#include "StdAfx.h" #include "InputDialog.hpp" CInputDialog::CInputDialog(void) { IsPassword=0; hbl=new BYTE[1024]; int n,m; dltt=(LPDLGTEMPLATE)hbl; dltt->style=WS_POPUP|WS_BORDER|WS_SYSMENU|DS_MODALFRAME| WS_CAPTION|DS_SETFONT; dltt->dwExtendedStyle=0; dltt->cdit=1; dltt->x=10; dltt->y=10; dltt->cx=100; dltt->cy=100; /* ¶Ô»°¿ò±ß³¤Êý×é */; LPWORD lpw=(LPWORD)(dltt+1); *lpw++=0x0000; //ûÓв˵¥ *lpw++=0x0000; //ʹÓÃϵͳĬÈÏÀà n = MultiByteToWideChar(CP_ACP,0,"¶Ô»°¿ò±êÌâÃû³Æ",-1,(LPWSTR)lpw,50); lpw+=n; *lpw++=9; //×ÖÌå´óС m = MultiByteToWideChar(CP_ACP,0,"ËÎÌå",-1,(LPWSTR)lpw,50); lpw++; lpw+=m; /* °´Å¥¿Ø¼þ */ lpw=(LPWORD)((((ULONG)lpw+3)>>2)<<2); dlit=(LPDLGITEMTEMPLATE)lpw; dlit->dwExtendedStyle=0; dlit->x=10; dlit->y=70; dlit->cx=80; dlit->cy=20; dlit->id=IDOK; //OK°´Å¥±êʶ dlit->style=WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON;//°´Å¥¿Ø¼þ´°¿Ú·ç¸ñ lpw=(LPWORD)(dlit+1); //Òƶ¯Ö¸Õ룬ʹÆäÖ¸ÏòDLGITEMTEMPPLATE½á¹¹µÄÏÂÒ»¸öÄÚ´æµ¥Ôª /* ¿Ø¼þ±ä³¤Êý×é */ *lpw++ = 0xffff; *lpw++ = 0x0080; n=MultiByteToWideChar(CP_ACP,0,"È·¶¨",-1,(LPWSTR)lpw,10); // HINSTANCE hinst = theApp.m_hInstance; /* ´´½¨¶Ô»°¿ò´°¿Ú */ // CDialog dialog1; InitModalIndirect((LPDLGTEMPLATE)hbl); // LRESULT ret = DialogBoxIndirect(hinst,(LPDLGTEMPLATE)hbl,NULL,(DLGPROC)DlgProc); // dialog1.DoModal(); /* ÊÍ·Å×ÊÔ´ */ // return ret; } CInputDialog::~CInputDialog(void) { delete [] hbl; hbl = NULL; } BOOL CInputDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: ÔÚ´ËÌí¼Ó¶îÍâµÄ³õʼ»¯ RECT rect1; rect1.left=10; rect1.top=10; rect1.right=200; rect1.bottom=26; m_static_hint.Create(HintStr,WS_VISIBLE,rect1,this); // m_static_hint.ShowWindow(SW_SHOW); rect1.left=10; rect1.top=40; rect1.right=200; rect1.bottom=64; DWORD style=WS_VISIBLE; if (IsPassword) {style|=ES_PASSWORD;} m_edit_input.Create(style,rect1,this,999); return TRUE; // return TRUE unless you set the focus to a control // Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE } void CInputDialog::OnOK() { // TODO: ÔÚ´ËÌí¼ÓרÓôúÂëºÍ/»òµ÷ÓûùÀà m_edit_input.GetWindowText(InputStr); CDialog::OnOK(); }