DialogBoxParam error

I am rewriting old program and compiler gives C2664 error - cannot convert argument 4 from 'FARPROC' to 'DLGPROC'
It underlines lpProc in all 4 instances.
I have looked at:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms645465%28v=vs.85%29.aspx

and still can't figure out the problem.

Any help will be appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Parinput::Parinput(void *lp,int DLG_ID)
{
    switch(DLG_ID)
    {
     case _DLG_PAR:
          lppar=(Parameters *)lp;
          lpProc  = MakeProcInstance((FARPROC)(Parinput::pardlg),hAppInst);
          DialogBoxParam(hAppInst,"DLG_PARINPUT",hFrameWnd,lpProc,(long)this);
          break;
     case _DLG_FLOAT:
          real=(float *)lp;
          lpProc = MakeProcInstance((FARPROC)(Parinput::floatdlg),hAppInst);
          DialogBoxParam(hAppInst,"DLG_BASICINPUT",hFrameWnd,lpProc,(long)this);
          break;
     case _DLG_BACKSUB:
          lpbd=(Bound *)lp;
          lpProc = MakeProcInstance((FARPROC)(Parinput::backsubdlg),hAppInst);
		    DialogBoxParam(hAppInst,"DLG_BACKSUBTRACT",hFrameWnd,lpProc,(long)this);
          break;

	 case _DLG_NORM:
	      lpbd=(Bound *)lp;
          lpProc = MakeProcInstance((FARPROC)(Parinput::normdlg),hAppInst);
	      DialogBoxParam(hAppInst,"DLG_NORMALIZE",hFrameWnd,lpProc,(long)this);
	      break;
	}
}
MakeProcInstance is a throwback to WIN16 days; for WIN32 and WIN64 code you just pass the function address.

5
6
7
8
     case _DLG_PAR:
          lppar=(Parameters *)lp;
          DialogBoxParam(hAppInst,"DLG_PARINPUT",hFrameWnd,Parinput::pardlg,(LPARAM)this); // long -> LPARAM, so valid for WIN64 as well as WIN32
          break;


You should not need a cast; if you need a cast the signature of your function must be wrong.

(I see you know that Parinput::pardlg(), etc must be static member functions given that you are passing the this pointer, but including this note for passing readers.)

Andy

PS Where is lppar, real, lpdb, .. declared? Are they member variables?

What did MakeProcInstance do?
http://blogs.msdn.com/b/oldnewthing/archive/2008/02/07/7502464.aspx
Last edited on
Thanks mate!
I can't tell you whether this works since this is a really old software and I sill have a plenty of legacy code to deal with. But the compiler does not complain about this anymore!

they are

def.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Parinput 
{
    Parameters *lppar;
    float      *real;
    Bound      *lpbd;
    FARPROC     lpProc;
    void printpar(HANDLE,WPARAM);
    void getpar(WPARAM); 
 public:
    Parinput(void *lp,int DLG_ID);
    ~Parinput(void){FreeProcInstance(lpProc);}    ;
    static int CALLBACK pardlg(HWND,UINT,WPARAM,LPARAM);
    static int CALLBACK backsubdlg(HWND,UINT,WPARAM,LPARAM);
    static int CALLBACK normdlg(HWND,UINT,WPARAM,LPARAM);
    static int CALLBACK floatdlg(HWND,UINT,WPARAM,LPARAM);
};
Last edited on
Topic archived. No new replies allowed.