windows functions?

Posted By: Espér

windows functions? - 12/04/09 17:06

hi there..

i wanted to ask if someone knows a way/tutorial/help for my problem:

I want to create editor menüs. At the moment, i do this with bitmaps, panels and buttons. but isn´t there a way to use the windows bordes, frames, tooltip windows, menüs ...etc... inside the A7 window?
Posted By: Quad

Re: windows functions? - 12/04/09 18:03

yes there is but not very easy.

best practice for that would be using c# wrapper and c# itself.
Posted By: Espér

Re: windows functions? - 12/04/09 18:13

hmm.. Sylar gave me the following code...
Can someone explain me how to ask wich menüpoint was selected??? Means - How to ask if new, end, open ...ect is selected.

Code:
#include <windows.h>

long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);

function test()
{
    long menu;
    long hSubMenu;
    long hSubMenu2;
    
    HWND hwnd=hWnd;

    menu=CreateMenu();
    hSubMenu=CreateMenu();
    hSubMenu2=CreateMenu();

    InsertMenu(hSubMenu,1,MF_BYPOSITION|MF_STRING,1,"Neu");
    InsertMenu(hSubMenu,2,MF_BYPOSITION|MF_STRING,2,"Öffnen");
    InsertMenu(hSubMenu,3,MF_BYPOSITION|MF_STRING,3,"Speichern");
    InsertMenu(hSubMenu,4,MF_BYPOSITION|MF_STRING,4,"Beenden");
    
    InsertMenu(hSubMenu2,1,MF_BYPOSITION|MF_STRING,5,"Test1");
    InsertMenu(hSubMenu2,2,MF_BYPOSITION|MF_STRING,6,"Test2");

    InsertMenu(menu,0,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu,"Datei");
    InsertMenu(menu,1,MF_BYPOSITION|MF_STRING|MF_POPUP,hSubMenu2,"Bearbeiten");
    
    SetMenu(hwnd,menu);
}


void main()
{
    video_set(800,600,32,2);
    
    level_load(NULL);
    wait(2);
    test();
    
  on_scanmessage = ScanMessage;
}

long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (WM_COMMAND) {
            case message:
                switch (wParam) {
                    case 1:
                        printf("Es wurde auf 'neu' geklickt");
                        return(1);
                        
                    case 2:
                        printf("Es wurde auf 'öffnen' geklickt");
                        return(1);

                    // USW:
                    
                    default:
                        break;
                }
                
                break;
            default:
                break;
        }
}



Sylar won´t help me, because he misunderstood a message from me..
Posted By: Lukas

Re: windows functions? - 12/04/09 18:21

It's possible with WINAAPI functions to do this like you would in C/C++. You can see an example for this in mandelbrot_legacy.c. It can be made work in pure mode, I think I tried that once. But you have to consider that it makes your "window" in which your game is rendered smaller, so it's squeezed a bit, so you have to enlarge your window by the same size.

You can see that this works in the Visual level editor by Alexey Rozhkov (=Shadow969), which should be available at AU Resources as it won the GS contest one or two years ago.


EDIT (I didn't see your new post): I don't know so much about WINAPI functions but according to the code I see, it looks like wParam tells you which button was clicked.
Posted By: Quad

Re: windows functions? - 12/04/09 18:48

yes
InsertMenu(hSubMenu,1,MF_BYPOSITION|MF_STRING,1,"Neu");
InsertMenu(hSubMenu,2,MF_BYPOSITION|MF_STRING,2,"Öffnen");

this numbers are passed as wparam, so you know which is which
Posted By: Espér

Re: windows functions? - 12/04/09 20:18

ah..ok...

what is this:
on_scanmessage = ScanMessage;


Do i need this 1:1 in my Project?
Posted By: Quad

Re: windows functions? - 12/04/09 21:26

on_scanmassage is the function that listens/catches messages that have been sent to lite-c window. you need to write this function yourself(which is ScanMessage in the script you posted) and process messages. ie WM_COMMAND is a message. when such messages sent on_scanmessage function is triggered. You check which message came in and act respectively.
Posted By: Espér

Re: windows functions? - 12/05/09 12:36

ok.. i wrote this code now:
Code:
//-------------------------------------------------------------------------------------------------
// • Einbinden der Scripts
//-------------------------------------------------------------------------------------------------
#include <acknex.h>
#include <default.c>
#include <windows.h>

//-------------------------------------------------------------------------------------------------
// • Einbinden der Pfade
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// • Funktionen
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);

