代码:
#include "stdafx.h"
#include "windows.h"
#include "resource.h"BOOL __stdcall DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
int __stdcall APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// The DialogBoxParam function creates a modal dialog box from a dialog box template resource. Before displaying the dialog box, the function passes an application-defined value to the dialog box procedure as the lParam parameter of the WM_INITDIALOG message. An application can use this value to initialize dialog box controls.
//
// INT_PTR DialogBoxParam(
// HINSTANCE hInstance, // handle to module
// LPCTSTR lpTemplateName, // dialog box template
// HWND hWndParent, // handle to owner window
// DLGPROC lpDialogFunc, // dialog box procedure
// LPARAM dwInitParam // initialization value
// );int nResult = DialogBoxParamA(hInstance,(LPCTSTR)IDD_MAIN,NULL,DlgProc,NULL);
if (nResult == IDOK)
{
MessageBoxA(NULL,"用户选择了OK按钮","07FirstDialog",MB_OK);
}
else
{
MessageBoxA(NULL,"用户选择了Cancel按钮","07FirstDialog",MB_OK);
}
return 0;
}BOOL __stdcall DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
{
SetWindowTextA(hDlg,"第一个对话框!");
break;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
{
// The EndDialog function destroys a modal dialog box, causing the system to end any processing for the dialog box.
//
// BOOL EndDialog(
// HWND hDlg, // handle to dialog box
// INT_PTR nResult // value to return
// );
// Parameters
// hDlg
// [in] Handle to the dialog box to be destroyed.
// nResult
// [in] Specifies the value to be returned to the application from the function that created the dialog box.
EndDialog(hDlg,IDCANCEL);
break;
}
case IDOK:
{
EndDialog(hDlg,IDOK);
break;
}
}
}
return 0;
}
已经有(0)位网友发表了评论,你也评一评吧!
原创文章如转载,请注明:转载自Eddy Blog
原文地址:http://www.rrgod.com/program/294.html 欢迎订阅Eddy Blog。
Tags:模态对话框