[MFC]probeme avec infos bulle
salut, pour non application je dois utiliser des info bulle.
voici comment je les ai codé:
dans myVyew.h j'ai mis:
Code:
1 2 3
|
CToolTipCtrl* tool ; //On definie une variable pour l'info bulle
char* text;//contiendra le message à afficher |
dans le constructeur de mon cpp, j'ai mis:
Code:
1 2 3
|
text=new char[256]; //la taille max. du message qui sera affiché dans ta tooltip
tool=new CToolTipCtrl(); |
dans la fonction oninitialeupdate, j'ai mis:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
tool->Create(this,TTS_ALWAYSTIP|TTF_TRACK|TTF_ABSOLUTE|TTF_IDISHWND );
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
ti.hwnd = this->m_hWnd;
ti.uId = (UINT)AfxGetMainWnd()->m_hWnd;
ti.hinst = AfxGetInstanceHandle();
ti.lpszText = LPSTR_TEXTCALLBACK;
ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0;
tool->SendMessage(TTM_ADDTOOL,0,(LPARAM)&ti);
tool->SendMessage(TTM_TRACKACTIVATE,(WPARAM)true,(LPARAM)&ti);
tool->SendMessage(TTM_SETMAXTIPWIDTH,0,(LPARAM)SHRT_MAX);
tool->SendMessage(TTM_SETDELAYTIME,(WPARAM)TTDT_AUTOPOP,(LPARAM)(INT) MAKELONG(SHRT_MAX,0));
tool->SendMessage(TTM_SETDELAYTIME,(WPARAM)TTDT_INITIAL,(LPARAM)(INT) MAKELONG(200,0));
tool->SendMessage(TTM_SETDELAYTIME,(WPARAM)TTDT_RESHOW ,(LPARAM)(INT) MAKELONG(200,0));
tool->EnableTrackingToolTips(true);
tool->EnableToolTips(true);
tool->Activate(true); |
et enfin je met ce code dans la fonction OnMouseMove pour que l'info bulle s'affiche dés que je laisse ma souris plus de trois seconde sur le même pixel:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
int ng;
DC=GetWindowDC();
ng=Calcul_ng(point);
sprintf(text,"x=%d\r\ny=%d\r\nng=%d",point.x,point.y,ng);
CPoint p=point;
ClientToScreen(&p);
tool->SendMessage(TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(p.x+20,p.y+20));
//le +20 c'est à décaler l'affichage à côté du curseur et pas pile dessous// Invalidate(true); |
le probleme, c'est que mon info bulle apparait dès que je pointe sur le pixel et il n'y a pas un temps d'atente de trois seconde.j'ai bien essayer de changer des parametre des fonctions tool->SendMessage(TTM_SETDELAYTIME,(WPARAM)TTDT_AUTOPOP,(LPARAM)(INT) MAKELONG(SHRT_MAX,0)) mais ca ne change rien.
De plus si je sort la souris de ma fenetre, l'info bulle reste afficher a la derniere position ou ma souris etait dns le fenetre.
Est ce que qulqu'un saurait comment je pourrait resudre mes probleme, car j'ai regarder dans la FAQ mais je n'est pas trouver de solution a mes probleme.