#include <windows.h>
#include <stdio.h>
#define ASCII "VHF = Very High Frequency"
#define FEOF "UHF = Ultra High Frequency"
#define ANSI "SHF = Super High Frequency"
#define FABR "SHF - Faixa entre 3 GHz e 30 GHz"
#define WSCE 512
static char font[50] = "Arial Black";
static HFONT tamanho;
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
PAINTSTRUCT ps;
HDC ctx;
switch(Message) {
case WM_CREATE:
CreateWindow(
"edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD,
10, 10, 280, 20,
hwnd,NULL,NULL,NULL
);
CreateWindow(
"edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD,
10, 40, 280, 20,
hwnd,NULL,NULL,NULL
);
CreateWindow(
"edit", " ", WS_VISIBLE | WS_BORDER | WS_CHILD,
10, 70, 280, 20,
hwnd,NULL,NULL,NULL
);
CreateWindow(
"button","MessageBoxA", WS_VISIBLE | WS_BORDER | WS_CHILD,
10, 100, 280, 20,
hwnd, (HMENU) 1,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) {
MessageBoxA(NULL, "CreateFont", "MessageBoxA", MB_OK);
}
return 0;
case WM_PAINT:
static char asci[100] = ASCII;
static char feof[300] = FEOF;
static char ansi[300] = ANSI;
static char fabr[300] = FABR;
ctx = BeginPaint(hwnd, &ps);
SelectObject(ctx, tamanho);
SetTextColor(ctx, RGB(120, 0, 136));
TextOut(ctx, 10, 140, asci, strlen(asci));
TextOut(ctx, 10, 180, feof, strlen(feof));
TextOut(ctx, 10, 220, ansi, strlen(ansi));
TextOut(ctx, 10, 260, fabr, strlen(fabr));
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY: {
PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCS) {
WNDCLASSEX wc; /* A properties struct of our window */
HWND hwnd;
MSG msg;
memset(&wc,0,sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_3DLIGHT+1);
wc.lpszClassName = "WindowClass";
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WSCE,"WindowClass","A função CreateFont",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 400,
NULL,NULL,hInstance,NULL
);
if(hwnd == NULL) {
MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
while(GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg); /* Translate key codes to chars if present */
DispatchMessage(&msg); /* Send it to WndProc */
}
return msg.wParam;
}
Comentários
Postar um comentário