Foro de elhacker.net

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
  1. // Dialog.cpp: implementation of the Dialog class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "..\HEADER FILES\Dialog.h"
  6.  
  7.  
  8. //#include <windows.h>
  9. //////////////////////////////////////////////////////////////////////
  10. // Construction/Destruction
  11. //////////////////////////////////////////////////////////////////////
  12.  
  13. xDialog::xDialog(){IsShowed = false;}
  14. xDialog::~xDialog(){}
  15.  
  16. BOOL CALLBACK xDialog::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
  17. switch (message){
  18. case WM_INITDIALOG:
  19. break;
  20. case WM_CLOSE:
  21. //EndDialog(hDlg, 0);
  22. break;
  23. }
  24. return FALSE;
  25. }
  26.  
  27. void xDialog::Show(){
  28. extern HINSTANCE hInst;
  29. if(!xDialog::IsShowed){
  30. MessageBox(NULL, "true","",MB_OK);
  31. }else{
  32. //int aa = DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,xDialog::DialogProc);
  33. DialogBox( hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,xDialog::DialogProc);
  34. IsShowed =false;
  35. }
  36.  
  37. }
  38.  

Código
  1. // Dialog.h: interface for the Dialog class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #if !defined(AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_)
  6. #define AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_
  7.  
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11.  
  12. #include <windows.h>
  13. #include "Commctrl.h" // Link: Comctl32.lib
  14. #include "resource.h"
  15. class xDialog  
  16. {
  17. public:
  18.  
  19. xDialog();
  20. ~xDialog();
  21.  
  22. void Show();
  23. private:
  24. bool IsShowed;
  25. BOOL CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  26.  
  27.  
  28.  
  29.  
  30. // END OF CLASS //////////////////////
  31. };
  32.  
  33.  
  34. #endif // !defined(AFX_DIALOG_H__06732DBB_9D27_41B9_A3A2_ECEEC8128230__INCLUDED_)
  35.  

Código
  1. //Main.cpp
  2. #include <windows.h>
  3. #include "Commctrl.h" // Link: Comctl32.lib
  4. #include "..\HEADER FILES\Dialog.h"
  5.  
  6. HINSTANCE hInst;
  7. int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow){
  8.  
  9. hInst = hInstance;
  10. return 0;
  11. }
  12.  
  13.  

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
  1. 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  ::)