🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by ScOe Wed, 26 Mar 2003 18:20
DialogBox BUG
#17395
Author: ScOe
Date: Wed, 26 Mar 2003 18:20
21 lines
1874 bytes
I've encounter one BUG with c++ builder or something ... and i dont know how
to fix it ...
Problem is following ...
i'm calling DialogBox function and for MyDialogProc
    fResult = DialogBox (hInstance, TEXT ("AboutBox"), 0, MyDialogProc) ;
error code that i'm receiving is:
    E2034 Cannot convert 'int (__stdcall *)(void *,unsigned int,unsigned
int,long)' to 'int (__stdcall*)()'
    E2342 Type mismatch in parameter 'lpDialogFunc' (wanted 'int (__stdcall
*)()', got 'int (__stdcall *)(void *,unsigned int,unsigned     int,long)')

this is declaration of lpDialogFunc function:
BOOL CALLBACK MyDialogProc(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM
lParam)

I dont know how did he expect to get 'int (__stdcall *)()' when in winhelp
is wroten that 'lpDialogFunc' expect 'int (__stdcall *)(void *,unsigned
int,unsigned     int,long)' callback function.
I saw in Charles Petzold example that is using same parametered procedure.
Tried to compile it but i receive same kind of error ... so problem must be
in C++ Builder.
Re: DialogBox BUG
#17397
Author: Remy Lebeau (TeamB)
Date: Wed, 26 Mar 2003 18:50
40 lines
2238 bytes
"ScOe" <sven.savic@zg.hinet.hr> wrote in message
news:3e81ef72@newsgroups.borland.com...
> I've encounter one BUG with c++ builder or something ...
> and i dont know how to fix it ...

That's not a bug in Builder, but in your understanding in how your own code
should work.

> i'm calling DialogBox function and for MyDialogProc
>     fResult = DialogBox (hInstance, TEXT ("AboutBox"), 0, MyDialogProc) ;
> error code that i'm receiving is:
>     E2034 Cannot convert 'int (__stdcall *)(void *,unsigned int,unsigned
> int,long)' to 'int (__stdcall*)()'

Your dialog procedure doesn't match the function signature DialogBox() is
expecting.  You need to cast your function pointe when you pass it in:

    fResult = DialogBox (hInstance, TEXT ("AboutBox"), 0,
(DLGPROC)MyDialogProc) ;

> I dont know how did he expect to get 'int (__stdcall *)()' when in winhelp
> is wroten that 'lpDialogFunc' expect 'int (__stdcall *)(void *,unsigned
> int,unsigned     int,long)' callback function.

That is because DLGPROC has a different declaration depending on whether
STRICT is defined or not, which is not defined by default:

typedef int (FAR WINAPI *FARPROC)();

...

#ifdef STRICT
typedef INT_PTR (CALLBACK* DLGPROC)(HWND, UINT, WPARAM, LPARAM);
#else
typedef FARPROC DLGPROC;
#endif


Gambit
Re: DialogBox BUG
#17388
Author: ScOe
Date: Wed, 26 Mar 2003 19:37
15 lines
1306 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e81f425$1@newsgroups.borland.com...
>
> "ScOe" <sven.savic@zg.hinet.hr> wrote in message
> news:3e81ef72@newsgroups.borland.com...

> That's not a bug in Builder, but in your understanding in how your own
code
> should work.

Thanx for reply.
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads