Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 1 of 4 1 2 3 4
Win API with Lite-C Pure Mode #151735
09/02/07 17:06
09/02/07 17:06
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Hallo

I am creating one game with lite-c pure mode.
I want to use windows.h creating Menu and Sub-menu in the game windows.

I create Menu and insert this menu with the code
long menu=CreateMenu();
InsertMenu(menu,1,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu1,"Option");
but when i will set the menu to the windos, did not work beocause I did not know the name of windows.
SetMenu(long hWnd,menu);

How i could create Menu and Submenu in Lite-c Pure?

thx

Re: Win API with Lite-C Pure Mode [Re: amadeu] #151736
09/02/07 17:39
09/02/07 17:39
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
Read the avars.h in the engine include folder you will get the handle of the engine window.
You can use all of the Vars in your programms (hope so).

hWnd is the HWND handle of the acknex engine.
hInstance is the HINSTANCE handle of the engine.

Menu adding works for me with hWnd

great feature

SetMenu(hWnd,YourMenu_here);

Last edited by dblade; 09/02/07 17:41.
Re: Win API with Lite-C Pure Mode [Re: dblade] #151737
09/02/07 18:10
09/02/07 18:10
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
hI

Thanks, it worked.
I have other question. after I set my menu, I rum the game and when I try to click in the menu , nothing happens. Why? I created one function to create menu, as:
function createMenu()
{
long menu=CreateMenu();
long hSubMenu;
long hSubMenu1;
long hSubMenu2;
hSubMenu=CreateMenu();
hSubMenu1=CreateMenu();
hSubMenu2=CreateMenu();
InsertMenu(hSubMenu,1,MF_BYPOSITION|MF_STRING,1,"Open");
InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu2,"save");
InsertMenu(hSubMenu,0,MF_BYPOSITION|MF_STRING,3,"QUIT");
InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"File");
InsertMenu(menu,1,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu1,"Option");
InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,1,"teste");
SetMenu(hWnd,menu);
}
What Will I need to do?

Re: Win API with Lite-C Pure Mode [Re: dblade] #151738
09/03/07 02:24
09/03/07 02:24
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
hI

Thanks, it worked.
I have other question. after I set my menu, I rum the game and when I try to click in the menu , nothing happens. Why? I created one function to create menu, as:
function createMenu()
{
long menu=CreateMenu();
long hSubMenu;
long hSubMenu1;
long hSubMenu2;
hSubMenu=CreateMenu();
hSubMenu1=CreateMenu();
hSubMenu2=CreateMenu();
InsertMenu(hSubMenu,1,MF_BYPOSITION|MF_STRING,1,"Open");
InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu2,"save");
InsertMenu(hSubMenu,0,MF_BYPOSITION|MF_STRING,3,"QUIT");
InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"File");
InsertMenu(menu,1,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu1,"Option");
InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,1,"teste");
SetMenu(hWnd,menu);
}
What Will I need to do?
I need create the function: LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

I am lost. Could someone help me?

thx

Amadeu

