maybe i should of explained a little, but did not have the time. still dont sorry! heres a stripped down version of my main WB3D_InitializeGUI() function for you to look over.
look into SetWindowsHookEx() functions to get even more events from the api.
BBDECL HWND BBCALL API_InitializeGUI(HWND runtimewindow_Name,int x,int y,int width,int height){
runtimewindow = runtimewindow_Name;
if(!runtimewindow){
MessageBox(0,"Error","API_InitializeGUI",MB_OK);
}
lpOLDblitzproc = (WNDPROC) SetWindowLong(runtimewindow,GWL_WNDPROC,(LONG)GLOBAL_HOOKED_WINPROC);
lpInst = (HINSTANCE)GetModuleHandle(0);
if(!lpInst){
MessageBox(0,"lpInst error","lpInst handle",MB_OK);
}
// get blitz window style, add clip children style, so that controls are not blitted over
long winstyle = GetWindowLong(runtimewindow,GWL_STYLE);
SetWindowLong(runtimewindow,GWL_STYLE,winstyle | WS_CLIPCHILDREN);
gKBHook = SetWindowsHookEx(WH_GETMESSAGE,GLOBAL_HOOKED_MESSAGE_WINPROC,0,GetWindowThreadProcessId(runtimewindow,NULL));
wpBHook = SetWindowsHookEx(WH_CALLWNDPROC,GLOBAL_HOOKED_MESSAGE_WINPROC_2,0,GetWindowThreadProcessId(runtimewindow,NULL));
HookRET = SetWindowsHookEx(WH_CALLWNDPROCRET,GLOBAL_HOOKED_MESSAGE_WINPROC_RET,0,GetWindowThreadProcessId(runtimewindow,NULL));
HDWP r = BeginDeferWindowPos(1);
HDWP t = DeferWindowPos(r,runtimewindow,0,x,y,width,height,SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOZORDER );
EndDeferWindowPos(r);
// get the window class name of the runtime window
if(!GetClassName(runtimewindow, szClassName, nMaxCount)){
MessageBox(NULL,"CLASS NAME ERROR","ERROR: Blitz Class Name",MB_OK);
return FALSE;
}else{
if(!GetClassInfoEx(GetModuleHandle(0), szClassName,&wc)){
MessageBox(NULL,"CLASS NAME ERROR","ERROR: Blitz Class Info",MB_OK);
return FALSE;
}else{
// set window background.
SetClassLong(runtimewindow, GCL_HBRBACKGROUND, (LONG) GetSysColorBrush(COLOR_BTNFACE));
// set window icon
SetClassLong(runtimewindow, GCL_HICON, (LONG) LoadIcon(lpInst, IDI_APPLICATION));
// set window cursor
SetClassLong(runtimewindow, GCL_HCURSOR, (LONG) LoadCursor(NULL, IDC_ARROW));
// set window winproc
SetClassLong(runtimewindow, GCL_WNDPROC,(long)GLOBAL_HOOKED_WINPROC);
WINPROC_CHANGED = 1;
}
}
return runtimewindow;
}
|