Profi-Frage... Kann wohl nur Gernot beantworten?!

Previous topic - Next topic

Schranz0r

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:
Code (glbasic) Select
WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Jedoch sagt er mir das hInst nicht existiert :(
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello


Schranz0r

habs schon !

Code (glbasic) Select
hinst = (HINSTANCE)::GetWindowLong((HWND)GLBASIC_HWND(),GWL_HINSTANCE);

Wie geht den nochmal Threaden :D

EDIT:

Soweit sogut :D

Code (glbasic) Select
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 :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello


Schranz0r

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?

Code (glbasic) Select
// --------------------------------- //
// 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
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard