
/**Ouvi a correção, não a rejeiteis e sede sábios. Provérbios 8:33*/
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hI,HINSTANCE hPI,PSTR szCmdLine,int iCmdShow) {
static TCHAR szAppName[] = TEXT("BitBlt");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hI;
wndclass.hIcon = LoadIcon(hI, IDI_ICON);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if(!RegisterClass(&wndclass)) {
MessageBox(NULL, TEXT("Error!"),szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(
szAppName,TEXT("GetSystemMetrics(SM_CYCAPTION);"),WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 300,
NULL, NULL, hI, NULL
);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage (&msg);
FreeConsole();
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
static int cxClient, cyClient, cxSc, cySc;
HDC hdcC, hdcWindow;
int x, y;
PAINTSTRUCT ps;
switch(msg) {
case WM_CREATE:
cxSc = GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(30);
cySc = GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(4);
return 0;
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdcC = BeginPaint(hwnd, &ps);
hdcWindow = GetWindowDC(hwnd);
for(y=0; y<cyClient; y+=cySc)
for(x=0; x<cxClient; x+=cxSc) {
BitBlt(hdcC, x, y, cxSc, cySc, hdcWindow, 0, 0,SRCCOPY);
}
ReleaseDC(hwnd, hdcWindow);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
/********************Arquivo: resource.h********************/
#define IDI_ICON 101
/********************Arquivo: resource.rc********************/
#include "afxres.h"
#include "resource.h"
MAIN ICON "icone.ico"
IDI_ICON ICON "icone.ico"
Comentários
Postar um comentário