2 registered members (AndrewAMD, Ayumi),
838
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Programmer
|
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:
#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
Serious User
|
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
Programmer
|
Programmer
Joined: May 2007
Posts: 2,043
Germany
|
Ah, thanks DJBMASTER! After adding the hInstance and some other changes, I got a working example:
#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
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Wow, thanks Interesting - of course Where do I find more examples for such things(i mean winAPI) ? thanks in advance, rei
|
|
|
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
Programmer
|
Programmer
Joined: May 2007
Posts: 2,043
Germany
|
You mean Windows controls? Just like you add subwindows:
#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. (But basically you just have to use other window classes than "Button" )
|
|
|
|