大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
代码如下:
#include<windows.h>
#include<stdlib.h>
#include<string.h>
long WINAPI WndProc
(
HWND hWnd,
UINT iMessage,
UINT wParam,
LONG lParam
);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow);
HWND hWndMain;
int WINAPI WinMain //主函数
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
MSG Message;
if (!InitWindowsClass(hInstance)) return FALSE;
if (!InitWindows(hInstance, nCmdShow)) return FALSE;
while (GetMessage(&Message, 0, 0, 0)) //消息循环
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
long WINAPI WndProc(HWND hWnd, UINT iMessage,
UINT wParam, LONG lParam) {
HDC hDC; //定义指向设备的句柄
HBRUSH hBrush; //定义指向画刷的句柄
HPEN hPen; //定义指向画笔的句柄
PAINTSTRUCT PtStr;//定义指向包含绘图信息的结构体变量
switch (iMessage) //处理消息
{
case WM_PAINT: //处理绘图消息
hDC = BeginPaint(hWnd, &PtStr);
SetMapMode(hDC, MM_ANISOTROPIC); //设置映像模式
hPen = (HPEN)GetStockObject(BLACK_PEN); //黑色画笔
hBrush = (HBRUSH)GetStockObject(DKGRAY_BRUSH); //画刷
SelectObject(hDC, hBrush); //选择画刷
SelectObject(hDC, hPen); //选择画笔
RoundRect(hDC, 50, 120, 100, 200, 15, 15); //绘制圆角矩形
hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH); //采用亮灰色画刷
SelectObject(hDC, hBrush); //选择画刷
Ellipse(hDC, 150, 50, 200, 150); //绘制椭圆
hBrush = (HBRUSH)GetStockObject(HOLLOW_BRUSH); //虚画刷
SelectObject(hDC, hBrush); //选择画刷
Pie(hDC, 250, 50, 300, 100, 250, 50, 300, 50); //绘制饼形
EndPaint(hWnd, &PtStr); //结束绘图
return 0;
case WM_DESTROY: //结束应用程序
PostQuitMessage(0); return 0;
default: //其他消息处理程序
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
}
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow)//初始化窗口
{
HWND hWnd;
hWnd = CreateWindow("WinFill", //生成窗口
"填充示例程序",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd) return FALSE;
hWndMain = hWnd;
ShowWindow(hWnd, nCmdShow); //显示窗口
UpdateWindow(hWnd);
return TRUE;
}
BOOL InitWindowsClass(HINSTANCE hInstance) //定义窗口类
{
WNDCLASS WndClass;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, "END");
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = "WinFill";
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
return RegisterClass(&WndClass);
WndClass.hIcon = LoadIcon(NULL, "END");
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = "WinFill";
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
return RegisterClass(&WndClass);
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/170966.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...