Hi Gernot!
Kann man das HINSTANCE von WinMain verwenden ?
Spiel grad ein wenig mit der windows.h rum...
Hab im Temp-Ordner zwar das gefunden:
WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Jedoch sagt er mir das hInst nicht existiert :(
GetModuleHandle(NULL);
habs schon !
hinst = (HINSTANCE)::GetWindowLong((HWND)GLBASIC_HWND(),GWL_HINSTANCE);
Wie geht den nochmal Threaden :D
EDIT:
Soweit sogut :D
INLINE
}
#define HINSTANCE W32HINSTANCE
#define HINSTANCE__ W32HINSTANCE__
#undef LPSTR
#undef DECLARE_HANDLE
#undef LPCTSTR
#undef DWORD
#undef LPWSTR
#undef LPCWSTR
#define HWND W32HWND
#define HWND__ W32HWND__
#define HANDLE W32HANDLE
#undef MAX_PATH
#undef TCHAR
#define WIN32_LEAN_AND_MEAN
#define WinMain WinMain2
#define GLBhInst hInst
#include <windows.h>
namespace __GLBASIC__ {
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 0, 0, TEXT("Hello World!"), 12);
EndPaint(hWnd, &ps);
return 0;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
struct TWindow{
DGStr szAppName;
HWND hWnd;
HINSTANCE hinst;
MSG msg;
WNDCLASSEX wndclassex;
};
DGArray<TWindow> TWin;
ENDINLINE
FUNCTION API_CreateWindow: Caption$
INLINE
TWindow Win;
//HINSTANCE hinst;
Win.szAppName = Caption_Str;
Win.hinst = (HINSTANCE)::GetWindowLong((HWND)GLBASIC_HWND(),GWL_HINSTANCE);
Win.wndclassex.cbSize = sizeof (WNDCLASSEX);
Win.wndclassex.style = CS_HREDRAW | CS_VREDRAW;
Win.wndclassex.lpfnWndProc = &WndProc;
Win.wndclassex.cbClsExtra = 0;
Win.wndclassex.cbWndExtra = 0;
Win.wndclassex.hInstance = Win.hinst;
Win.wndclassex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
Win.wndclassex.hCursor = LoadCursor(NULL, IDC_ARROW);
Win.wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
Win.wndclassex.lpszMenuName = NULL;
Win.wndclassex.lpszClassName = Win.szAppName.c_str();
Win.wndclassex.hIconSm = Win.wndclassex.hIcon;
if (!::RegisterClassEx(&Win.wndclassex)){
::MessageBox(NULL, TEXT("RegisterClassEx fehlgeschlagen!"),
Caption_Str.c_str(), MB_OK | MB_ICONERROR);
return -1;
}
Win.hWnd = ::CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil
Win.szAppName.c_str(), // Name der Fensterklasse
TEXT(Caption_Str.c_str()), // Fenstertitel
WS_OVERLAPPEDWINDOW, // Fensterstil
CW_USEDEFAULT, // X-Position des Fensters
CW_USEDEFAULT, // Y-Position des Fensters
CW_USEDEFAULT, // Fensterbreite
CW_USEDEFAULT, // Fensterh?he
NULL, // ?bergeordnetes Fenster
NULL, // Men?
Win.hinst, // Programm-Kopiez?hler (Programm-ID)
NULL); // zus?tzliche Parameter
::ShowWindow ( Win.hWnd, SW_SHOW);
DIMPUSH(TWin,Win);
return LEN(TWin())-1;
ENDINLINE
ENDFUNCTION
FUNCTION API_UpdateWindow: win_handle
INLINE
::UpdateWindow(TWin(win_handle).hWnd);
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
ENDINLINE
ENDFUNCTION
Nat?rlich ist die Updatefunktion totaler quatsch ist mir schon klar :)
http://www.glbasic.com/forum/index.php?topic=964.0 (http://www.glbasic.com/forum/index.php?topic=964.0).
Wobei das auch besser geht. Ich such mal...
PeekMessage w?r besser oder :)
aber da steig ich net ganz so durch muss ich mir nochmal genauer angucken.
Fenster erstellen und anzeigen (very Basic) geht ja schonmal :D
Siehe vorherigen Post.
Aktuell:
Fenster k?nnen erstellt werden und auch bewegt usw...
Nur das problem mit den Events...
Wie l?se ich das am besten Gernot?
// --------------------------------- //
// Project: Windows Header
// Start: Wednesday, April 15, 2009
// IDE Version: 6.217
INLINE
}
#define HINSTANCE W32HINSTANCE
#define HINSTANCE__ W32HINSTANCE__
#undef LPSTR
#undef DECLARE_HANDLE
#undef LPCTSTR
#undef DWORD
#undef LPWSTR
#undef LPCWSTR
#define HWND W32HWND
#define HWND__ W32HWND__
#define HANDLE W32HANDLE
#undef MAX_PATH
#undef TCHAR
#define WIN32_LEAN_AND_MEAN
#define WinMain WinMain2
#define GLBhInst hInst
#include <windows.h>
namespace __GLBASIC__ {
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 0, 0, TEXT("Hello World!"), 12);
EndPaint(hWnd, &ps);
return 0;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
struct TWindow{
DGStr szAppName;
HWND hWnd;
HINSTANCE hinst;
MSG msg;
WNDCLASSEX wndclassex;
};
DGArray<TWindow> TWin;
ENDINLINE
FUNCTION API_CreateWindow: Caption$
INLINE
TWindow Win;
//HINSTANCE hinst;
Win.szAppName = Caption_Str;
Win.hinst = (HINSTANCE)::GetWindowLong((HWND)GLBASIC_HWND(),GWL_HINSTANCE);
Win.wndclassex.cbSize = sizeof (WNDCLASSEX);
Win.wndclassex.style = CS_HREDRAW | CS_VREDRAW;
Win.wndclassex.lpfnWndProc = &WndProc;
Win.wndclassex.cbClsExtra = 0;
Win.wndclassex.cbWndExtra = 0;
Win.wndclassex.hInstance = Win.hinst;
Win.wndclassex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
Win.wndclassex.hCursor = LoadCursor(NULL, IDC_ARROW);
Win.wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
Win.wndclassex.lpszMenuName = NULL;
Win.wndclassex.lpszClassName = Win.szAppName.c_str();
Win.wndclassex.hIconSm = Win.wndclassex.hIcon;
if (!::RegisterClassEx(&Win.wndclassex)){
::MessageBox(NULL, TEXT("RegisterClassEx fehlgeschlagen!"),
Caption_Str.c_str(), MB_OK | MB_ICONERROR);
return -1;
}
Win.hWnd = ::CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil
Win.szAppName.c_str(), // Name der Fensterklasse
TEXT(Caption_Str.c_str()), // Fenstertitel
WS_OVERLAPPEDWINDOW, // Fensterstil
CW_USEDEFAULT, // X-Position des Fensters
CW_USEDEFAULT, // Y-Position des Fensters
CW_USEDEFAULT, // Fensterbreite
CW_USEDEFAULT, // Fensterh?he
NULL, // ?bergeordnetes Fenster
NULL, // Men?
Win.hinst, // Programm-Kopiez?hler (Programm-ID)
NULL); // zus?tzliche Parameter
::ShowWindow ( Win.hWnd, SW_SHOW);
DIMPUSH(TWin,Win);
return LEN(TWin())-1;
ENDINLINE
ENDFUNCTION
FUNCTION API_UpdateWindow: win_handle
INLINE
::UpdateWindow(TWin(win_handle).hWnd);
MSG msg;
if (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
ENDINLINE
ENDFUNCTION