資源簡介
Q760642.zip windows程序設計 編寫Windows窗口應用程序實現對話框與菜單的應用 https://ask.csdn.net/questions/760642 編寫Windows窗口應用程序實現對話框與菜單的應用
1)編程實現如下應用程序,含有菜單,單擊“新建”時彈出新建對話框(非模態對話框),單擊對話框顏色按鈕后應用程序窗口字體和背景色發生相應的變化。單擊“關于”菜單項時彈出關于對話框(模態對話框)。
(Winodws對話框、Windows菜單)

代碼片段和文件信息
//?Q760642.cpp?:?Defines?the?entry?point?for?the?application.
//
#include?“stdafx.h“
#include?“commdlg.h“
#include?“Q760642.h“
#define?MAX_LOADSTRING?100
LRESULT?CALLBACK?NewWndProc(HWND?hWnd?UINT?message?WPARAM?wParam?LPARAM?lParam);
//?Global?Variables:
HINSTANCE?hInst; //?current?instance
TCHAR?sztitle[MAX_LOADSTRING]; //?The?title?bar?text
TCHAR?szWindowClass[MAX_LOADSTRING]; //?the?main?window?class?name
HWND?hWnd;
HWND?newdlghWnd;
HBRUSH?hmainBrush?=?NULL;
//?Forward?declarations?of?functions?included?in?this?code?module:
ATOM MyRegisterClass(HINSTANCE?hInstance);
BOOL InitInstance(HINSTANCE?int);
LRESULT?CALLBACK WndProc(HWND?UINT?WPARAM?LPARAM);
INT_PTR?CALLBACK About(HWND?UINT?WPARAM?LPARAM);
int?APIENTRY?_tWinMain(HINSTANCE?hInstance
?????????????????????HINSTANCE?hPrevInstance
?????????????????????LPTSTR????lpCmdLine
?????????????????????int???????nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
? //?TODO:?Place?code?here.
MSG?msg;
HACCEL?hAccelTable;
//?Initialize?global?strings
LoadString(hInstance?IDS_APP_title?sztitle?MAX_LOADSTRING);
LoadString(hInstance?IDC_Q760642?szWindowClass?MAX_LOADSTRING);
MyRegisterClass(hInstance);
//?Perform?application?initialization:
if?(!InitInstance?(hInstance?nCmdShow))
{
return?FALSE;
}
hAccelTable?=?LoadAccelerators(hInstance?MAKEINTRESOURCE(IDC_Q760642));
//?Main?message?loop:
while?(GetMessage(&msg?NULL?0?0))
{
if?(!TranslateAccelerator(msg.hwnd?hAccelTable?&msg))
{
if?(!IsDialogMessage(newdlghWnd?&msg))?
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return?(int)?msg.wParam;
}
//
//??FUNCTION:?MyRegisterClass()
//
//??PURPOSE:?Registers?the?window?class.
//
//??COMMENTS:
//
//????This?function?and?its?usage?are?only?necessary?if?you?want?this?code
//????to?be?compatible?with?Win32?systems?prior?to?the?‘RegisterClassEx‘
//????function?that?was?added?to?Windows?95.?It?is?important?to?call?this?function
//????so?that?the?application?will?get?‘well?formed‘?small?icons?associated
//????with?it.
//
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_Q760642));
wcex.hCursor =?LoadCursor(NULL?IDC_ARROW);
wcex.hbrBackground =?(HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName =?MAKEINTRESOURCE(IDC_Q760642);
wcex.lpszClassName =?szWindowClass;
wcex.hIconSm =?LoadIcon(wcex.hInstance?MAKEINTRESOURCE(IDI_SMALL));
return?RegisterClassEx(&wcex);
}
//
//???FUNCTION:?InitInstance(HINSTANCE?int)
//
//???PURPOSE:?Saves?instance?handle?and?creates?main?window
//
//???COMMENTS:
//
//????????In?this?function?we?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-05-10?01:41??Q760642\Debug\
?????文件???????91648??2019-05-10?01:38??Q760642\Debug\Q760642.exe
?????文件?????????888??2019-05-10?00:18??Q760642\Q760642.sln
?????文件???????12288??2019-05-10?01:41??Q760642\Q760642.suo
?????目錄???????????0??2019-05-10?01:05??Q760642\Q760642\
?????目錄???????????0??2019-05-10?01:42??Q760642\Q760642\Debug\
?????文件???????52452??2019-05-10?01:05??Q760642\Q760642\Q760642.APS
?????文件????????6923??2019-05-10?01:38??Q760642\Q760642\Q760642.cpp
?????文件??????????39??2019-05-10?00:18??Q760642\Q760642\Q760642.h
?????文件???????23558??2009-08-31?02:31??Q760642\Q760642\Q760642.ico
?????文件????????8774??2019-05-10?01:04??Q760642\Q760642\Q760642.rc
?????文件????????4592??2019-05-10?00:18??Q760642\Q760642\Q760642.vcxproj
?????文件????????1824??2019-05-10?00:18??Q760642\Q760642\Q760642.vcxproj.filters
?????文件?????????143??2019-05-10?00:18??Q760642\Q760642\Q760642.vcxproj.user
?????文件????????2578??2019-05-10?00:18??Q760642\Q760642\ReadMe.txt
?????文件????????2252??2019-05-10?01:04??Q760642\Q760642\resource.h
?????文件???????23558??2009-08-31?02:31??Q760642\Q760642\small.ico
?????文件?????????294??2019-05-10?00:18??Q760642\Q760642\stdafx.cpp
?????文件?????????529??2019-05-10?00:18??Q760642\Q760642\stdafx.h
?????文件?????????314??2019-05-10?00:18??Q760642\Q760642\targetver.h
- 上一篇:指紋識別的代碼
- 下一篇:2個8位PWM實現16位DAC
評論
共有 條評論