我真的不明白這些來自網絡的例子。他們都是零碎的。沒有一個簡單的簡潔例子來說明如何製作經典的查找文本對話框。不能讓Windows常見查找對話框工作
我把我知道這個,但沒有顯示任何窗口並返回:2147500037 0x80004005
#include <windows.h>
#include <iostream>
#include <iomanip>
int main() {
using namespace std;
UINT uFindReplaceMsg; // message identifier for FINDMSGSTRING
uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
wstring search_str = L"text to search";
HWND findDialog = NULL;
wchar_t szFindWhat[MAX_PATH];
FINDREPLACEW fr;
ZeroMemory(& fr, sizeof(FINDREPLACEW));
fr.lStructSize = sizeof(FINDREPLACEW);
fr.hwndOwner = NULL;
fr.lpstrFindWhat = szFindWhat;
fr.wFindWhatLen = MAX_PATH;
findDialog = FindTextW(&fr);
cout << GetLastError() << endl;
cout << hex << GetLastError() << endl;
}
你能提供給我的作品,所以我可以從構建代碼。
根據http://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#finding_text上的示例,您的應用程序必須處理FINDMSGSTRING消息。你通過調用RegisterWindowMessage來設置它。看樣品。 – 2013-03-14 15:14:50
使用['FindText()']管理的**無模式**通用對話框有一些需求(http://msdn.microsoft.com/en-us/library/windows/desktop/ms646918(v = vs.85).aspx),其中許多你沒有見面。我建議您查看該API的具體內容。 – WhozCraig 2013-03-14 15:15:33
更新了代碼,仍然不起作用。我試圖實現的是儘管讓窗戶顯示出來。 – rsk82 2013-03-14 15:24:24