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