创建对话框
首选需要创建一个对话框
所以应该包含resource.h资源文件
.h 文件:
struct DecodeUint{
UINT meesage;
LONG (*fun)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
};
#define dim(x) (sizeof(x)/sizeof(x[0]))
LONG OnInit(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LONG OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LONG OnClose(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
.c文件:
#include
#include
#include Border.h
#include resource.h
struct DecodeUint DlgMessage[] = {
WM_INITDIALOG,OnInit,
WM_COMMAND,OnCommand,
};
struct DecodeUint DlgCommand[] = {
IDOK,OnClose,
IDCANCEL,OnClose,
};
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,About);
return 1;
}
BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
for (int i = 0;i dim(DlgMessage);i ++)
{
if (DlgMessage[i].meesage == message)
{
(*DlgMessage[i].fun)(hDlg,message,wParam,lParam);
}
}
return FALSE;
}
LONG OnInit(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
return TRUE;
}
LONG OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
for (int i = 0;i dim(DlgCommand);i ++)
{
if (DlgCommand[i].meesage == LOWORD(wParam))
{
(*DlgCommand[i].fun)(hDlg,message,wParam,lParam);
}
}
return TRUE;
}
LONG OnClose(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
EndDialog(hDlg,0);
return TRUE;
}
WinCE 相关文章:
- 如何使WINCE启动时自动运行应用程序(04-11)
- 基于WinCE操作系统的通用USB数控键盘设计(08-05)
- 基于WinCE的ARM视频监控系统(11-14)
- WinCE系统下BootLoader的开发(04-10)
- WinCE下光电编码器的驱动程序设计(04-12)
- WindowsCE.Net下CAN卡的驱动程序设计(04-12)