From: Giuliano Suminsky on
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
* 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
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
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
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.