Could you provide some more information about how to use ScanMessage. I've looked in the manual, at the Lite-C legacy examples, and the GStudio include files and I'm still having trouble. I have some questions about the engine window that is created by default when using Lite-C pure mode (I'll just call it Engine Window)
All my questions refer to Lite-C Pure mode.
1.Does the Engine Window automatically check for messages using GetMessage?
2.Is the Engine Window created using the WNDCLASS or WNDCLASSEX class and CreateWindow or CreateWindowEx?
3.Is the lpfnWndProc member of one of those classes set to ScanMessage by default?
Or do i need to use SetWindowLong, or some other Win API function to change the Window Procedure function?
4.I figured out I can use SetWindowLong(hWnd,GWL_STYLE, WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_SIZEBOX); ShowWindow(hWnd,SW_SHOW); to activate the maximize button and make the window sizeable. I also know how to get the current client area using GetClientRect() which I can use to adjust the resolution to mathch the resolution to the client area. However It seems video_set() affects window style, so the maximize button becomes inactive. What does video_set use to adjust the window resolution and why is it affecting the style?
I've included some code so it might be easier for you to find where I've made mistakes or if I'm totally on the wrong track. It runs, but nothing happens when you select the menu items, or click in the engine window. I put a beep in the ScanMessage function to see if it ever gets called--It doesn't!. So how do I use ScanMessage?! (Where/when/how does ScanMessage get called?)
Code:
#include <acknex.h>
#include <default.c>
#include <windows.h>
function ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);
function main()
{
wait(1);
HMENU menu=CreateMenu();
HMENU hSubMenu=CreateMenu();
InsertMenu(hSubMenu,0,MF_BYPOSITION|MF_STRING,1,"BEEP");
InsertMenu(hSubMenu,1,MF_BYPOSITION|MF_STRING,2,"QUIT");
InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"File");
//SetWindowLong(hWnd,GWL_WNDPROC, &ScanMessage); //(Causes Crash with or without '&')
//Change Window style to activate Maximize button
SetWindowLong(hWnd,GWL_STYLE, WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_SIZEBOX);
SetMenu(hWnd,menu);
ShowWindow(hWnd,SW_SHOW);
// I'm not sure if this part is already taken care of somewhere?
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
wait(1);
}
///////////////////////////////
}
function ScanMessage(UINT message, WPARAM wParam, LPARAM lParam){
error("here");
switch(message){
case WM_LBUTTONDOWN:
MessageBox(NULL, "L mouse down","info", MB_OK);
break;
case WM_RBUTTONDOWN:
MessageBox(NULL, "R mouse down","info", MB_OK);
break;
case WM_COMMAND:
switch(wParam){
case 1: beep(); break;
case 2: sys_exit(NULL);
}
default:
MessageBox(NULL, "default","info", MB_OK);
}
return;
}