Prev: Relay accurate time over network
Next: How to know exactly when a window is ceated for the first time (WM_CREATE and WM_NCCREATE not working )
From: Giuliano Suminsky on 27 Sep 2009 16:20 Hi, I was just trying to create a button( BS_GROUP ) at the WM_CREATE of the main window, but it fails.. But when I create it just after create the main window, its fine, why? Cant I create buttons at the WM_CREATE? Or is just something stupid Im missing? That works ok: //******* hmainwnd = CreateWindow( TEXT("MAINWNDCLASS"), szCaption, WS_OVERLAPPEDWINDOW, wndrect.left, wndrect.top, wndrect.right, wndrect.bottom, NULL, NULL, hInstance, NULL ); hbgroupIPDisplay = CreateWindow( TEXT("Button"), TEXT("Your IP"), WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 50, 50, 160, 160, hmainwnd, (HMENU)100, //button ID GetModuleHandle(NULL), NULL ); //********** That dont: //********* case WM_CREATE: hbgroupIPDisplay = CreateWindow( TEXT("Button"), TEXT("Your IP"), WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 50, 50, 160, 160, hmainwnd, (HMENU)100, //button ID GetModuleHandle(NULL), NULL ); return 0; //***********
From: Alf P. Steinbach on 27 Sep 2009 16:46 * Giuliano Suminsky: > Cant I create buttons at the WM_CREATE? You can. > Or is just something stupid Im > missing? Yes. However, you don't post enough of your code (and what you posted is too ugly) to say what, exactly. Cheers & hth., - Alf
From: Markus Schaaf on 27 Sep 2009 17:05 Giuliano Suminsky wrote: > case WM_CREATE: > > hbgroupIPDisplay = CreateWindow( TEXT("Button"), TEXT("Your IP"), > WS_CHILD | WS_VISIBLE | BS_GROUPBOX, > 50, 50, 160, 160, > hmainwnd, (HMENU)100, //button ID > GetModuleHandle(NULL), > NULL ); > Probably `hmainwnd` is not initialized. If that code fragment is part of a window procedure, you should use the passed window handle.
From: Giuliano Suminsky on 27 Sep 2009 17:14 On 27 set, 19:05, Markus Schaaf <msch...(a)elaboris.de> wrote: > Giuliano Suminsky wrote: > > case WM_CREATE: > > > hbgroupIPDisplay = CreateWindow( TEXT("Button"), TEXT("Your IP"), > > WS_CHILD | WS_VISIBLE | BS_GROUPBOX, > > 50, 50, 160, 160, > > hmainwnd, (HMENU)100, //button ID > > GetModuleHandle(NULL), > > NULL ); > > Probably `hmainwnd` is not initialized. If that code fragment is part > of a window procedure, you should use the passed window handle. Ah! I knew it ! That WM_CREATE IS from hmainwnd CreateWindow(), so it just get fully initialized when back from that function right? Anyway, now its ok, thanx. How cant it be initialized if that WM_CREATE is for that window ?
From: Giuliano Suminsky on 27 Sep 2009 17:17
On 27 set, 19:05, Markus Schaaf <msch...(a)elaboris.de> wrote: > Giuliano Suminsky wrote: > > case WM_CREATE: > > > hbgroupIPDisplay = CreateWindow( TEXT("Button"), TEXT("Your IP"), > > WS_CHILD | WS_VISIBLE | BS_GROUPBOX, > > 50, 50, 160, 160, > > hmainwnd, (HMENU)100, //button ID > > GetModuleHandle(NULL), > > NULL ); > > Probably `hmainwnd` is not initialized. If that code fragment is part > of a window procedure, you should use the passed window handle. Ah! I knew it ! That WM_CREATE IS from hmainwnd CreateWindow(), so it just get fully initialized when back from that function right? Anyway, now its ok, thanx. |