ctx = BeginPaint(hwnd, &ps); SelectObject(ctx, tamanho);

ctx = BeginPaint(hwnd, &ps); SelectObject(ctx, tamanho);
#include <windows.h> #include <stdio.h> #define WSCE 512 static char font[50] = "Arial Black"; static HFONT tamanho; static HWND n1, n2, n3; int rec() { static int i = 0; return (i++); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC ctx; static char CON[200]; FILE *fp; fp = fopen("arquivo.txt", "r"); fgets(CON, 126, fp); switch(msg) { case WM_CREATE: n1 = CreateWindow( "edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD, 10, 10, 280, 20, hwnd,NULL,NULL,NULL ); n2 = CreateWindow( "edit", " ",WS_VISIBLE|WS_BORDER|WS_CHILD, 10, 40, 280, 20, hwnd,NULL,NULL,NULL ); n3 = CreateWindow( "edit", " ", WS_VISIBLE | WS_BORDER | WS_CHILD, 10, 70, 280, 20, hwnd,NULL,NULL,NULL ); CreateWindow( "button","Teste", 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) { char conteudo[100]; itoa(GetSysColor(6), conteudo, 10); MessageBoxA(NULL, conteudo, "Preencher Lacunas", MB_OK); SetWindowText(n1, "CreateFont"); SetWindowText(n2, "CreateFont"); SetWindowText(n3, "CreateFont"); } return 0; case WM_PAINT: ctx = BeginPaint(hwnd, &ps); SelectObject(ctx, tamanho); SetTextColor(ctx, RGB(255, 255, 255)); SetBkColor(ctx, RGB(0, 94, 0)); TextOut(ctx, 10, 180, CON, strlen(CON)); fclose(fp); 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 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 = hI; 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, 910, 400, NULL, NULL, hI, 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