/*
|
/*
|
* Copyright (c) 2001 Greg Haerr <greg@censoft.com>
|
* Copyright (c) 2001 Greg Haerr <greg@censoft.com>
|
*
|
*
|
* Demo program for StretchBlt
|
* Demo program for StretchBlt
|
*/
|
*/
|
#define MWINCLUDECOLORS
|
#define MWINCLUDECOLORS
|
#include "windows.h"
|
#include "windows.h"
|
#include "device.h"
|
#include "device.h"
|
|
|
extern MWIMAGEHDR image_penguin;
|
extern MWIMAGEHDR image_penguin;
|
|
|
PMWIMAGEHDR image = &image_penguin;
|
PMWIMAGEHDR image = &image_penguin;
|
|
|
#define APPCHILD "test2"
|
#define APPCHILD "test2"
|
|
|
/* forward decls*/
|
/* forward decls*/
|
LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
|
|
int
|
int
|
RegisterAppClass(void)
|
RegisterAppClass(void)
|
{
|
{
|
WNDCLASS wc;
|
WNDCLASS wc;
|
|
|
wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wc.lpfnWndProc = (WNDPROC)ChildWndProc;
|
wc.lpfnWndProc = (WNDPROC)ChildWndProc;
|
wc.cbClsExtra = 0;
|
wc.cbClsExtra = 0;
|
wc.cbWndExtra = 0;
|
wc.cbWndExtra = 0;
|
wc.hInstance = 0;
|
wc.hInstance = 0;
|
wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
|
wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
|
wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
|
wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
|
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
wc.lpszClassName = APPCHILD;
|
wc.lpszClassName = APPCHILD;
|
return RegisterClass( &wc);
|
return RegisterClass( &wc);
|
}
|
}
|
|
|
LRESULT CALLBACK
|
LRESULT CALLBACK
|
ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
{
|
{
|
HDC hdcMem;
|
HDC hdcMem;
|
HBITMAP hbmp, hbmpOrg;
|
HBITMAP hbmp, hbmpOrg;
|
RECT rc;
|
RECT rc;
|
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
|
|
switch(msg) {
|
switch(msg) {
|
case WM_PAINT:
|
case WM_PAINT:
|
BeginPaint(hwnd, &ps);
|
BeginPaint(hwnd, &ps);
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
|
|
/* redirect painting to offscreen dc*/
|
/* redirect painting to offscreen dc*/
|
hdcMem = CreateCompatibleDC(ps.hdc);
|
hdcMem = CreateCompatibleDC(ps.hdc);
|
hbmp = CreateCompatibleBitmap(hdcMem, image->width, image->height);
|
hbmp = CreateCompatibleBitmap(hdcMem, image->width, image->height);
|
hbmpOrg = SelectObject(hdcMem, hbmp);
|
hbmpOrg = SelectObject(hdcMem, hbmp);
|
|
|
/* draw onto offscreen dc*/
|
/* draw onto offscreen dc*/
|
DrawDIB(hdcMem, 0, 0, image);
|
DrawDIB(hdcMem, 0, 0, image);
|
|
|
/* stretch blit offscreen with physical screen*/
|
/* stretch blit offscreen with physical screen*/
|
StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
0, 0, image->width, image->height, MWROP_SRCCOPY);
|
0, 0, image->width, image->height, MWROP_SRCCOPY);
|
DeleteObject(SelectObject(hdcMem, hbmpOrg));
|
DeleteObject(SelectObject(hdcMem, hbmpOrg));
|
DeleteDC(hdcMem);
|
DeleteDC(hdcMem);
|
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
break;
|
break;
|
default:
|
default:
|
return DefWindowProc( hwnd, msg, wp, lp);
|
return DefWindowProc( hwnd, msg, wp, lp);
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
int WINAPI
|
int WINAPI
|
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
int nShowCmd)
|
int nShowCmd)
|
{
|
{
|
MSG msg;
|
MSG msg;
|
RECT rc;
|
RECT rc;
|
|
|
RegisterAppClass();
|
RegisterAppClass();
|
GetWindowRect(GetDesktopWindow(), &rc);
|
GetWindowRect(GetDesktopWindow(), &rc);
|
|
|
/* create penguin windows*/
|
/* create penguin windows*/
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
10, 10, 50, 50,
|
10, 10, 50, 50,
|
GetDesktopWindow(), (HMENU)1000, NULL, NULL);
|
GetDesktopWindow(), (HMENU)1000, NULL, NULL);
|
|
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
10, 70, 200, 200,
|
10, 70, 200, 200,
|
GetDesktopWindow(), (HMENU)1001, NULL, NULL);
|
GetDesktopWindow(), (HMENU)1001, NULL, NULL);
|
|
|
/* type ESC to quit...*/
|
/* type ESC to quit...*/
|
while( GetMessage(&msg, NULL, 0, 0)) {
|
while( GetMessage(&msg, NULL, 0, 0)) {
|
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|