69,371
社区成员
发帖
与我相关
我的任务
分享
#define GUI
//*
#define UNICODE
#define _UNICODE
//*/
#include <Windows.h>
#include <tchar.h>
#include <stdio.h>
#pragma comment(lib, "gdi32")
#pragma comment(lib, "user32")
#pragma comment(linker, "/subsystem:windows")
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("HelloWin");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
RtlZeroMemory(&wndclass, sizeof(wndclass));
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, TEXT("#32512"));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if (!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("This program requires Windows NT series!"), szAppName, MB_ICONERROR);
return -1;
}
hwnd = CreateWindowEx(WS_EX_APPWINDOW, // A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.
szAppName, // window class name
TEXT("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
820,//CW_USEDEFAULT, // initial x size
620,//CW_USEDEFAULT, // initial y size
NULL,
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
{
BOOL bRet;
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
MessageBox(NULL, TEXT("GetMessage Error."), TEXT("Message"), MB_ICONERROR);
return -1;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
HFONT hFont;
static TCHAR szString [] = TEXT(" Rotation");
static int cxClient, cyClient;
switch (message)
{
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
hFont = CreateFont(60, //字体的高度
30, //字体的宽度
300, //字体显示的角度
0, //字体的角度
FW_NORMAL, //字体的磅数
TRUE, //斜体字体
TRUE, //带下划线的字体
TRUE, //带删除线的字体
CHINESEBIG5_CHARSET, //所需的字符集
OUT_CHARACTER_PRECIS, //输出的精度
CLIP_CHARACTER_PRECIS, //裁减的精度
DEFAULT_QUALITY, //逻辑字体与输出设备的实际字体之间的精度
FF_MODERN, //字体间距和字体集
_T("Times New Roman") //字体名称
);
SelectObject(hdc, hFont);
TextOut(hdc, cxClient / 2, cyClient / 2, szString, lstrlen(szString));
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}