Razort4x
Razort4x

Reputation: 3416

What's wrong with this CreateWindowEx function?

Okay, so first a little overview of what I am tryna do..
I am trying to create 3 child window in a main parent window, and use EnumChildWindow and EnumChildProc to enumerate them, I want to create 3 child windows of same height as of parent but 1/3rd width, and align them one after the other..

So, I captured the WM_CREATE msg to create those child window, and WM_SIZE to move and align them using MoveWindow, everything is fine except for the fact that no child window is created. When I debugged it, I found that (in the Autos Window in Visual Studio 2008, while debugging) my CreateWindowEx statement is not getting executed (the autos window said "Expression cannot be evaluated."

Here's the statement:

CreateWindowEx(0, (LPCWSTR)("childClass"), (LPCWSTR)NULL, WS_CHILD | WS_BORDER, 0, 0, 0, 0, hWnd, (HMENU) (int) (ID_FIRSTCHILD + 1), hInst, NULL);

of course I was using it in a for loop to create 3 windows, but that's the other thing...
So, can anyone please help/guide/advice me what is going on in here? Or what am I doing wrong?

ps: I am reading this ebook from where I got this code and all, so please don't ask me to adopt another approach or something, say put the Child creation code somewhere else or so... because I am not making any program, but just following a book's example... :)

Upvotes: 0

Views: 1228

Answers (1)

selbie
selbie

Reputation: 104589

My psychic powers suggest you need to pass in the WS_VISIBLE style to the CreateWindow call above for your child windows - so you can seem them. :)

My development experience suggests the following:

What is the return value of CreateWindowEx? Did you assign the return value to a variable. And if so, did you set a breakpoint on that line in the debugger? And if the return value from CreateWindow is NULL, then what is GetLastError (which you can evaluate in the debugger as "@err").

After your main window pops up (with the children invisible), did you run Spy++ to see if the child windows exist? What is their state?

Otherwise, did you validate that the WM_CREATE callback of the WndProc of your child window class is getting called?

Upvotes: 1

Related Questions