展开全部
可以直接调用CodeBlocks,MinGW,Win SDK
2. CodeBlocks可以创建 Win32 GUI Project
3. resource.h
#include <windows.h>
// ID of Main Dialog
#define DLG_MAIN 101
4. resource.rc
#include "resource.h"
DLG_MAIN DIALOGEX 6, 5, 194, 106
CAPTION "Code::Blocks Template Dialog App"
FONT 8, "Tahoma"
5. main.cpp
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include<stdlib.h>
#include<string.h>
#include "resource.h"
HINSTANCE hInst;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hDC; //定义指向设备描述表的句柄
HBRUSH hBrush; //定义指向画刷的句柄
HPEN hPen; //定义指向画笔的句柄
PAINTSTRUCT PtStr; //定义指向包含绘图信息的结构体变量
switch(uMsg)
{
case WM_PAINT:
hDC=BeginPaint(hwndDlg,&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(hwndDlg,&PtStr); //结束绘图
return TRUE;
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
}
2. CodeBlocks可以创建 Win32 GUI Project
3. resource.h
#include <windows.h>
// ID of Main Dialog
#define DLG_MAIN 101
4. resource.rc
#include "resource.h"
DLG_MAIN DIALOGEX 6, 5, 194, 106
CAPTION "Code::Blocks Template Dialog App"
FONT 8, "Tahoma"
5. main.cpp
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include<stdlib.h>
#include<string.h>
#include "resource.h"
HINSTANCE hInst;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hDC; //定义指向设备描述表的句柄
HBRUSH hBrush; //定义指向画刷的句柄
HPEN hPen; //定义指向画笔的句柄
PAINTSTRUCT PtStr; //定义指向包含绘图信息的结构体变量
switch(uMsg)
{
case WM_PAINT:
hDC=BeginPaint(hwndDlg,&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(hwndDlg,&PtStr); //结束绘图
return TRUE;
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询