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
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
#define WINDOW_CLASS_NAME "Test 1" #define WIN32_LEAN_AND_MEAN #define KEYDOWN(vk_code) ((GetAsyncKeyState((vk_code)&0x8000)?1:0) #define KEYUP(vk_code) ((GetAsyncKeyState((vk_code)&0x8000)?0:1) #include <windows.h> int Width = 800; int Height = 600; void Start(void); void Main(void); void Exit(void); HWND main_window_handle = 0; HINSTANCE hinstance_app = 0; LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch(msg) { case WM_CREATE: { return(0); } break; case WM_PAINT: { hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); return(0); } break; case WM_DESTROY: { PostQuitMessage(0); return(0); } break; default: break; } return (DefWindowProc(hwnd, msg, wparam, lparam)); } int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; HWND hwnd; MSG msg; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(0, IDI_APPLICATION); winclass.hCursor = LoadCursor(0, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = 0; winclass.lpszClassName = "Engine 1"; winclass.hIconSm = LoadIcon(0, IDI_APPLICATION); hinstance_app = hinstance; if(!RegisterClassEx(&winclass)) { return(0); } if(!(hwnd = CreateWindowEx(0, WINDOW_CLASS_NAME, "Test 1", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, Width, Height, 0, 0, hinstance, 0))) { return(0); main_window_handle = hwnd; Start(); while(TRUE) { if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } Main(); } Exit(); return(msg.wParam); } } void Start(void) { } void Main(void) { if(KEYDOWN(VK_ESCAPE)) { SendMessage(main_window_handle, WM_CLOSE, 0, 0); } } void Exit(void) { } |
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 86 87 88 89 90 91 92 93 94 95 96 |
#define WINDOW_CLASS_NAME "Test 1" #define WIN32_LEAN_AND_MEAN #include <windows.h> #include "functions.h" int Width = 800; int Height = 600; HWND main_window_handle = 0; HINSTANCE hinstance_app = 0; LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch(msg) { case WM_CREATE: { return(0); } break; case WM_PAINT: { hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); return(0); } break; case WM_DESTROY: { PostQuitMessage(0); return(0); } break; default: break; } return (DefWindowProc(hwnd, msg, wparam, lparam)); } int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; HWND hwnd; MSG msg; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(0, IDI_APPLICATION); winclass.hCursor = LoadCursor(0, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = 0; winclass.lpszClassName = "Test 1"; winclass.hIconSm = LoadIcon(0, IDI_APPLICATION); hinstance_app = hinstance; if(!RegisterClassEx(&winclass)) { return(0); } if(!(hwnd = CreateWindowEx(0, WINDOW_CLASS_NAME, "Test 1", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, Width, Height, 0, 0, hinstance, 0))) { return(0); main_window_handle = hwnd; while(TRUE) { if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } } return(msg.wParam); } } |
Anonymous
unregistriert
Anonymous
unregistriert
Anonymous
unregistriert
Anonymous
unregistriert
Werbeanzeige