Article View: comp.windows.ms.programmer
Article #2389Re: Creating a Button inside a child process
From: Kent Forschmiedt
Date: Wed, 01 May 1991 21:08
Date: Wed, 01 May 1991 21:08
26 lines
1667 bytes
1667 bytes
In article <1991Apr29.140448.2027@iplmail.orl.mmc.com>
darak@iplmail.orl.mmc.com (dara khani) writes:
> CreateWindow("button", "hi", WS_CHILD | WS_VISIBLE | WS_PUSHBUTTON,
> 1,1, 30,30, hWnd, 1, hInst, NULL)
>I not sure if the order of the parameters are right ( I don't have
> the program with me).
>hWnd is the handle of the child
>hInst is the instance of the parent
>
>the handle returned from the CreateWindow is NULL (button not created).
>Now, if I put the same CreateWindow in the WM_PAINT part of the procedure
>( I know this is wrong) the button is created.
One common source of this sort of problem in WM_CREATE processing is
that in a WM_CREATE message, the hwnd is not entirely valid yet. Use
data from the CREATESTRUCT pointed to by lParam, rather than using e.g.
GetWindowWord(); the most common use I find is for getting hInstance:
((LPCREATESTRUCT)lParam)->hInstance
The CREATESTRUCT contains the stuff from the CreateWindow() call.
(Actually, it looks like a pointer to the actual arguments to the
CreateWindow() call, but I don't feel like running CodeView right
now, so I won't look and see)
--
Kent Forschmiedt ... kentfo@polari ... uw-beaver!sumax!polari!kentfo
Technical Details
Message-ID:
<3931@polari.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!milton!sumax!thebes!polari!kentfoReferences:
<1991Apr29.140448.2027@iplmail.orl.mmc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!milton!sumax!thebes!polari!kentfo From: kentfo@polari.UUCP (Kent Forschmiedt) Newsgroups: comp.windows.ms.programmer Subject: Re: Creating a Button inside a child process Message-ID: <3931@polari.UUCP> Date: 1 May 91 21:08:04 GMT References: <1991Apr29.140448.2027@iplmail.orl.mmc.com> Organization: Seattle Online Public Unix (206) 328-4944 Lines: 26