views:

1261

answers:

2

i'm new to C++ as well as for windows programming..

i have created a window using msdn CreateWindow() function

which works correctly..now i would like to create a child window...the parent window should control the child window...

Any helps sample code regarding this .

Thanks in advance

+2  A: 

Roughly speaking, in the handler for the parent, where you wish to create the child, you call CreateWindow, passing in the window for the parent as the hwndParent - probably, you also want to set certain styles on the child such as WS_CHILD. Your interaction with the child window then depends on the type of the window you created. Some windows (such as buttons) are designed to work as child windows, so they send a lot of notification messages, so you would set up your parent to listen for those notification messages.

1800 INFORMATION
+2  A: 

I'd highly recommend having a read through Charles Petzold's "Programming Windows" if you can obtain a copy.

Otherwise, to answer your question, pass the parent window's handle as the parent when you create the child window (using either CreateWindow or CreateWindowEx):

HWND CreateWindowEx
(      
    DWORD dwExStyle,
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName,
    DWORD dwStyle,
    int x,
    int y,
    int nWidth,
    int nHeight,
    HWND hWndParent,      /// pass the parent window handle here
    HMENU hMenu,
    HINSTANCE hInstance,
    LPVOID lpParam
);

..As 1800 Info has also stated, perhaps also set the WS_CHILD style (more oon Window Styles here). This is just the rudimentary plumbing, really..

Can you be a bit more specific when you say "control the child window..."?

RobS