Jump to content
  • Advertisement
Sign in to follow this  
pavel989

C++, XP child windows

This topic is 3478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, im trying to create a child window, but no matter what values i change, i cannot get a HWND for it. just keeps failing. are there like specific rules in making one? im Using createwindowexa() -- or something like that, but my point is, i know which parameter is which, but like are there rules for the params themselves?

Share this post


Link to post
Share on other sites
Advertisement
Of course there are rules.

You'll have to provide some actual code for us to know what the actaul problem actually is, though.

Share this post


Link to post
Share on other sites
a) Don't use the *A and *W forms of the API calls unless you have a very good reason - use the normal ones and let you project's UNICODE settings decide which one to use.

b) Post some code so we can figure out what is wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by EasilyConfused
a) Don't use the *A and *W forms of the API calls unless you have a very good reason - use the normal ones and let you project's UNICODE settings decide which one to use.

b) Post some code so we can figure out what is wrong.


c) Tell us what GetLastError() returns after CreateWindow() fails

d) Put a breakpoint in your window proc and see if it's ever called - If so, make sure you're processing WM_CREATE properly, and returning 0 for that message.

Share this post


Link to post
Share on other sites

if(!CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
"ChildWClass",
(LPCTSTR) NULL,
WS_CHILD | WS_BORDER,
0,0,100,100,
hWnd, NULL,
hInstance,
NULL)
)
{
MessageBox(NULL,"Child Window Creation Error.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
return 0;
}
LPTSTR pszMessage;
DWORD dwLastError = GetLastError();

FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL,
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszMessage,
0, NULL );
wprintf(L"%s failed with error %d: ", (LPSTR) dwLastError, pszMessage);





create window ex returns null if it failed, wprintf says (null) failed with error: 1500872


-- it seems to not extract the Dword error. i took the format message code from msdn.

Share this post


Link to post
Share on other sites
Quote:
Original post by pavel989
wprintf(L"%s failed with error %d: ", (LPSTR) dwLastError, pszMessage)


You've got dwLastError and pszMessage backwards. The text of the message "failed with error" also doesn't make sense with the parameters you're passing in.

My guess is the problem is you're passing NULL for the window title. I think you need to pass a valid value.

Share this post


Link to post
Share on other sites
Quote:
Original post by pavel989
*** Source Snippet Removed ***

create window ex returns null if it failed, wprintf says (null) failed with error: 1500872


-- it seems to not extract the Dword error. i took the format message code from msdn.
That means that dwLastError is 0, which is "No error".

Did you try this:
Quote:
Original post by Evil Steve
d) Put a breakpoint in your window proc and see if it's ever called - If so, make sure you're processing WM_CREATE properly, and returning 0 for that message.
?

Share this post


Link to post
Share on other sites
Sorry for the late response. Was on a break :)

Do I have to put it in wm_create?

And do I need to register a new window class?
If so, after or befor I call this createwindow func?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!