1 | initial version |
it wants a static function as mouse callback, while you have a class member function (which would need the classe's this
pointer to work properly)
it needs some indirection:
class CBeautyDlg {
void ::realMouse(int events, int x, int y, int flag) {
// your event handling code
}
static void ::onMouse(int events, int x, int y, int flag, void* me) {
CBeautyDlg * that = (CBeautyDlg *)(me); // cast back to proper class
that->realMouse(events, x, y, flag); // call class member
}
void OnBnClickedButton6() {
...
setMouseCallback("myshowWnd", onMouse, (void*)this); // "this" goes into the userdata !
}
};
2 | No.2 Revision |
it wants a static function as mouse callback, while you have a class member function (which would need the classe's this
pointer to work properly)
it needs some indirection:
class CBeautyDlg {
void ::realMouse(int events, int x, int y, int flag) {
// your event handling code
}
// static wrapper (does NOT need "this")
static void ::onMouse(int events, int x, int y, int flag, void* me) {
CBeautyDlg * that = (CBeautyDlg *)(me); // cast back to proper class
that->realMouse(events, x, y, flag); // call class member
}
void OnBnClickedButton6() {
...
setMouseCallback("myshowWnd", onMouse, (void*)this); // "this" goes into the userdata !
}
};
3 | No.3 Revision |
it wants a static function as mouse callback, while you have a class member function (which would need the classe's this
pointer to work properly)
it needs some indirection:
class CBeautyDlg {
void ::realMouse(int events, int x, int y, int flag) {
// your event handling code
}
// static wrapper (does NOT need "this")
static void ::onMouse(int events, int x, int y, int flag, void* me) {
CBeautyDlg * that = (CBeautyDlg *)(me); // cast back to proper class
that->realMouse(events, x, y, flag); // call class member
}
void OnBnClickedButton6() {
...
setMouseCallback("myshowWnd", onMouse, (void*)this); // "this" goes into the userdata !
(void*)this);
}
};
4 | No.4 Revision |
it wants a static function as mouse callback, while you have a class member function (which would need the classe's this
pointer to work properly)
it needs some indirection:
class CBeautyDlg {
void ::realMouse(int events, int x, int y, int flag) {
// your event handling code
}
// static wrapper (does NOT need "this")
static void ::onMouse(int events, int x, int y, int flag, void* me) {
// "me" is, what we fed into setMouseCallback() below:
CBeautyDlg * that = (CBeautyDlg *)(me); // cast back to proper class
that->realMouse(events, x, y, flag); // call class member
}
void OnBnClickedButton6() {
...
setMouseCallback("myshowWnd", onMouse, (void*)this);
}
};
5 | No.5 Revision |
it wants a static function as mouse callback, while you have a class member function (which would need the classe's this
pointer to work properly)
it needs some indirection:
class CBeautyDlg {
void ::realMouse(int realMouse(int events, int x, int y, int flag) {
// your event handling code
}
// static wrapper (does NOT need "this")
static void ::onMouse(int onMouse(int events, int x, int y, int flag, void* me) {
// "me" is, what we fed into setMouseCallback() below:
CBeautyDlg * that = (CBeautyDlg *)(me); // cast back to proper class
that->realMouse(events, x, y, flag); // call class member
}
void OnBnClickedButton6() {
...
setMouseCallback("myshowWnd", onMouse, (void*)this);
}
};