Re: Win API with Lite-C Pure Mode [Re: amadeu] #151739
09/03/07 10:23
09/03/07 10:23
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
Have a Menu Problem, too
When mouse_sync is off the cursor isn`t visible over the added menu.
But when mouse_sync is on the cursor allways blinks.
(32 x 32) cursor image, tga

For your Problem:
Look at the mci.c example, there is a menu code
Copy it in an own Project (without WinMain and LRES stuff) and try.
Worked very well for me

Re: Win API with Lite-C Pure Mode [Re: dblade] #151740
09/03/07 10:50
09/03/07 10:50
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Hi,
I tried but did not work. What I write when I take off the WinMain and LRES stuff?
I need create a new int function instead of WinMain like: int createMenu() and void WndProc(...) instead of LRESULT CALLBACK WndProc(...);
Please see my code above and tell me what I did wrong.


////////////////////////////////////////////////////////////////////
#include <litec.h>
#include <acknex.h>
#include <default.c>

////////////////////////////////////////////////////////////////////

void WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message){
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(wParam){
case 1:
{
OPENFILENAME of;
char buf[256];
FillMemory(&of,sizeof(of),0);
FillMemory(buf,256,0);
of.Flags=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
of.lpstrFilter ="Supported Files Types (*.mp3;*.wav;*.mpg;*.mpeg)\0*.mp3;*.wav;*.mpg;*.mpeg\0";
of.lStructSize=sizeof(of);
of.hwndOwner=hWnd;
of.lpstrFile=buf;
of.nMaxFile=255;
of.lpstrTitle="Open";
if (GetOpenFileName(&of))
MessageBox(NULL,"abriu","My first program",0);
}
break;
case 2:
break;
case 3:
PostQuitMessage(0);
break;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
RECT rect;GetClientRect(hWnd,&rect);
EndPaint(hWnd, &ps);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

int createMenu()
{
char *szClass="CScriptWindowClass";
HINSTANCE hInstance=GetModuleHandle(NULL);
UnregisterClass(szClass,hInstance);
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,128);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = COLOR_WINDOW+1;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szClass;
wcex.hIconSm = LoadIcon(hInstance,128);
RegisterClassEx(&wcex);
long menu=CreateMenu();
long hSubMenu;
hSubMenu=CreateMenu();
InsertMenu(hSubMenu,0,MF_BYPOSITION|MF_STRING,1,"Open");
InsertMenu(hSubMenu,2,MF_BYPOSITION|MF_STRING,3,"QUIT");
InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"File");
if (hWnd)
{
SetMenu(hWnd,menu);
ShowWindow(hWnd,SW_SHOW);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
}



void main()
{
video_mode = 7; // lite-C: start in 640x480 resolution
video_screen = 2; // lite-C: start settings for Fullscreen
level_load("VAH.wmb");
wait(2); // let level load
Mouse_init(); // function for the mouse
createMenu();
}

Re: Win API with Lite-C Pure Mode [Re: amadeu] #151741
09/03/07 10:59
09/03/07 10:59
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
First, please tell me why did you inlude litec.h when you want to program in pure-mode ?
Just include acknex.h, windows.h and if you want default.c

Will check the code and post you an example, but will take a while (just re-installed GStudio)

See ya

Re: Win API with Lite-C Pure Mode [Re: dblade] #151742
09/03/07 11:11
09/03/07 11:11
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
ok
thanks.
i will wait your example.

See you.

Re: Win API with Lite-C Pure Mode [Re: dblade] #151743
09/03/07 11:13
09/03/07 11:13
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
#include <acknex.h>
#include <windows.h>

int main(void)
{
wait(1); //don't set in the first frame
char *szClass="LiteC menu_test";
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW|CS_VREDRAW;
wcex.cbClsExtra = 0;
wcex.lpfnWndProc = NULL;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hbrBackground = COLOR_WINDOW+1;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szClass;
RegisterClassEx(&wcex);

long menu=CreateMenu();
long hSubMenu;
hSubMenu=CreateMenu();
InsertMenu(hSubMenu,0,MF_BYPOSITION|MF_STRING,1,"Open");
InsertMenu(hSubMenu,2,MF_BYPOSITION|MF_STRING,3,"QUIT");
InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"File");

if(hWnd)
{
SetMenu(hWnd,menu);
}
}

/*
Here, a modified version of the mci menu
Works fine for me without the LRES stuff and so on
*/

Re: Win API with Lite-C Pure Mode [Re: dblade] #151744
09/03/07 11:24
09/03/07 11:24
Joined: Jan 2007
Posts: 651
Germany
R
RedPhoenix Offline
User
RedPhoenix  Offline
User
R

Joined: Jan 2007
Posts: 651
Germany
From MSDN:
Quote:

Associated with each menu item is a unique, application-defined integer, called a menu-item identifier. When the user chooses a command item from a menu, the system sends the item's identifier to the owner window as part of a WM_COMMAND message. The window procedure examines the identifier to determine the source of the message, and processes the message accordingly. In addition, you can specify a menu item using its identifier when you call menu functions; for example, to enable or disable a menu item.






This is your problem right? You can't get the message that the item sends when pressed by the user. I tried receiving this for days, but I didn't succeed what of course doesn't mean that it's impossible.
My advice: Create the menu on your own using panels and buttons. You can use the API for showing the menudialogs like open save and close, but I don't recommend you using the windows menustructure itself.

Page 1 of 4 1 2 3 4

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

Gamestudio download | 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