Dialog Boxes Help!

Started by
3 comments, last by CoolTomK 21 years, 9 months ago
I am having problems setting up a dialog box. When I try to compile my code when it is named mycode.c, it compiles perfectly, but when try to compile when it is names mycode.cpp, I get this error:
  
error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(void)'
 [\source] 

I am assuming that the file name endings tell the compiler to compile in c or c++.  And am wondering why my dialog box code wont compile under C++.  Oh yeah I am using MS VC++ 5.0...

here is my code:
[source]
BOOL	CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);

//window procedure

BOOL CALLBACK AboutDlgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch(Message)
	{
	case WM_INITDIALOG:
		return TRUE;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:
			EndDialog(hWndDlg, 0);
			return TRUE;
		case IDC_LINKBUTTON:
			ShellExecute(NULL, "open", "http://www.keanecircuits.com", NULL, NULL, SW_SHOWDEFAULT);

			break;

		}
		break;
	}

	return FALSE;
}

//how I create the dialog box(line where error occurs)

DialogBox(hInstance, "ABOUTDLG", hWndMain, AboutDlgProc);

 [\source] 

Has anybody experienced a problem like this before, or can help me out???

<SPAN CLASS=editedby>[edited by - CoolTomK on July 18, 2002 4:40:13 PM]</SPAN>  
Advertisement
add this line before including any headers:

#define STRICT

should help.

---
Come to #directxdev IRC channel on AfterNET
Does you prototype and definition of AboutDlgProc look like this?

BOOL CALLBACK AboutDlgProc(HWND,UINT ,WPARAM , LPARAM );

BOOL CALLBACK AboutDlgProc(HWND hAbout,UINT msg,WPARAM wParam,
LPARAM lParam)
{
whatever !
}

maybe !!!
The sky is the limit !
Try this:

////////
DialogBox(hInstance, "ABOUTDLG", hWndMain, (DLGPROC) AboutDlgProc);
////////
quote:Original post by doctorsixstring
DialogBox(hInstance, "ABOUTDLG", hWndMain, (DLGPROC) AboutDlgProc);

it''s better to use STRICT, you get type safety => catch more errors at compile-time rather than at run-time.

---
Come to #directxdev IRC channel on AfterNET

This topic is closed to new replies.

Advertisement