Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#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;
}


error C2065: “IDC_EDIT_RECVMESSAGE”: is not declared

how to solve this problem,thanks!
Posted
Updated 12-Jul-12 5:17am
v2
Comments
[no name] 12-Jul-12 10:52am    
Did you create a control on the dialog with an ID of "IDC_EDIT_RECVMESSAGE"?
zhangdian 12-Jul-12 10:55am    
I don't know how to create the control.Thank you for your reply
[no name] 12-Jul-12 11:01am    
Well you would open your dialog in the dialog editor and add the control by selecting the control in the toolbox and then drawing it on the dialog surface then edit the control properties to have that ID...
zhangdian 12-Jul-12 11:08am    
can you tell me the control name? I don't know which one to select.
Richard MacCutchan 12-Jul-12 12:08pm    
You already have the control's id IDC_EDIT_RECVMESSAGE, so only you can decide what control it is. There is nothing in your question that helps us to figure it out.

1 solution

Quote:
error C2065: “IDC_EDIT_RECVMESSAGE”: is not declared

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900