Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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, Ayumi), 877 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: using Windows ComboBox??? [Re: flits] #317762
04/02/10 12:48
04/02/10 12:48
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
@flits: Your example seems to be supposed to just add a menu to the engine window (but st_mode is undefined), but we need a script that creates a subwindow.

Here's my try:
Code:
#include <acknex.h>
#include <windows.h>
#include <default.c>





#define LPWSTR char*
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCE MAKEINTRESOURCEW
#define IDI_WINLOGO MAKEINTRESOURCE(32517)


LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

HWND hwnd1;
STRING* class_name = "YourWindowClass";


void main ()
{
	
	wait(4);
	
	WNDCLASS wc;
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = 0; // You need to find a way to get the Instance!
	wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = _chr(class_name);
	RegisterClass (&wc);
	
	hwnd1 = CreateWindowEx
	(
	0,
	_chr(class_name),
	_chr("Your Subwindow"),
	(long)(WS_OVERLAPPEDWINDOW | WS_POPUP),
	200, 200, 200, 200,
	(long)hWnd,
	0,
	0, // You need to find a way to get the Instance!
	0
	);

	ShowWindow   (hwnd1, SW_SHOWNORMAL);
	UpdateWindow (hwnd1);
	
	
	while(1) wait(1);
	
	MSG msg;
	while (GetMessage (&msg, NULL, 0, 0))
	{
		TranslateMessage (&msg);
		DispatchMessage (&msg);
		wait(1); // I'm not sure if this is neccessary or helpful
	}
}






LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		
		case WM_LBUTTONDOWN:
		MessageBox(0,"Left mouse button pressed inside your subwindow!","!!!",MB_OK);
		return 0; 
		
		default:
		wait(1);
		break;
	}

	return DefWindowProc (hwnd, message, wParam, lParam);
}



So far it doesn't work, it just stops the engine window from responding. This might be because you can't get the instance of the program. So far, I just used 0 as instance, lol. Maybe you can use the SDK to make the engine send you the instance through the command line?

Re: using Windows ComboBox??? [Re: Lukas] #317768
04/02/10 13:28
04/02/10 13:28
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
@Lukas, the HINSTANCE is exposed through the 'hInstance' variable.

Last edited by DJBMASTER; 04/02/10 13:28.
Re: using Windows ComboBox??? [Re: DJBMASTER] #317773
04/02/10 14:09
04/02/10 14:09
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ah, thanks DJBMASTER!

After adding the hInstance and some other changes, I got a working example:

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





#define LPWSTR char*
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCE MAKEINTRESOURCEW
#define IDI_WINLOGO MAKEINTRESOURCE(32517)


LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

HWND hwnd1;

char cname[4] = {0x62, 0x6C, 0x61, 0}; // "bla"


void main ()
{
	
	wait(1);
	
	WNDCLASS wc;
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = cname;
	RegisterClass (&wc);
	
	hwnd1 = CreateWindowEx
	(
	0,
	cname,
	"Your Subwindow",
	WS_OVERLAPPEDWINDOW | WS_POPUP,
	400, 400, 400, 400,
	hWnd,
	0,
	hInstance,
	0
	);

	ShowWindow   (hwnd1, SW_SHOWNORMAL);
	
	MSG msg;
	while (GetMessage (&msg, NULL, 0, 0))
	{
		TranslateMessage (&msg);
		DispatchMessage (&msg);
		wait(1);
	}
}






LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		
		case WM_LBUTTONDOWN:
		MessageBox(0,"Left mouse button pressed inside your subwindow!","!!!",MB_OK);
		return 0; 
	}

	return DefWindowProc (hwnd, message, wParam, lParam);
}



Re: using Windows ComboBox??? [Re: Lukas] #317778
04/02/10 14:32
04/02/10 14:32
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Wow, thanks laugh

Interesting - of course laugh


Where do I find more examples for such things(i mean winAPI) ?

thanks in advance,
rei

Re: using Windows ComboBox??? [Re: Rei_Ayanami] #317782
04/02/10 14:44
04/02/10 14:44
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
msdn,google, etc


3333333333
Re: using Windows ComboBox??? [Re: Quad] #317820
04/02/10 19:12
04/02/10 19:12
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
how can i add panels, controls, MOUSE..etc to the subwindow???


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: using Windows ComboBox??? [Re: Espér] #317829
04/02/10 22:01
04/02/10 22:01
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
You mean Windows controls? Just like you add subwindows:

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





#define LPWSTR char*
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCE MAKEINTRESOURCEW
#define IDI_WINLOGO MAKEINTRESOURCE(32517)

#define ID_yourbutton 1


LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

HWND hwnd1;
HWND hwnd_button;

char cname[4] = {0x62, 0x6C, 0x61, 0}; // "bla"


void main ()
{
	
	wait(1);
	mouse_pointer = 2;
	
	WNDCLASS wc;
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = cname;
	RegisterClass (&wc);
	
	hwnd1 = CreateWindowEx
	(
	0,
	cname,
	"Your Subwindow",
	WS_OVERLAPPEDWINDOW | WS_POPUP,
	400, 400, 400, 400,
	hWnd,
	0,
	hInstance,
	0
	);
	
	
	
	hwnd_button = CreateWindowEx (0, "Button", "Klick me!",
	WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
	10, 10, 96, 24, hwnd1, (HMENU)ID_yourbutton,
	(HINSTANCE) GetWindowLong (hwnd1, GWL_HINSTANCE), NULL);
	
	

	ShowWindow   (hwnd1, SW_SHOWNORMAL);
	
	
	
	MSG msg;
	while (GetMessage (&msg, NULL, 0, 0))
	{
		TranslateMessage (&msg);
		DispatchMessage (&msg);
		wait(1);
	}
}






LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		
		case WM_LBUTTONDOWN:
		MessageBox(hwnd1,"Left mouse button pressed inside your subwindow!","!!!",MB_OK);
		return 0;
		
		
		case WM_COMMAND:
		if(LOWORD(wParam) == ID_yourbutton)
		{
			MessageBox(hwnd1,"You pressed the button!","OMFG!!!",MB_OK);
		}
		/*default:
		wait(1);
		break;*/
	}

	return DefWindowProc (hwnd, message, wParam, lParam);
}



To find out how to add other objects, it might be healthly to RTFMSDN. wink (But basically you just have to use other window classes than "Button" wink )

Re: using Windows ComboBox??? [Re: Lukas] #317833
04/02/10 22:50
04/02/10 22:50
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
no..i mean controls.. keyboard.. Panel-buttons...


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: using Windows ComboBox??? [Re: Espér] #317834
04/02/10 22:59
04/02/10 22:59
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
You can't place Gamestudio controls into this subwindow.
I thought this whole thread was about how to add Windows elements like ComboBoxes to a Gamestudio application. It is not possible in the main window because DirectX would render above it, so I showed you how to do it by adding a subwindow. The whole point of adding this subwindow was creating an area in which the engine doesn't render, so you can create Windows elements into it. This means, in the subwindow, you can only create Windows controls, while in the main window you can only create engine controls.

Re: using Windows ComboBox??? [Re: Lukas] #317836
04/02/10 23:17
04/02/10 23:17
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. and how to use the basic windows functions??? ( never used .net framework or visual studio..or anything else )...


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 2 of 3 1 2 3

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