Test Foro de elhacker.net SMF 2.1

Programación => Programación C/C++ => Mensaje iniciado por: xkiz ™ en 13 Junio 2010, 09:02 AM

Título: error C2664: 'DialogBoxParamA'
Publicado por: xkiz ™ en 13 Junio 2010, 09:02 AM
bue antes que nada debo decir que busque lo que dice el titulo y no encontre algo que me ayude en este foro y en Google, o tal vez no supe entender con lo que me tope, asi que les pido ayuda pls.
recien me termine de ver estos 29 tutoriales (http://foro.elhacker.net/programacion_cc/video_tutorial_programacion_c-t249577.0.html;msg1238679#msg1238679), y empeze un nuevo proyecto y antes que nada ya tengo un error.

Código (cpp) [Seleccionar]

// Dialog.cpp: implementation of the Dialog class.
//
//////////////////////////////////////////////////////////////////////

#include "..\HEADER FILES\Dialog.h"


//#include <windows.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

xDialog::xDialog(){IsShowed = false;}
xDialog::~xDialog(){}

BOOL CALLBACK xDialog::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
switch (message){
case WM_INITDIALOG:
break;
case WM_CLOSE:
//EndDialog(hDlg, 0);
break;
}
return FALSE;
}

void xDialog::Show(){
extern HINSTANCE hInst;
if(!xDialog::IsShowed){
MessageBox(NULL, "true","",MB_OK);
}else{
//int aa = DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,xDialog::DialogProc);
DialogBox( hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,xDialog::DialogProc);
IsShowed =false;
}

}


Código (cpp) [Seleccionar]

// Dialog.h: interface for the Dialog class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_)
#define AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <windows.h>
#include "Commctrl.h" // Link: Comctl32.lib
#include "resource.h"
class xDialog 
{
public:

xDialog();
~xDialog();

void Show();
private:
bool IsShowed;
BOOL CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);




// END OF CLASS //////////////////////
};


#endif // !defined(AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_)


Código (cpp) [Seleccionar]

//Main.cpp
#include <windows.h>
#include "Commctrl.h" // Link: Comctl32.lib
#include "..\HEADER FILES\Dialog.h"

HINSTANCE hInst;
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow){

hInst = hInstance;
return 0;
}



ERROR: Dialog.cpp(33) : 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,l
ong)'
        None of the functions with this name in scope match the target type.


estoy utilizando VS C++6.0
¿Como puedo arreglar esto, ya no se por donde mirar?
Título: Re: error C2664: 'DialogBoxParamA'
Publicado por: Eternal Idol en 13 Junio 2010, 13:10 PM
Tenes que hacer al metodo estatico, el callback no puede pasarte el puntero this del objeto. Lo podes meter en el GWL_USERDATA con SetWindowLong y sacarlo despues con GetWindowLong:

Código (cpp) [Seleccionar]
xDialog *thisDialog = (xDialog*)GetWindowLong(hDlg, GWL_USERDATA);
Título: Re: error C2664: 'DialogBoxParamA'
Publicado por: xkiz ™ en 13 Junio 2010, 13:43 PM
muchas gracias...
Título: Re: error C2664: 'DialogBoxParamA'
Publicado por: Eternal Idol en 13 Junio 2010, 13:55 PM
De nadas  ::)