C++完成昨天的对话框程序

// 20170915_testdlg.cpp : Defines the entry point for the application.//#include "stdafx.h"#include#include "resource.h"

BOOL CALLBACK DialogProc(      HWND hwndDlg,

UINT uMsg,

WPARAM wParam,

LPARAM lParam

);

BOOL CALLBACK DialogProc(          HWND hwndDlg,

UINT uMsg,

WPARAM wParam,

LPARAM lParam

)

{

char szBuffer1[256];

char szBuffer2[256];

char szOutputBuf[256];

switch (uMsg)

{

case WM_INITDIALOG:

memset(szBuffer1,0,sizeof(szBuffer1));

memset(szBuffer2,0,sizeof(szBuffer2));

memset(szOutputBuf,0,sizeof(szOutputBuf));

break;

case WM_COMMAND:

if (wParam ==IDC_BTN_OUTPUT)

{

GetDlgItemText(hwndDlg,IDC_EDT_FIRST,szBuffer1,sizeof(szBuffer1));

GetDlgItemText(hwndDlg,IDC_EDT_SECOND,szBuffer2,sizeof(szBuffer2));

wsprintf(szOutputBuf,"%s%s",szBuffer1,szBuffer2);

SetDlgItemText(hwndDlg,IDC_EDT_OUTPUT,szOutputBuf);

}

if (wParam == IDC_BTN_EXITAPP)

SendMessage(hwndDlg,WM_CLOSE,0,0);

break;

case WM_CLOSE:

if (IDYES == MessageBox(NULL,"确定关闭?","",MB_YESNO))

EndDialog(hwndDlg,0);

break;

default:

break;

}

return FALSE;

}

int APIENTRY WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPSTR    lpCmdLine,

int      nCmdShow)

{

// TODO: Place code here.

DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DLG_MAIN),NULL,DialogProc,NULL);

return 0;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容