这个程序错在哪里呢,哪位帮找找,我想了好久没解决

foxzhouxp 2016-09-05 08:33:00
error C2664: 'EnumChildWindows' : cannot convert parameter 2 from 'int (struct HWND__ *,long)' to 'int (__stdcall *)(struct HWND__ *,long)'
None of the functions with this name in scope match the target type
Generating Code...
Error executing cl.exe.

ccc.exe - 1 error(s), 0 warning(s)



编译出错




...全文
704 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
baoyz 2016-10-29
  • 打赏
  • 举报
回复
BOOL CALLBACK CAutoCADDlg::EnumChildWindowsproc1(HWND hwnd,LPARAM lparam) 这个函数只有两个输入变量。
schlafenhamster 2016-09-08
  • 打赏
  • 举报
回复
10楼不是给你搞好了吗。 没有必要 把 CALLBACK 放 类里 !
schlafenhamster 2016-09-06
  • 打赏
  • 举报
回复
对话框

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);
	}
}
schlafenhamster 2016-09-06
  • 打赏
  • 举报
回复

// 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 ?
Saleayas 2016-09-06
  • 打赏
  • 举报
回复
class C { static BOOL CALLBACK StaticEnumChildProc(HWND hWnd, LPARAM lParam) { return reinterpret_cast< C * >(lParam)->EnumChild(hWnd); } BOOL EnumChild(HWND hWnd) { // 实现的成员函数。 } void EnumWindows(HWND hWnd) { // 你呼叫的函数。 EnumChildWindows(hWnd,StaticEnumChildProc,this); } }
zgl7903 2016-09-06
  • 打赏
  • 举报
回复
类内的回调函数用 static 声明 class xxx { static BOOL CALLBACK EnumChildFun(HWND hWnd, LPARAM lParam) { return TRUE; } }
foxzhouxp 2016-09-06
  • 打赏
  • 举报
回复
我是用vc6输入代码的,兄弟,把null改为0就得了吗?还有一个兄弟说传this指针怎么具体实现呢,谢谢!
sevancheng 2016-09-06
  • 打赏
  • 举报
回复
去掉CALLBACK
Saleayas 2016-09-06
  • 打赏
  • 举报
回复
使用 static 修饰 CALLBACK 函数,在 Param 参数中传递 this. 在 Callback 函数中Param 重新指向 this, 在调用成员函数。
schlafenhamster 2016-09-06
  • 打赏
  • 举报
回复
::EnumChildWindows(wnd1,lpEnumFunc,NULL);//出错是在这句, ::EnumChildWindows(wnd1,lpEnumFunc,0);// 0 不是 NULL
Eleven 2016-09-06
  • 打赏
  • 举报
回复
BOOL CALLBACK EnumChildProc( HWND hwnd, LPARAM lParam );
schlafenhamster 2016-09-06
  • 打赏
  • 举报
回复
那 EnumChildProc 改 EnumChild 吧 vc6 上 可运行成功
foxzhouxp 2016-09-06
  • 打赏
  • 举报
回复
10楼,编译出错啊, Generating Code... Linking... dddDlg.obj : error LNK2005: "int __stdcall EnumChildProc(struct HWND__ *,long)" (?EnumChildProc@@YGHPAUHWND__@@J@Z) already defined in ddd.obj Debug/ddd.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. ddd.exe - 2 error(s), 0 warning(s)
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
截图上来看,
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
我是参数以下这个代码做的,这个是控制台下的程序,我上面那个是想写在MF基于对话框下的,

以下代码是可以正常运行的。得到设想的结果。
#include "stdafx.h"
#include<windows.h>
#include<stdio.h>
BOOL CALLBACK lpEnumFunc(HWND hwnd, LPARAM lParam);
static int i=0;

int main(int argc, char* argv[])
{
HWND wnd1=FindWindowEx(NULL,NULL,NULL,"Ìæ»»");
if (wnd1 !=NULL)
{
::EnumChildWindows(wnd1,lpEnumFunc,NULL); //ö¾Ù×Ó´°¿Ú
}


return 0;
}


BOOL CALLBACK lpEnumFunc(HWND wnd, LPARAM lParam)
{
char WindowName[52]={0};
GetWindowText(wnd,WindowName,sizeof(WindowName)); //¸ù¾Ý´°¿Ú¾ä±ú»ñµÃ´°¿ÚÃû
printf("´°¿Ú¾ä±ú:%d ´°¿ÚÃû³Æ:%s\n,",wnd,WindowName);
//¿ÉÒÔÔÚÕâÀï¼Ó¸öÅжϵ±Ç°ÊÇ·ñÓÐÒ»¸ö´°¿ÚÕýÔÚÔËÐÐ

if (i==7)
{
::SendMessage(wnd,WM_SETTEXT,0,(LPARAM)"ÑÝʾ");
return 0;
}
i++;
return 1;
}
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
程序的功能就是想把这个“替换“对话框中的一个按钮的标题更换为”演示“,其实我是学枚举窗口,到时候枚举到对应的窗口后,就直接发送单击消息,主要是学习枚举窗口方法,各位不要建议我用什么findwindowx什么的啊,谢谢。我是学枚举窗口的使用。
oyljerry 2016-09-05
  • 打赏
  • 举报
回复
你的函数参数不符合要求 注意类型一致
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
::EnumChildWindows(wnd1,lpEnumFunc,NULL);//出错是在这句,因为只要是加了这句,就出错了,提示好似是参数不正确还是什么。 i变量是作为对话框类的对成变量,回调涵数lpEnumFunc是作为对话框类的成员凼数,可是为什么总是出错啊,哪位高手帮帮忙啦,十分感谢。
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
foxzhouxp 2016-09-05
  • 打赏
  • 举报
回复
主机代码如图所示:

大约的功能就是,打一记事本窗口后,点出来“编辑”菜单中的“替换”对话框,

然后,我这个程序的功能就是把“替换”对话框中的一个按钮的标题替换为“演示”这两个字,我是练习枚举窗口用的,但是不成功,谢谢。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