以下代码有什么问题? [英] What's wrong with the following code?

查看:79
本文介绍了以下代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include "stdafx.h"
#include "resource.h"
#include <stdio.h>
#include <windows.h>
BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
					 HINSTANCE hPrevInstance,
					 LPSTR     lpCmdLine,
					 int       nCmdShow)
{
	// TODO: Place code here.
	DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);
	return 0;
}
BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	const char szDlgTitle[] = "RecvMessage";
	static HWND s_hEditShowRecv;

	switch (message)
	{
	case WM_INITDIALOG:
		SetWindowTextA(hDlg, szDlgTitle);
		s_hEditShowRecv = GetDlgItem(hDlg, IDC_EDIT_RECVMESSAGE);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
		case IDCANCEL:
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
		}
		break;

	case WM_COPYDATA:
		{
			COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT*)lParam;
			char szBuffer[300];

			memset(szBuffer, 0, sizeof(szBuffer));
			sprintf(szBuffer, "dwData:%d cbData:%d\r\nlpData:0x%08x = %s\r\n\r\n", 
				pCopyData->dwData, pCopyData->cbData, 
				(PVOID)pCopyData->lpData, (char*)pCopyData->lpData);
			//在编辑框中追加数据
			SendMessage(s_hEditShowRecv, EM_SETSEL, (WPARAM)-1, (LPARAM)-1); // (0, -1)表示全选, (-1,任意)表示全不选
			SendMessage(s_hEditShowRecv, EM_REPLACESEL, FALSE, (LPARAM)szBuffer);
			SendMessage(s_hEditShowRecv, EM_SCROLLCARET, 0, 0);
		}
		return TRUE;
	}
	return FALSE;
}



错误C2065:"IDC_EDIT_RECVMESSAGE":未声明



error C2065: "IDC_EDIT_RECVMESSAGE": is not declared

how to solve this problem,thanks!

推荐答案

报价:

错误C2065: "IDC_EDIT_RECVMESSAGE":未声明

error C2065: "IDC_EDIT_RECVMESSAGE": is not declared


错误消息很容易解释.无论从何处获取此代码,都会有一个编辑框控件(按名称猜测),该控件的资源ID为IDC_EDIT_RECVMESSAGE(如果完全存在,它将位于资源头文件中).现在,编辑框ID已被重命名,或者已被删除,或者您已经复制了它,并且该框在您自己的项目资源中根本不存在.


The error message is pretty self explanatory. Wherever you got this code from, there was an edit box control (I''m guessing by the name) that had a resource ID of IDC_EDIT_RECVMESSAGE (if it exists at all, it would be in the resource header file). Now the edit box ID has either been renamed OR it''s been deleted OR you copied this and the box doesn''t exist at all within your own project resources.


这篇关于以下代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