在c++中使用Win32InputBox
Using Win32InputBox in C++
本文关键字:Win32InputBox c++ 更新时间:2023-10-16
我正在使用这个InputBox代码(使用对话框模板)-> http://www.codeproject.com/Articles/13330/Using-Dialog-Templates-to-create-an-InputBox-in-C
和如果我先调用MessageBox(..)函数一切正常,但没有他们的应用程序挂起!(其中必须有一些初始化代码)!
其实我不需要MessageBox(),只想使用这个InputBox ->我怎么才能实现它?
我的步骤:
- <
- 包括Win32InputBox.h/. cpp/gh>
- 包含头文件到我的文件
- add
CWin32InputBox::InputBox(_T("Input Dialog"), _T("Please enter password"), buf, 100, false, NULL);
(wchar_t buf[100] = {0};)
void ClassA::SomeFunction()
{
// ...
MessageBoxA(NULL, "TEST!", "TEST", MB_ICONINFORMATION); // with this ALL OK
wchar_t buf[100] = {0};
CWin32InputBox::InputBox(_T("Input Dialog"), _T("Please enter password"), buf, 100, false, NULL);
// ...
}
如果应用程序挂起,就是CWin32InputBox::InputBoxEx(...)
INT_PTR r = ::DialogBoxIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)&inputbox);
Thx
我通过在调用InputBox之前创建一个虚拟窗口来解决这个问题!
void ClassA::SomeFunction()
{
// ...
// create a dummy window
HWND dummyHWND = ::CreateWindowA("STATIC","dummy",WS_VISIBLE,0,0,100,100,NULL,NULL,NULL,NULL);
wchar_t buf[100] = {0};
CWin32InputBox::InputBox(_T("Input Dialog"), _T("Please enter KeyCard password"), buf, 100, false, dummyHWND);
// ...
}
相关文章: