赞
踩
我自己看文档、找资料和写代码需要一定时间,现在在用课余时间持续更新中...
Win32控件中文文档
控件库 - Win32 apps | Microsoft Learn
win32控件英文文档
Control Library - Win32 apps | Microsoft Learn
win32通用控件中文文档
Commdlg.h 标头 - Win32 apps | Microsoft Learn
win32通用控件英文文档
Commdlg.h header - Win32 apps | Microsoft Learn
附此结构体的英文文档:FINDREPLACEA (commdlg.h) - Win32 apps | Microsoft Learn
- typedef struct tagFINDREPLACEA {
- DWORD lStructSize;
- HWND hwndOwner;
- HINSTANCE hInstance;
- DWORD Flags;
- LPSTR lpstrFindWhat;
- LPSTR lpstrReplaceWith;
- WORD wFindWhatLen;
- WORD wReplaceWithLen;
- LPARAM lCustData;
- LPFRHOOKPROC lpfnHook;
- LPCSTR lpTemplateName;
- } FINDREPLACEA, *LPFINDREPLACEA;
DWORD lStructSize
结构体的字节长度
HWND hwndOwner
拥有此通用控件“FindText”的窗口的句柄,这个句柄可以是任何有效的窗口,但不能写NULL
DWORD Flags
暂时还没弄懂...,先填FR_DIALOGTERM吧
LPSTR lpstrFindWhat
用户输入在“Find What”编辑框里面的要查找的字符串。你必须动态分配一个缓冲区,或者用一个全局数组或静态数组。这个缓冲区至少要有80个char那么长。
LPSTR lpstrReplaceWith
用户输入在“Replace With”编辑框里面的要被替代的字符串。你必须动态分配一个缓冲区,或者用一个全局数组或静态数组。
WORD wFindWhatLen
被lpstrFindWhat成员指定的缓冲区的字节长度
WORD wReplaceWithLen
被lpstrReplaceWith成员指定的缓冲区的字节长度
LPARAM lCustData
暂时还没弄懂...,先填NULL吧
LPFRHOOKPROC lpfnHook
暂时还没弄懂...,先填NULL吧
LPCSTR lpTemplateName
暂时还没弄懂...,先填NULL吧
- HWND FindText(
- LPFINDREPLACEA unnamedParam1
- );
- #include<Windows.h>
-
- LRESULT CALLBACK WndProc(HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam)
- {
- switch (msgID)
- {
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hWnd, msgID, wParam, lParam);
- }
-
- int CALLBACK WinMain(HINSTANCE hIns, HINSTANCE hPreIns, LPSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASS wc = { 0 };
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.hCursor = NULL;
- wc.hIcon = NULL;
- wc.hInstance = hIns;
- wc.lpfnWndProc = WndProc;
- wc.lpszClassName = L"Main";
- wc.lpszMenuName = NULL;
- wc.style = CS_HREDRAW | CS_VREDRAW;
-
-
-
- RegisterClass(&wc);
-
- HWND hWnd = CreateWindowEx(0, L"Main", L"window", WS_OVERLAPPEDWINDOW, 100, 100, 500, 500, NULL, NULL, hIns, NULL);
-
- char find_buffer[80] = " ", replace_buffer[80] = " ";
- FINDREPLACEA find;
- find.lStructSize = sizeof(find);
- find.hwndOwner = hWnd;
- find.hInstance = hIns;
- find.Flags = FR_DIALOGTERM;
- find.lpstrFindWhat =find_buffer;
- find.lpstrReplaceWith =replace_buffer;
- find.wFindWhatLen = sizeof(find_buffer);
- find.wReplaceWithLen = sizeof(replace_buffer);
- find.lCustData = NULL;
- find.lpfnHook = NULL;
- find.lpTemplateName = NULL;
- LPFINDREPLACE lpfp = (LPFINDREPLACE)&find;
- HWND hFind = FindText(lpfp);
-
- ShowWindow(hWnd, SW_SHOW);
-
- UpdateWindow(hWnd);
-
- MSG nMsg = { 0 };
- while (GetMessage(&nMsg, NULL, NULL, NULL))
- {
- TranslateMessage(&nMsg);
- DispatchMessage(&nMsg);
-
- }
-
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。