Page 1 of 1

Strange CreateWindow behaviour in emulator

PostPosted: Mar 13, 2003 @ 8:21am
by superman
I was having some trouble testing some code in the emulator that worked well on my E-200, so I decided to track down the problem. After an hour or so of hunting, I finally got it down to a problem registering the window class.

Here is the scenario: I have a class wrapper for a window. In that class wrapper are funtions to register and create the window, as well as a static wndproc. On creation, I use setwindowlong to put a pointer to the specific class in its windows GWL_USERDATA. Then, in the wndproc, I get the GWL_USERDATA, cast it as a pointer to my class, and send the messages through to another function in the class that isn't shared.

I had two separate projects that I was using to play around with this. The first time I tried it, it worked great on both the emulator and the PPC. The second time I tried it, I found that I had to register the window class with a NULL wndproc and then use setwindowlong to set the GWL_WNDPROC to point to my static wndproc after I had created the window.

Every time I tried to create a window with the wndproc set when I registered the class, the program would kill itself when I called createwindow. It doesn't do this in the first project.

I have no idea what could be happening. Thoughts?

PostPosted: Mar 13, 2003 @ 8:14pm
by Orpe

PostPosted: Mar 13, 2003 @ 10:28pm
by superman
Thanks, that works perfectly. I don't know why I didn't realize that CreateWindow would send WM_CREATE to my wndproc. Thanks again.

PostPosted: Mar 13, 2003 @ 11:34pm
by Orpe