How to create a static derived class with controls inside it

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.


0
zhaoyandong
12/2/2003 3:36:12 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
710 Views

Similar Articles

[PageSpeed] 54

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.


"zhaoyandong" <zhaoyandong@163.net> wrote in message
news:ujQkepOuDHA.3496@TK2MSFTNGP11.phx.gbl...
> 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.
>
>


0
nospam7515 (2084)
12/2/2003 5:18:57 PM
create them in ur oncreate handler and don't subclass the static ctrl
use create to create it instead at the desired position


"zhaoyandong" <zhaoyandong@163.net> wrote in message news:<ujQkepOuDHA.3496@TK2MSFTNGP11.phx.gbl>...
> 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.
0
xmontyx (28)
12/3/2003 6:49:05 AM
Reply:

Similar Artilces: