2 registered members (AndrewAMD, alibaba),
1,184
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Win API with Lite-C Pure Mode
[Re: yorisimo]
#151757
09/20/07 17:38
09/20/07 17:38
|
Joined: Mar 2007
Posts: 197
yorisimo
Member
|
Member
Joined: Mar 2007
Posts: 197
|
Have not heard back from support yet obviously, but I figured out a solution without ScanMessage. Try this example (should run fine): Code:
#include <acknex.h> #include <default.c> #include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, 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, WndProc); //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); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ 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: return DefWindowProc(hWnd, message, wParam, lParam); } return(0); } I will make a nice example with some common dialogs and post in Lite-C contributions
|
|
|
Re: Win API with Lite-C Pure Mode
[Re: yorisimo]
#151758
09/22/07 08:23
09/22/07 08:23
|
Joined: Aug 2006
Posts: 78
amadeu
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 78
|
|
|
|
Re: Win API with Lite-C Pure Mode
[Re: amadeu]
#151759
09/22/07 16:42
09/22/07 16:42
|
Joined: Jan 2006
Posts: 1,829 Neustadt, Germany
TWO
Serious User
|
Serious User
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
|
This works for me: Code:
LRESULT CALLBACK ScanMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CLOSE: sys_exit(NULL);
case WM_QUIT: sys_exit(NULL);
case WM_KILLFOCUS: ED_WindowFocus = false;
case WM_SETFOCUS: ED_WindowFocus = true;
case WM_COMMAND: { switch(wParam) { case 1: { break; } case 2: { break; } case 3: { sys_exit(NULL); break; } } } default: return DefWindowProc(hWnd, message, wParam, lParam); } return(0); }
JCL, please add an example for this to the manual.
|
|
|
Re: Win API with Lite-C Pure Mode
[Re: yorisimo]
#151764
09/27/07 20:01
09/27/07 20:01
|
Joined: Mar 2007
Posts: 197
yorisimo
Member
|
Member
Joined: Mar 2007
Posts: 197
|
From GS email support: "you must not name your function "ScanMessage" because there's already a function pointer of this name (see manual). And you'll need that pointer for implementing a message loop." AND "You must not have a default case, and not call DefWindowProc. Otherwise the Windows Message loop is called twice for most messages, with undesired effects." @TWO: are you sure that your implementation of ScanMessage works? I noticed that most of your callbacks do default things (like exit) How do you use the ScanMessage function pointer to implement the message loop? I assumed it was something like this, but it's still not working (MyMessageFunction should cause a beep and error message when the window is resized): Code:
#include <acknex.h> #include <windows.h>
long MyMessageFunction(UINT message, WPARAM wParam, LPARAM lParam);
function main() { ScanMessage=MyMessageFunction; while(1) { wait(1); } }
long MyMessageFunction(UINT message, WPARAM wParam, LPARAM lParam){ switch(message){ case WM_SIZE: beep(); error("resized"); return(0); } }
Last edited by yorisimo; 09/27/07 21:55.
|
|
|
|