Archived

This topic is now archived and is closed to further replies.

original vesoljc

classes & CALLBACK func

Recommended Posts

I think there''s an article here in gamedev.net that discusses about this problem, but I forget the title. Try to search "win32 wrapper" or something like that. It should give you some results. This is what I got:
http://www.gamedev.net/reference/programming/features/win32wrapper/


My compiler generates one error message: "Doesn''t compile."
-Albert Tedja-

Share this post


Link to post
Share on other sites
again i cry for help...
i think i''m trying to create a msg router. the thing compiles, after which i get a few windowproc calls an at the end access violation...

URL for the project
http://vesoljc.tripod.com/AXP/AXP_Engine.zip



Abnormal behavior of abnormal brain makes me normal...

Share this post


Link to post
Share on other sites
win_app in AXP_WinApp::StaticWindowProc is zero, from then on an access violation is guaranteed. Read over the presented solutions again. I also compiled a couple of projects demonstrating different techniques, which you can grab here. In two words:

Base: the application template, for reference only
SimpleGlobal: uses a global variable to call instance WndProc
SimpleCreateHandler: uses per-window data and WM_NCCREATE. This is what you should have in your code, examine this project carefully.
OptimizedCreate: a slightly optimized version, with two static window procedures
CBTHook: uses per-window data and CBT hook instead of WM_NCCREATE.

I''m also thinking of wrapping this up with an article or something like that, would anyone be interested?

---
Come to #directxdev IRC channel on AfterNET

Share this post


Link to post
Share on other sites
i did the simple create handler, which on the first look appers to be ok. the thing compiles and a window is created. but it seems that none of the msg-es get handled.
In my WindowProc i tried WM_KEYDOWN, WM_ACTIVATE, but none of them work...

u can dl the project at:
http://vesoljc.tripod.com/AXP/AXP_Engine.zip


Abnormal behavior of abnormal brain makes me normal...

Share this post


Link to post
Share on other sites
still need help...

LRESULT CALLBACK AXP_WinApp::StaticWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
// Store this pointer in WM_NCCREATE handler
if (msg == WM_NCCREATE)
{
LPCREATESTRUCT lpcs = LPCREATESTRUCT(lparam);
SetWindowLong(hwnd, GWL_USERDATA, (long) lpcs->lpCreateParams);
}
// Retrieve it from per-window data, and call the instance WndProc
AXP_WinApp *pThis = (AXP_WinApp *) GetWindowLong(hwnd, GWL_USERDATA);
error = GetLastError();
Debug("ERROR=%d",error);
if (pThis)
{
return pThis->WindowProc(hwnd, msg, wparam, lparam);
}
else
{
// This branch will be called for the first WM_GETMINMAXINFO message, because it is processed
// before WM_NCCREATE is, so this pointer is not available yet
return DefWindowProc(hwnd, msg, wparam, lparam);
}

}

i found out that getWindowLong returns zero, so pthis is also null... last error is 183: cannont create file when allread exists...





Abnormal behavior of abnormal brain makes me normal...

Share this post


Link to post
Share on other sites
guys... really need help!

i found out that the problem is this line:
SetWindowLong(hwnd, GWL_USERDATA, (long) lpcs->lpCreateParams);
by some strange stuff "(long) lpcs->lpCreateParams" returns zero which is then set. any ideas why this is working like it should???


Abnormal behavior of abnormal brain makes me normal...

Share this post


Link to post
Share on other sites