🔒 Locked
classes & CALLBACK func
Advertisement
Original Post
i''m trying to make a simple win wrapper and WindowProc (CALLBACK) is giving me problems. at the end i solved it the way i shouldn''t. i made it global.
how should it be?!?
Abnormal behavior of abnormal brain makes me normal...
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-
http://www.gamedev.net/reference/programming/features/win32wrapper/
My compiler generates one error message: "Doesn''t compile."
-Albert Tedja-
cool...
Abnormal behavior of abnormal brain makes me normal...
Abnormal behavior of abnormal brain makes me normal...
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...
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...
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
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
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...
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...
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...
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...
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...
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...
it''s been set to null, while i must fill it with this 
took me some time
niyaw: tnx, will mention u
Abnormal behavior of abnormal brain makes me normal...
took me some time
niyaw: tnx, will mention u
Abnormal behavior of abnormal brain makes me normal...
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement