003
26.03.2005, 20:00 Uhr
~radix
Gast
|
Danke ich werds mir mal anschauen....
Hab mal n Prob mit der WinGDI:
C++: |
#define STRICT #define CName "My Application" #include <windows.h>
const int WindowXSize = 640; const int WindowYSize = 480;
HWND hwnd;
inline int MyLoop(); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wc;
wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = CName; wc.lpszMenuName = NULL; wc.style = CS_VREDRAW|CS_HREDRAW;
RegisterClass(&wc); hwnd = CreateWindow(CName, CName, WS_POPUP|WS_SYSMENU, 100, 100, WindowXSize, WindowYSize, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg;
while ( msg.message != WM_QUIT ) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else MyLoop(); }
return msg.wParam; }
////////////////////////// //////////////////////////
HDC hdc; HDC hdc2; HBITMAP bmp;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch(msg) { case WM_CREATE: hdc = GetDC(hwnd); hdc2 = CreateCompatibleDC(hdc); bmp = CreateCompatibleBitmap(hdc, WindowXSize, WindowYSize); SelectObject(hdc2, bmp); return 0;
case WM_PAINT: BitBlt(hdc, 0, 0, WindowXSize, WindowYSize, hdc2, 0, 0, SRCCOPY);
return 0;
case WM_DESTROY: DeleteObject(bmp); ReleaseDC(hwnd, hdc2); ReleaseDC(hwnd, hdc);
PostQuitMessage(0);
return 0;
case WM_KEYDOWN: if (wp == VK_ESCAPE) SendMessage(hwnd, WM_DESTROY, 0, 0); return 0; } return DefWindowProc(hwnd, msg, wp, lp); }
inline int MyLoop() { TextOut(hdc2, 10,10,"H", 1); InvalidateRect(hwnd, NULL, FALSE); return 0; }
|
Soviel zum Code:
Soll n Double Buffering test darstellen. Nur es funzt nich, irgenwie wird kein "H" angezeit... Wenn ich aber das TextOut(hdc2,...) in die WM_PAINT rein packe, dann gehts. Ich wollt aber unbedingt in der MyLoop() auf den BackBuffer zeichnen.
Hilfe und sonstige Verbesserungsvorschläge zum Code herzlich willkommen
MfG radix |