#include <windows.h>
#include <stdio.h>
#define WSCE 512
static char font[50] = "Arial Black";
static HFONT tamanho;
static HWND n1, n2, n3;
char C[]="Vaidade são, obra de enganos; no tempo da sua visitação, virão a perecer.";
char P[] = "Jeremias 10:15";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
PAINTSTRUCT ps;
HDC ctx;
switch(msg) {
case WM_CREATE:
CreateWindow(
"button","Teste", WS_VISIBLE | WS_BORDER | WS_CHILD,
10, 40, 120, 20,
hwnd, (HMENU) 1,NULL,NULL
);
n1 = CreateWindow(
"edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD,
160, 40, 120, 20,
hwnd,NULL,NULL,NULL
);
n2 = CreateWindow(
"edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD,
310, 40, 120, 20,
hwnd,NULL,NULL,NULL
);
n3 = CreateWindow(
"edit", " ", WS_VISIBLE | WS_BORDER | WS_CHILD,
460, 40, 120, 20,
hwnd,NULL,NULL,NULL
);
return 0;
case WM_COMMAND:
tamanho = CreateFont(
35, 0, 0, 0, 1,
0, 0, 0, 0, 0,
0, 0, 0, font
);
if(LOWORD(wParam)==1) {
SetWindowText(n1, P);
SetWindowText(n2, P);
SetWindowText(n3, P);
}
return 0;
case WM_PAINT:
ctx = BeginPaint(hwnd, &ps);
SelectObject(ctx, tamanho);
SetTextColor(ctx, RGB(255, 255, 255));
SetBkColor(ctx, RGB(0, 74, 55));
TextOut(ctx, 10, 180, C, strlen(C));
TextOut(ctx, 10, 240, P, strlen(P));
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY: {
PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR lpCL, int nCS) {
WNDCLASSEX wc;
HWND hwnd;
MSG msg;
memset(&wc,0,sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hI;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetSysColorBrush(18);
wc.lpszClassName = "WindowClass";
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) {
MessageBox(NULL,"Error!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WSCE,"WindowClass","SetWindowText(n1, P);",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 1070, 400,
NULL, NULL, hI, NULL
);
if(hwnd == NULL) {
MessageBox(NULL, "Error!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
while(GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
Comentários
Postar um comentário