Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,184 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 3 of 4 1 2 3 4
Re: Win API with Lite-C Pure Mode [Re: yorisimo] #151755
09/20/07 15:23
09/20/07 15:23
Joined: Jan 2007
Posts: 651
Germany
R
RedPhoenix Offline
User
RedPhoenix  Offline
User
R

Joined: Jan 2007
Posts: 651
Germany
I tried it very similar to your version, but like you had no success. The message function didn't react on any message (I tried several ones).

Re: Win API with Lite-C Pure Mode [Re: RedPhoenix] #151756
09/20/07 15:29
09/20/07 15:29
Joined: Mar 2007
Posts: 197
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

Joined: Mar 2007
Posts: 197
bummer, I will email support

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
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

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


Joris Lambrecht
My Contributions: Relative Rotation, Window Sizing
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
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Thx

it worked.

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
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

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: TWO] #151760
09/25/07 16:07
09/25/07 16:07
Joined: Mar 2007
Posts: 197
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

Joined: Mar 2007
Posts: 197
I tried something like this but the function was never called. How is the ScanMessage function called?

I used "SetWindowLong(hWnd,GWL_WNDPROC, WndProc);" to set the window procedure to my function. I tried the same with ScanMessage but it didn't work because ScanMessage does not have the same format (no hWnd parameter)

I assume it's already set by default, but why isn't it being called then?


Joris Lambrecht
My Contributions: Relative Rotation, Window Sizing
Re: Win API with Lite-C Pure Mode [Re: yorisimo] #151761
09/26/07 18:18
09/26/07 18:18
Joined: Mar 2007
Posts: 197
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

Joined: Mar 2007
Posts: 197
@TWO,

I've noticed that my method prevents me from using all the key_... variables. I guess this is because they are set by the default Acknex window procedure, and I am not using the default window procedure.
Does your method of using ScanMessage cause the same problem or can you still use the key_... variables? I also still don't know how to use ScanMessage. (I understand the format of the callback function, but not how it gets called). Could you provide some advice?


Joris Lambrecht
My Contributions: Relative Rotation, Window Sizing
Re: Win API with Lite-C Pure Mode [Re: yorisimo] #151762
09/26/07 18:42
09/26/07 18:42
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
yorisimo, that's why the ScanMessage thing was implemented. So the engine can handle incoming messages and than pass them to the SM func.

Just define the function like I've done, it should work well.

Re: Win API with Lite-C Pure Mode [Re: TWO] #151763
09/26/07 21:17
09/26/07 21:17
Joined: Mar 2007
Posts: 197
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

Joined: Mar 2007
Posts: 197
Could someone try this and let me know if it works. It's not working for me for some reason. When you resize (by dragging) the window it should give a message and beep. Thanks

Code:
 
#include <acknex.h>
#include <windows.h>

LRESULT CALLBACK ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);

function main() {
level_load("box.wmb"); wait(-.5);
while(1){
wait(1);
}
}

LRESULT CALLBACK ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_SIZE:
error("window resized");
beep(); break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}

return(0);
}




Joris Lambrecht
My Contributions: Relative Rotation, Window Sizing
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
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

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.
Page 3 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1