
/**************** João 3:16 ********************/
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <tchar.h>
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
static char font[50] = "Verdana";
char vs[]="ES_PASSWORD";
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; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hI;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* 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, /* Extended possibilites for variation */
szClassName, /* Classname */
_T("ES_PASSWORD"), /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hI, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow(hwnd, nCS);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage(&messages, NULL, 0, 0)) {
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
FreeConsole();
}
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) {
HDC hdc;
PAINTSTRUCT ps;
switch(msg) {
case WM_CREATE:
CreateWindow(
TEXT("edit"), TEXT(""), WS_VISIBLE | WS_CHILD | ES_PASSWORD,
10, 60, 200, 20,
hwnd, NULL, NULL, NULL
);
CreateWindow(
TEXT("button"), TEXT("No Event"), WS_VISIBLE | WS_CHILD,
260, 60, 120, 20,
hwnd, NULL, NULL, NULL
);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
tamanhoDaFonte = CreateFontA(
58, 0, 0, 0, FW_EXTRABOLD,
1, 0, 0, 0, 0,
0, 0, 0, font
);
SelectObject(hdc, tamanhoDaFonte);
SetTextColor(hdc, RGB(255, 20, 0));
TextOut(hdc, 10, 180, vs, strlen(vs));
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default:
return DefWindowProc(hwnd, msg, wP, lP);
}
return 0;
}
Comentários
Postar um comentário