2 registered members (AndrewAMD, TipmyPip),
12,420
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Member
|
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
amadeu
OP
Junior Member
|
OP
Junior Member
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
amadeu
OP
Junior Member
|
OP
Junior Member
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
Member
|
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
amadeu
OP
Junior Member
|
OP
Junior Member
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
Member
|
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]
#151743
09/03/07 11:13
09/03/07 11:13
|
Joined: May 2007
Posts: 175 Germany
dblade
Member
|
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  */
|
|
|
|