Bonjour,
Cette question doit �tre r�currente mais je n'ai pas trouv� une r�ponse compr�hensible par mes connaissances en C++.
Beaucoup de fonction de l'API Windows utilisent des callback.
Je peux passer une fonction membre comme callback en la d�clarant static.
Mais j'ai besoin d'acc�der � des donn�es de l'instance de ma classe.
Je comprends qu'en passant une fonction membre, cela ne respecte pas le prototype.
Je ne dispose pas d'un param�tre permettant de passer l'instance de ma classe comme cela est mentionn� dans cet article : http://cpp.developpez.com/faq/cpp/?p...onction_membre
J'ai regard� boost ... mais je n'ai pas compris comment l'utiliser!
Comment faire?
Merci,
Yves
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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
28
29
30
31
32
33
34
35 class Calibration { public: Calibration(void); ~Calibration(void); bool Initialize(HINSTANCE hInstance, HWND hWnd); private: HWND hWnd; INT_PTR CALLBACK Initialize_CallBack( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); }; INT_PTR CALLBACK Calibration::Initialize_CallBack( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { // use of hWnd } bool Calibration::Initialize(HINSTANCE hInstance, HWND hWnd) { this->hWnd = hWnd; if (DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG_DISPLAY_SIZE), hWnd, &Calibration::Initialize_CallBack) != IDOK){ return false; } return true; }
Partager