Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
killmichnich
unregistriert
Zitat von »"killmichnich"«
Nur dazu muss ich ja iwie die int WINAPI WinMain() und LRESULT CALLBACK WndProc() in meine dll reinpacken können.
killmichnich
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
class DLL_EXPORT CWindow { public: CWindow(); ~CWindow(); bool Create(int xpos, int ypos, int width, int height, string fenstertitel); void Move(int xpos, int ypos, int width, int height); protected: HWND C_Hwnd; LRESULT CALLBACK C_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); char* C_ClassName; }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
#include "window.h" CWindow::CWindow() { C_ClassName = "Fenster-Klasse"; } CWindow::~CWindow() { } LRESULT CALLBACK CWindow::C_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); break; case WM_KEYDOWN: { switch(wParam) { case VK_ESCAPE: PostQuitMessage(0); break; default: break; } break; } default: return DefWindowProc (hwnd, message, wParam, lParam); break; } return 0; } bool CWindow::Create(int xpos, int ypos, int width, int height, string fenstertitel) { WNDCLASSEX wincl; wincl.hInstance = GetModuleHandle(NULL); wincl.lpszClassName = C_ClassName; wincl.lpfnWndProc = C_WndProc; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default colour as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; if(!RegisterClassEx (&wincl)) { MessageBox(NULL, "Fehler beim registrieren der Fensterklasse", "Fehler", MB_OK); return false; } C_Hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ C_ClassName, /* Classname */ fenstertitel.c_str(), /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ xpos, /* Windows decides the position */ ypos, /* where the window ends up on the screen */ width, /* The programs width */ height, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ GetModuleHandle(NULL), /* Program Instance handler */ NULL /* No Window Creation data */ ); if(C_Hwnd==NULL) { MessageBox(NULL, "Fehler beim erstellen des Fensters", "Fehler", MB_OK); return false; } ShowWindow(C_Hwnd, SW_SHOW); return true; } |
killmichnich
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
class DLL_EXPORT CWindow { public: CWindow(); ~CWindow(); bool Create(int xpos, int ypos, int width, int height, string fenstertitel); void Move(int xpos, int ypos, int width, int height); protected: HWND C_Hwnd; // ! static LRESULT CALLBACK C_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); char* C_ClassName; }; |
killmichnich
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
#include <windows.h> #include "window.h" using namespace std; CWindow Window; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { return 0; } |
Werbeanzeige