提交 | 用户 | age
|
4b03ae
|
1 |
#include "StdAfx.h"
|
Q |
2 |
#include "InputDialog.hpp"
|
|
3 |
|
|
4 |
|
|
5 |
CInputDialog::CInputDialog(void)
|
|
6 |
{
|
|
7 |
IsPassword=0;
|
|
8 |
|
|
9 |
hbl=new BYTE[1024];
|
|
10 |
|
|
11 |
int n,m;
|
|
12 |
dltt=(LPDLGTEMPLATE)hbl;
|
|
13 |
dltt->style=WS_POPUP|WS_BORDER|WS_SYSMENU|DS_MODALFRAME|
|
|
14 |
WS_CAPTION|DS_SETFONT;
|
|
15 |
dltt->dwExtendedStyle=0;
|
|
16 |
dltt->cdit=1;
|
|
17 |
dltt->x=10;
|
|
18 |
dltt->y=10;
|
|
19 |
dltt->cx=100;
|
|
20 |
dltt->cy=100;
|
|
21 |
/* 对话框边长数组 */;
|
|
22 |
LPWORD lpw=(LPWORD)(dltt+1);
|
|
23 |
*lpw++=0x0000; //没有菜单
|
|
24 |
*lpw++=0x0000; //使用系统默认类
|
|
25 |
n = MultiByteToWideChar(CP_ACP,0,"对话框标题名称",-1,(LPWSTR)lpw,50);
|
|
26 |
lpw+=n;
|
|
27 |
*lpw++=9; //字体大小
|
|
28 |
m = MultiByteToWideChar(CP_ACP,0,"宋体",-1,(LPWSTR)lpw,50);
|
|
29 |
lpw++;
|
|
30 |
lpw+=m;
|
|
31 |
|
|
32 |
/* 按钮控件 */
|
|
33 |
lpw=(LPWORD)((((ULONG)lpw+3)>>2)<<2);
|
|
34 |
dlit=(LPDLGITEMTEMPLATE)lpw;
|
|
35 |
dlit->dwExtendedStyle=0;
|
|
36 |
dlit->x=10;
|
|
37 |
dlit->y=70;
|
|
38 |
dlit->cx=80;
|
|
39 |
dlit->cy=20;
|
|
40 |
dlit->id=IDOK; //OK按钮标识
|
|
41 |
dlit->style=WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON;//按钮控件窗口风格
|
|
42 |
lpw=(LPWORD)(dlit+1); //移动指针,使其指向DLGITEMTEMPPLATE结构的下一个内存单元
|
|
43 |
/* 控件变长数组 */
|
|
44 |
*lpw++ = 0xffff;
|
|
45 |
*lpw++ = 0x0080;
|
|
46 |
n=MultiByteToWideChar(CP_ACP,0,"确定",-1,(LPWSTR)lpw,10);
|
|
47 |
// HINSTANCE hinst = theApp.m_hInstance;
|
|
48 |
/* 创建对话框窗口 */
|
|
49 |
// CDialog dialog1;
|
|
50 |
InitModalIndirect((LPDLGTEMPLATE)hbl);
|
|
51 |
// LRESULT ret = DialogBoxIndirect(hinst,(LPDLGTEMPLATE)hbl,NULL,(DLGPROC)DlgProc);
|
|
52 |
// dialog1.DoModal();
|
|
53 |
/* 释放资源 */
|
|
54 |
|
|
55 |
// return ret;
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
CInputDialog::~CInputDialog(void)
|
|
60 |
{
|
|
61 |
delete [] hbl;
|
|
62 |
hbl = NULL;
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
BOOL CInputDialog::OnInitDialog()
|
|
67 |
{
|
|
68 |
CDialog::OnInitDialog();
|
|
69 |
|
|
70 |
// TODO: 在此添加额外的初始化
|
|
71 |
RECT rect1;
|
|
72 |
rect1.left=10;
|
|
73 |
rect1.top=10;
|
|
74 |
rect1.right=200;
|
|
75 |
rect1.bottom=26;
|
|
76 |
m_static_hint.Create(HintStr,WS_VISIBLE,rect1,this);
|
|
77 |
// m_static_hint.ShowWindow(SW_SHOW);
|
|
78 |
|
|
79 |
rect1.left=10;
|
|
80 |
rect1.top=40;
|
|
81 |
rect1.right=200;
|
|
82 |
rect1.bottom=64;
|
|
83 |
DWORD style=WS_VISIBLE;
|
|
84 |
if (IsPassword) {style|=ES_PASSWORD;}
|
|
85 |
m_edit_input.Create(style,rect1,this,999);
|
|
86 |
|
|
87 |
return TRUE; // return TRUE unless you set the focus to a control
|
|
88 |
// 异常: OCX 属性页应返回 FALSE
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
void CInputDialog::OnOK()
|
|
93 |
{
|
|
94 |
// TODO: 在此添加专用代码和/或调用基类
|
|
95 |
m_edit_input.GetWindowText(InputStr);
|
|
96 |
|
|
97 |
CDialog::OnOK();
|
|
98 |
}
|