Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(DLGPROC) not recognized ... what am i missing ?

Status
Not open for further replies.

iza

Programmer
Apr 4, 2000
1,804
FR
hi :)
i only want to launch a DialogBox
the point is that the parent window is a shell window but that shouldn't be a problem
so i wrote : (ok basically it's msdn example ;))
...
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_DELETEITEM:
if (DialogBox(hinst,
MAKEINTRESOURCE(DLG_DELETEITEM),
hwnd, (DLGPROC)DeleteItemProc)==IDOK)
{
...

BOOL CALLBACK DeleteItemProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
...

...

this is how it's done almost everywhere

now when i try to buld it, i get :

error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'

to me that means that (DLGPROC) is not recognised !!!!! what could i do ???

if i change the call to :

DialogBox(hinst,MAKEINTRESOURCE(DLG_DELETEITEM), hwnd, DeleteItemProc)


i get :

error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'

so i'm just missing the (__stdcall *) part ????

please help ! as you can see i'm a bit lost as i'm new to vc++ and not doing "standards" things !!!!


 
Wow, I'm having this same issue. Anyone have a clue what the cause is?

B
 
I don't know why you are having this problems, I have many SDK programs that use this sintax they all compile and work OK with or without the cast to (DLGPROC).

However, I hope you have predeclared your DialogProc function with a sintax like:

BOOL CALLBACK DeleteItemProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
before the main function or in an included .h file.

Try also to change the name of your dialog procedure, it may look like the name of a function that is present in one of a included .h file.

Just-in-case you cann add the __stdcall modifier to your function declaration, but I don't see why this should be normally asked there.

Hope this helps,

s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
I totally agree and have double checked the suggested items.

The only things I can find that may be causing additional confusion.

1. The Proc is a Member function of a class, derived from another class.

2. The prototype is present within the class declaration.

3. Windows.h is included and successfully resourced.

The problem is totally confusing, I've used Dialogs before but not the way I'm attempting to here (inside a class).

I'll try a direct cast to the __stdcall modifier to see what happens but I don't expect it to solve the problem.

B
 
The dialog proc should NOT be a member of a class or a namespace. It should be an independent function declared in one of included .h file or inside the same file with its caller.(like the one from my previos answer)

I think this is the problem.
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
I've discovered the problem and resolution. In summary, I didn't think about the fact a member function gets a *this behind the scenes. Making it static strips the *this. So my call to the proc was packing more information then set for and couldn't find itself because of it.

The resolution was using DialogBoxParam and casting this to (LPARAM)this. Now the static class member uses the proc correctly. Because of the LPARAM cast, *this can be extracted and used inside the proc while being a static class member that doesn't know it's passing the *this.

If I would have used MFC this would have been a no brainer because the functionality is already wrapped into classes which is exactly what I wanted, but have no interest in the runtime reqs of MFC.

Thanks
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top