資源簡介
簡單win32繪圖程序
代碼片段和文件信息
//?First_Win32.cpp?:?定義應用程序的入口點。
//
#include?“stdafx.h“
#include?“First_Win32.h“
#include?“Graph.h“
#include?
#include?
using?namespace?std;
#define?MAX_LOADSTRING?100
//?全局變量:
HINSTANCE?hInst; //?當前實例
TCHAR?sztitle[MAX_LOADSTRING]; //?標題欄文本
TCHAR?szWindowClass[MAX_LOADSTRING]; //?主窗口類名
list??g_data;
list?::iterator?it;??//?迭代器
//?此代碼模塊中包含的函數的前向聲明:
ATOM MyRegisterClass(HINSTANCE?hInstance);
BOOL InitInstance(HINSTANCE?int);
LRESULT?CALLBACK WndProc(HWND?UINT?WPARAM?LPARAM);
INT_PTR?CALLBACK About(HWND?UINT?WPARAM?LPARAM);
BOOL?SaveDrawInfo();??//?保存繪圖信息
BOOL?OpenDrawInfo();??//?讀取繪圖信息
BOOL?DestroyList();???//?釋放函數
int?APIENTRY?_tWinMain(HINSTANCE?hInstance
?????????????????????HINSTANCE?hPrevInstance
?????????????????????LPTSTR????lpCmdLine
?????????????????????int???????nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
? //?TODO:?在此放置代碼。
MSG?msg;
HACCEL?hAccelTable;
//?初始化全局字符串
LoadString(hInstance?IDS_APP_title?sztitle?MAX_LOADSTRING);
LoadString(hInstance?IDC_FIRST_WIN32?szWindowClass?MAX_LOADSTRING);
MyRegisterClass(hInstance);
//?執行應用程序初始化:
if?(!InitInstance?(hInstance?nCmdShow))
{
return?FALSE;
}
hAccelTable?=?LoadAccelerators(hInstance?MAKEINTRESOURCE(IDC_FIRST_WIN32));
//?主消息循環:
while?(GetMessage(&msg?NULL?0?0))
{
if?(!TranslateAccelerator(msg.hwnd?hAccelTable?&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return?(int)?msg.wParam;
}
//
//??函數:?MyRegisterClass()
//
//??目的:?注冊窗口類。
//
//??注釋:
//
//????僅當希望
//????此代碼與添加到?Windows?95?中的“RegisterClassEx”
//????函數之前的?Win32?系統兼容時,才需要此函數及其用法。調用此函數十分重要,
//????這樣應用程序就可以獲得關聯的
//????“格式正確的”小圖標。
//
ATOM?MyRegisterClass(HINSTANCE?hInstance)
{
WNDCLASSEX?wcex;
wcex.cbSize?=?sizeof(WNDCLASSEX);
wcex.style =?CS_HREDRAW?|?CS_VREDRAW;
wcex.lpfnWndProc =?WndProc;
wcex.cbClsExtra =?0;
wcex.cbWndExtra =?0;
wcex.hInstance =?hInstance;
wcex.hIcon =?LoadIcon(hInstance?MAKEINTRESOURCE(IDI_FIRST_WIN32));
wcex.hCursor =?LoadCursor(NULL?IDC_ARROW);
wcex.hbrBackground =?(HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName =?MAKEINTRESOURCE(IDC_FIRST_WIN32);
wcex.lpszClassName =?szWindowClass;
wcex.hIconSm =?LoadIcon(wcex.hInstance?MAKEINTRESOURCE(IDI_SMALL));
return?RegisterClassEx(&wcex);
}
//
//???函數:?InitInstance(HINSTANCE?int)
//
//???目的:?保存實例句柄并創建主窗口
//
//???注釋:
//
//????????在此函數中,我們在全局變量中保存實例句柄并
//????????創建和顯示主程序窗口。
//
BOOL?InitInstance(HINSTANCE?hInstance?int?nCmdShow)
{
???HWND?hWnd;
???hInst?=?hInstance;?//?將實例句柄存儲在全局變量中
???hWnd?=?CreateWindow(szWindowClass?sztitle?WS_OVERLAPPEDWINDOW
??????CW_USEDEFAULT?0?CW_USEDEFAULT?0?NULL?NULL?hInstance?NULL);
???if?(!hWnd)
???{
??????return?FALSE;
???}
???ShowWindow(hWnd?nCmdShow);
???UpdateWindow(hWnd);
???return?TRUE;
}
//
- 上一篇:電子商務物流uml各種圖
- 下一篇:wwkaven_8363939.zip
評論
共有 條評論