mfc >> How to create a static derived class with controls inside it

by zhaoyandong » Tue, 02 Dec 2003 23:36:12 GMT

I want to create a CStatic derived class(eg. CMyStatic), which has some
controls inside it.


At first I want to add these controls at "CStatic::PreSubclassWindow", but
if I want to create the CMyStatic programmically, error will appear.

So I'm asking when should I add these controls to my class.

Thank you.




mfc >> How to create a static derived class with controls inside it

by Ali R. » Wed, 03 Dec 2003 01:18:57 GMT


The way I personally got around this problem was to put my creation function
in a Function by itself. override the Create method and the
PreSubclassWindow methods. From the Create function set a flag that says it
is being created using the create function, rather than being subclassed by
ddx_control. call the create after the create call the function to create my
internal controls. In the PreSubclassWindow method if the flag is not set
then call the function to create the internal controls.

BOOL CMyStatic::Create(LPCSTR lpszText,DWORD dwStyle,const RECT &rect,CWnd
*pParentWnd,UINT nID)
{
m_bCreate = true;
if (CStatic::Create(lpszText,dwStyle......))
{
CreateControls();
return TRUE;
}
return FALSE;
}

void CMyStatic::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
if (!m_bCreate)
{
CreateControls();
}
}

Ali R.









mfc >> How to create a static derived class with controls inside it

by xmontyx » Wed, 03 Dec 2003 14:49:05 GMT

create them in ur oncreate handler and don't subclass the static ctrl
use create to create it instead at the desired position





Similar Threads

1. How to create own (derived) control class - Windows CE

2. control in base class is underneath control in derived class

Hi.  My problem is that a control in the base class is
underneath a control in derived class.  But I want to make it be
on top.  How to do this?

Details:

(1) There is a frame object F1 derived from TFrame.  It has a
control on the form, say a TButton B1 of size 10*10 at location
100*100.

(2) There is an object F2 derived from the frame F1.  On this
frame I paste a frame S1 of size 100*100 at location 50*50.  As
you can guess, S1 covers B1, so B1 is hidden.

How can I make B1 be on top?  I have tried the following:

(1) Right click S1 and say Send To Back, but it does not work.
(2) Try to right click B1, but it does not work.
(3) Look for the Transparent property of S1, but did not find it.
Also, my frame S1 has on it a panel P1.  So I'd have to make
both S1 and P1 transparent.

Thanks.

3. How to get inherited class type/name inside static base class meth - CSharp/C#

4. How to get inherited class type/name inside static base class

Hi James

My base class meyhod is static and because of being static the keyword 
"this" is not available.


"james" wrote:

> 
> "Eliseu Rodrigues" < XXXX@XXXXX.COM > wrote in 
> message news: XXXX@XXXXX.COM ...
> > Hi
> >
> > I would like to have a static method on a base class that executes some
> > action (for example retrieves the row count) on a table whose name is the
> > same of the inherited class name.
> >
> > For example:
> >
> > Assume that my base class has a static method named GetRowCount().
> >
> > Having a class named Customer that inherits from my base class when i call
> > the method Customer.GetRowCount() it should return the number of rows
> > existing on my Customer table.
> >
> > Having a class named Employee it should return the number of rows in the
> > Employee table, and so on...
> >
> > My question is:
> > How can I get my inherited class name (Customer, Employee, etc...) inside
> > the body of my static method in the base class?
> >
> 
> If what I think you have is correct, "this.GetType().ToString(); should give 
> you your type name?
> I have a base class called "cnParams", and inherited off this are several 
> others such as a clsPing, clsWeb and so on. From a method inside the base 
> cnParams I can set a string to this.gettype().tostring() and it returns 
> "appname.clsPing" etc.?
> James 
> 
> 
> 

5. Static Constructor of Abstract class and Derived Classes - CSharp/C#

6. derived class objects in base class static function

hello group,

is it possible to use derived class objects in base class static function?

example:

#include <iostream>

class b;

class a
{
	public:
		a() {}
		virtual ~a() {}

		static void Init() {b thing; thing.Do();} // compile
							  // error
};

class b : public a
{
	public:
		b() {}
		virtual ~b() {}

		void Do() {std::cout << "hello?" << std::endl;}
};

int main()
{
	a::Init();
}

thanx & hand, chris

7. Custom Control derived from CWnd won't paint inside CFormView Wind

8. function defined with base class return derived class object when called with a derived class