function menucreate()
{
	long menuheader;
	long submenu1;
	long submenu12;
	
	HWND hwnd=hWnd;
	
	//	CreateMenu(); ist der Befehl dazu, der gibt ein Handle auf das neue Menü zurück
	menuheader = CreateMenu();
	submenu1 = CreateMenu();
	submenu12 = CreateMenu();
	
	//	InsertMenu(); ist der Befehl der Menüpunkte erstellt
	// InsertMenu(longpointer, Position, Flags, sublongpointer / id, "Anzeigestring");
	InsertMenu(submenu1, 1, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu12, "Neu");
	InsertMenu(submenu1, 2, MF_BYPOSITION|MF_STRING, 2, "Öffnen");
	InsertMenu(submenu1, 3, MF_BYPOSITION|MF_STRING, 3, "Beenden");
	
	InsertMenu(submenu12, 4, MF_BYPOSITION|MF_STRING, 4, "Karte");
	InsertMenu(submenu12, 5, MF_BYPOSITION|MF_STRING, 5, "Map");
	InsertMenu(submenu12, 6, MF_BYPOSITION|MF_STRING, 6, "Quest");
	
	InsertMenu(menuheader, 0, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu1, "Datei");
	
	
	SetMenu(hwnd,menuheader);
}

//-------------------------------------------------------------------------------------------------
// • Mainscripts
//-------------------------------------------------------------------------------------------------
function main()
{
	fps_max= 60;
	video_mode = 8;
	video_aspect = 1.777;
	level_load(NULL);
	wait(3);
	
	menucreate();
	on_scanmessage = ScanMessage;
}

//-------------------------------------------------------------------------------------------------
// • Longs
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (WM_COMMAND) {
		case message:
		switch (wParam) {
			case 2:
			printf("Es wurde auf 'Öffnen' geklickt");
			return(1);
			
			case 3:
			printf("Es wurde auf 'Beenden' geklickt");
			return(1);
			
			case 4:
			printf("Es wurde auf 'Neue Karte' geklickt");
			return(1);
			
			case 5:
			printf("Es wurde auf 'Neue Map' geklickt");
			return(1);
			
			case 6:
			printf("Es wurde auf 'Neue Quest' geklickt");
			return(1);

			
			default:
			break;
		}
		
		break;
		default:
		break;
	}
}



But now nothing reacts when the project is started.. i need to end the process via the task manager. What´s wrong?
Posted By: Quad

Re: windows functions? - 12/05/09 17:45

hey 2 problems,

1.
Code:
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (WM_COMMAND) {
		case message:


should be

switch (message) {
case WM_COMMAND:

because the variable here is the message, WM_COMMAND is only a #defined constant

2. you are only handling WM_COMMAND message, there are alot of other possible messages could be goind around, so you should return a value fot hem. make the last default return 0;

that's all i guess.
Posted By: Espér

Re: windows functions? - 12/05/09 17:52

IT WORKS

Great.. thanks Quadraxas.. my hero ^^
Posted By: Espér

Re: windows functions? - 12/08/09 16:01

ok...
got another windows question....

1.)
Is there a way to create a frame or border inside the A7 Window?

2.)
Any way to change the layer of the menü so i can show cursor or panels above it?

3.)
How to remove a menü/frame/border, if i don´t need it anymore?

4.)
How to call a homepage with the standard Browser? I tried:
Code:
exec("http://rmxpworld.de", NULL);


But nothing happened

thx for all help
Posted By: Nicholas

Re: windows functions? - 12/11/09 17:22

would you mind posting your new code that doesn't freeze as an example.
thanks
and to help out I don't think the new exec is actually implemented yet, but this one will work.
Code:
function open_url()

{
       exec("%PROG_DIR%\\internet explorer\\iexplore.exe","http://www.3dgamestudio.com");
}


Posted By: Quad

Re: windows functions? - 12/11/09 17:51

1)i dont get it what do you want exactly?

2)i am not sure but i guess you cant.

3)use according removal function, search on winapi docs.

4)ShellExecute(NULL, "open", "http://www.acknexturk.com", NULL, NULL, SW_SHOWNORMAL);

opens in default browser. dont forget to include windows.h
Posted By: Espér

Re: windows functions? - 12/11/09 18:18

thx Quadraxas..

1.) means:

Atm i need to design the GUI via Photoshop and bitmaps. Is there a way with the windows commands to create frames, scrollbars..etc...?
Posted By: Quad

Re: windows functions? - 12/11/09 18:48

use panels?
Posted By: Rei_Ayanami

Re: windows functions? - 12/11/09 18:51

he meant if he must use panels, or if he could use windows functions like in delphi wink
Posted By: flits

Re: windows functions? - 12/11/09 19:10

i am dont get it working very good but here is the thing you can do

