CDialogBox is CWnd derived class. And CWnd in order have defined PreCreateWindow virtual function. So you just have to override CDialog_Derived_Window::PreCreateWindow() (the same way like for MainFrame::PreCreateWindow())
consult this FAQ Q: > I want to register my own class name for my dialog window. I add my > register code in the preCreateWindow routine, however, it cannot work. I > debug my code and found that it doesn't execute the preCreateWindow routine > when my window is created. Does someone tell me why it doesn't go through > this routine? Any help is really appreciated. > A: In a dialog application MFC does not create (or precreate) your window, it uses the Win32 dialog functions instead. Quicker and simpler, but they don't take a user-defined window class name. That means the dialog's class name is "Dialog". So what you want is just incompatible with the standard MFC dialog application. You could consider a doc/view app with a formview, or just roll your own window.
have defined PreCreateWindow virtual function. So you just have to override
CDialog_Derived_Window::PreCreateWindow() (the same way like for
MainFrame::PreCreateWindow())
Q:
> I want to register my own class name for my dialog window. I add my
> register code in the preCreateWindow routine, however, it cannot work. I
> debug my code and found that it doesn't execute the preCreateWindow routine
> when my window is created. Does someone tell me why it doesn't go through
> this routine? Any help is really appreciated.
>
A:
In a dialog application MFC does not create (or precreate) your window,
it uses the Win32 dialog functions instead. Quicker and simpler, but
they don't take a user-defined window class name. That means the
dialog's class name is "Dialog". So what you want is just incompatible
with the standard MFC dialog application. You could consider a doc/view
app with a formview, or just roll your own window.
我要修改cs结构,所以要用到PreCreateWindow函数,有什么别的方法可以达到这个目的吗?