16,548
社区成员




BOOL CALLBACK EnumChildProc(HWND wnd, LPARAM lParam)
{
static int i=0;
char prompt[80];
char WindowName[52]={0};
GetWindowText(wnd,WindowName,sizeof(WindowName));
sprintf(prompt,"HWND: %d;name: %s\n",wnd,WindowName);
afxDump << prompt ;
//HWND: 459738;name: 查找内容(&N):
//HWND: 787428;name:
//HWND: 459708;name: 替换为(&P):
//HWND: 263206;name:
//HWND: 590790;name: 全字匹配(&W)
//HWND: 263204;name: 区分大小写(&C)
//HWND: 263202;name: 查找下一个(&F)
//HWND: 263272;name: 替换(&R)
// if name="替换(&R)" class 按钮
if (i==7)
{
SendMessage(wnd,WM_SETTEXT,0,(LPARAM)"Demo");
return 0;
}
i++;
return 1;
}
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HWND wnd=FindWindowEx(NULL,NULL,NULL,"替换");
if (wnd != NULL)
{
EnumChildWindows(wnd,EnumChildProc,0);
}
}
// notepad.c
#include<windows.h>
#include<stdio.h>
BOOL CALLBACK EnumChildProc(HWND wnd, LPARAM lParam)
{
static int i=0;
char WindowName[52]={0};
GetWindowText(wnd,WindowName,sizeof(WindowName));
printf("HWND: %d;name: %s\n",wnd,WindowName);
if (i==7)
{
SendMessage(wnd,WM_SETTEXT,0,(LPARAM)"Demo");
return 0;
}
i++;
return 1;
}
int main(int argc, char* argv[])
{
HWND wnd=FindWindowEx(NULL,NULL,NULL,"替换");
if (wnd != NULL)
{
EnumChildWindows(wnd,EnumChildProc,0);
}
return 0;
}
怎么知道是 i=7 ?