headwindow = CreateWindowEx(NULL,"STATIC","",WS_VISIBLE | WS_POPUP,recta.right-200,40,200,60,hWnd,NULL,hInstance,NULL);

hwnd_coll[0] = CreateWindowEx(NULL,"STATIC","you text",WS_VISIBLE | WS_CHILD | WS_BORDER,10,color_offset_y - 25,150,20,headwindow,50,hInstance,"1");

for more info check this:
http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx

you can swicth the STATIC to BUTTON/COMBOBAOX/EDIT rest didnt test
but i cant get it to retreive changements in the windows
so you need GetWindowText for that
Posted By: Nicholas

Re: windows functions? - 12/12/09 02:03

can someone please post (or pm me) a working copy of the code, I'm not sure what Quadraxas meant by returning a 0 and my code keeps freezing and not able to close without ctrl+alt+del
please
Posted By: Espér

Re: windows functions? - 12/12/09 02:16

Code:
//-------------------------------------------------------------------------------------------------
// • Einbinden der Scripts
//-------------------------------------------------------------------------------------------------
#include <acknex.h>
#include <default.c>
#include <windows.h>

//-------------------------------------------------------------------------------------------------
// • Einbinden der Pfade
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// • Funktionen
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);

function menucreate()
{
	long menuheader;
	long submenu1;
	long submenu12;
	
	HWND hwnd=hWnd;
	
	//	CreateMenu(); ist der Befehl dazu, der gibt ein Handle auf das neue Menü zurück
	menuheader = CreateMenu();
	submenu1 = CreateMenu();
	submenu12 = CreateMenu();
	
	//	InsertMenu(); ist der Befehl der Menüpunkte erstellt
	// InsertMenu(longpointer, Position, Flags, sublongpointer / id, "Anzeigestring");
	InsertMenu(submenu1, 1, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu12, "Neu");
	InsertMenu(submenu1, 2, MF_BYPOSITION|MF_STRING, 2, "Öffnen");
	InsertMenu(submenu1, 3, MF_BYPOSITION|MF_STRING, 3, "Beenden");
	
	InsertMenu(submenu12, 4, MF_BYPOSITION|MF_STRING, 4, "Karte");
	InsertMenu(submenu12, 5, MF_BYPOSITION|MF_STRING, 5, "Map");
	InsertMenu(submenu12, 6, MF_BYPOSITION|MF_STRING, 6, "Quest");
	
	InsertMenu(menuheader, 0, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu1, "Datei");
	
	
	SetMenu(hwnd,menuheader);
}

//-------------------------------------------------------------------------------------------------
// • Mainscripts
//-------------------------------------------------------------------------------------------------
function main()
{
	fps_max= 60;
	video_mode = 8;
	video_aspect = 1.777;
	level_load(NULL);
	wait(3);
	
	menucreate();
	on_scanmessage = ScanMessage;
}

//-------------------------------------------------------------------------------------------------
// • Longs
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
		case WM_COMMAND:
		switch (wParam) {
			case 2:
			printf("Es wurde auf 'Öffnen' geklickt");
			return(1);
			
			case 3:
			printf("Es wurde auf 'Beenden' geklickt");
			return(1);
			
			case 4:
			printf("Es wurde auf 'Neue Karte' geklickt");
			return(1);
			
			case 5:
			printf("Es wurde auf 'Neue Map' geklickt");
			return(1);
			
			case 6:
			printf("Es wurde auf 'Neue Quest' geklickt");
			return(1);

			
			default:
			return(0);
			break;
		}
		
		default:
		break;
	}
}



Have fun..
Posted By: Nicholas

Re: windows functions? - 12/12/09 04:09

