
#include <windows.h>
#include <stdlib.h>
#include "resource.h"
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
static char szClassName[ ] = "CodeBlocksWindowsApp";
static char font[50] = "Verdana";
char vs[]="No princípio, criou Deus os céus e a terra. Gênesis 1:1";
static HFONT tamanhoDaFonte;
int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR lpszA, int nCS) {
HWND hwnd; /* This is the handle for our window */
MSG messages;
WNDCLASSEX wincl;
HBITMAP imagem;
HBRUSH hBrush;
imagem = LoadBitmap(hI, (char *) IMG);
hBrush = CreatePatternBrush(imagem);
DeleteObject(imagem);
wincl.hInstance = hI;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof(WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon(hI, (char *) IDI_ICON);
wincl.hIconSm = LoadIcon(hI, (char *) IDI_ICON);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = hBrush;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx(&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, szClassName, "DrawText", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 380,
HWND_DESKTOP, NULL, hI, NULL
);
/* Make the window visible on the screen */
ShowWindow(hwnd, nCS);
while(GetMessage(&messages, NULL, 0, 0)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
FreeConsole();
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wP, LPARAM lParam) {
HDC hdc;
RECT rect;
PAINTSTRUCT ps;
switch(msg) {
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
tamanhoDaFonte = CreateFontA(
28, 0, 0, 0, FW_EXTRABOLD,
1, 0, 0, 0, 0,
0, 0, 0, font
);
SelectObject(hdc, tamanhoDaFonte);
SetTextColor(hdc, RGB(0, 0, 162));
DrawText(hdc, vs, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc(hwnd, msg, wP, lParam);
}
return 0;
}
/********************Arquivo: resource.h********************/
#define IDI_ICON 1
#define IMG 2
/********************Arquivo: resource.rc********************/
#include "afxres.h"
#include "resource.h"
IDI_ICON ICON "project1.ico"
IMG BITMAP DISCARDABLE "img.bmp"
Comentários
Postar um comentário