2 * Copyright (c) 2001 Greg Haerr <greg@censoft.com>
4 * Demo program for StretchBlt
6 #define MWINCLUDECOLORS
10 extern MWIMAGEHDR image_penguin;
12 PMWIMAGEHDR image = &image_penguin;
14 #define APPCHILD "test2"
17 LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
20 RegisterAppClass(void)
24 wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
25 wc.lpfnWndProc = (WNDPROC)ChildWndProc;
29 wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
30 wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
31 wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
32 wc.lpszMenuName = NULL;
33 wc.lpszClassName = APPCHILD;
34 return RegisterClass( &wc);
38 ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
41 HBITMAP hbmp, hbmpOrg;
47 BeginPaint(hwnd, &ps);
48 GetClientRect(hwnd, &rc);
50 /* redirect painting to offscreen dc*/
51 hdcMem = CreateCompatibleDC(ps.hdc);
52 hbmp = CreateCompatibleBitmap(hdcMem, image->width, image->height);
53 hbmpOrg = SelectObject(hdcMem, hbmp);
55 /* draw onto offscreen dc*/
56 DrawDIB(hdcMem, 0, 0, image);
58 /* stretch blit offscreen with physical screen*/
59 StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
60 0, 0, image->width, image->height, MWROP_SRCCOPY);
61 DeleteObject(SelectObject(hdcMem, hbmpOrg));
66 return DefWindowProc( hwnd, msg, wp, lp);
72 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
79 GetWindowRect(GetDesktopWindow(), &rc);
81 /* create penguin windows*/
82 CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
84 GetDesktopWindow(), (HMENU)1000, NULL, NULL);
86 CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
88 GetDesktopWindow(), (HMENU)1001, NULL, NULL);
90 /* type ESC to quit...*/
91 while( GetMessage(&msg, NULL, 0, 0)) {
92 TranslateMessage(&msg);
93 DispatchMessage(&msg);