Great, thanks man, I did notice something though, not sure if that script works on your machine, but it kills mine like usual, but with some tweaking I got it to work.
1. switch (WM_COMMAND) {
case WM_COMMAND:
switch (wParam) {
//you have switch (message) this didn't work for me until I changed it back to WM_COMMAND
2. case 2:
printf("Es wurde auf 'Neue Map' geklickt");
return(1);
//I don't know why this wouldn't work, but case 2 always seems to be for mousing over the window bar or menu and freezes it.. all I did was change the InsertMenu line to not have 2, I also had to mix and match different numbers or the same numbers to make the window title stop being a button, see below for the sample and change my commented lines to see what I mean


Here is my updated code in case anyone else has the same problem
Code:
//-------------------------------------------------------------------------------------------------
// • Einbinden der Scripts
//-------------------------------------------------------------------------------------------------
#include <acknex.h>
#include <default.c>
#include <windows.h>

//-------------------------------------------------------------------------------------------------
// • Einbinden der Pfade
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// • Funktionen
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam);

function menucreate()
{
	long menuheader;
	long submenu1;
	long submenu12;
	
	HWND hwnd=hWnd;
	
	//	CreateMenu(); ist der Befehl dazu, der gibt ein Handle auf das neue Menü zurück
	menuheader = CreateMenu();
	submenu1 = CreateMenu();
	submenu12 = CreateMenu();
	
	//	InsertMenu(); ist der Befehl der Menüpunkte erstellt
	// InsertMenu(longpointer, Position, Flags, sublongpointer / id, "Anzeigestring");
	InsertMenu(submenu1, 1, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu12, "Neu");
	InsertMenu(submenu1, 3, MF_BYPOSITION|MF_STRING, 3, "Öffnen");
	InsertMenu(submenu1, 4, MF_BYPOSITION|MF_STRING, 4, "Beenden");
	
	InsertMenu(submenu12, 5, MF_BYPOSITION|MF_STRING, 8, "Karte");		// use different numbers if you have a problem
	InsertMenu(submenu12, 6, MF_BYPOSITION|MF_STRING, 6, "Map");		// or use the same if you have a problem, I had to use both methods here
	InsertMenu(submenu12, 7, MF_BYPOSITION|MF_STRING, 7, "Quest");
	
	InsertMenu(menuheader, 0, MF_BYPOSITION|MF_STRING|MF_POPUP, submenu1, "Datei");
	
	
	SetMenu(hwnd,menuheader);
}

//-------------------------------------------------------------------------------------------------
// • Mainscripts
//-------------------------------------------------------------------------------------------------
function main()
{
	fps_max= 60;
	video_mode = 8;
	video_aspect = 1.777;
	level_load(NULL);
	wait(3);
	
	menucreate();
	on_scanmessage = ScanMessage;
}

//-------------------------------------------------------------------------------------------------
// • Longs
//-------------------------------------------------------------------------------------------------
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (WM_COMMAND) {
		case WM_COMMAND:
		switch (wParam) {
			case 3:
			printf("Öffnen");
			return(1);
			
			case 4:
			printf("Beenden");
			return(1);
			
			case 8:
			printf("Es wurde auf 'Neue Karte' geklickt");
			return(1);
			
			case 6:
			printf("Es wurde auf 'Neue Map' geklickt");
			return(1);
			
			case 7:
			printf("Es wurde auf 'Neue Quest' geklickt");
			return(1);

			
			default:
			return(0);
			break;
		}
		default:
		break;
	}
}




I am using A7.8 on Windows 7 32 bit if you want to know

thanks for the help and if I find out how to add the scrollbars and stuff I'll let you know.
Posted By: Espér

Re: windows functions? - 01/01/10 03:07

hmm..

Another question for Windows code ( MSDN ):

Can someone tell me how to create a Windows Textinput ( textbox )?

I know i can use inkey(), but a support for cursor_movement, TAB using, ALT+NUM Commands..etc would be really useful for my message system.


Oh... and for all who need it.. here the function to remove the menü:
SetMenu(hwnd, NULL);
Posted By: WickWoody

Re: windows functions? - 01/01/10 09:24

I also have a problem like this. I want to show a message box, but C + + with the command as follows MessageBox does not happen. Do you need to add a custom header?
Posted By: DJBMASTER

Re: windows functions? - 01/01/10 10:37

Originally Posted By: WickWoody
I also have a problem like this. I want to show a message box, but C + + with the command as follows MessageBox does not happen. Do you need to add a custom header?


Make sure you add '#include <windows.h>' at the top of your script. Then you can just call it like normal...
Code:
MessageBox(NULL,"hi","hey",MB_OK);


Posted By: WickWoody

Re: windows functions? - 01/01/10 11:17

Oh, thanks.
Posted By: Espér

Re: windows functions? - 01/03/10 00:37

uhm.. is there someone who knows how to create a textbox for writing..etc?
Posted By: Espér

Re: windows functions? - 01/05/10 01:54

uhm.. still need a textbox..

or a wy to move the writing cursor via the cursor keys and using TAB funktion.

Example picture:


If someone knows how to create such a textbox.. plz shout it out..
Perhaps someone knows thenhow to set a string to the textbox entry ^^
Posted By: Espér

Re: windows functions? - 01/23/10 00:43

still need this...
Posted By: DJBMASTER

Re: windows functions? - 01/23/10 08:52

I've tried to add win32 controls to the engine and yet to be successful. I mean the control is created ok, because you can see it flickering in a couple of frames, but I guess DirectX is taking over so I don't see a way of adding controls to the engine.
Posted By: MMike

Re: windows functions? - 01/24/10 17:51

maybe you dont need the direct x here, you can disable that. camera reset, and changing rendering variables to nothing..
© 2024 lite-C Forums