The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: minor28 on May 17, 2010, 11:05:51 AM

Title: Listview tooltip problem
Post by: minor28 on May 17, 2010, 11:05:51 AM
I have been struggling to get a tooltips control to work with a listview control but not succeeded to do it as I want. The code below is working with commenting the line (2) and no matter how the other lines (1) or (3) are commented.

However if I want to retrieve the text with LPSTR_TEXTCALLBACK the listview will not resieve any TTN_NEEDTEXT notification messages.

Can someone see if I am missing something?


Main dialog window with a listview control

.if eax==WM_INITDIALOG
invoke CreateWindowEx,WS_EX_TOPMOST,offset szToolTipClass,0,WS_POPUP or TTS_NOPREFIX or TTS_BALLOON,
0,0,0,0,hWin,0,hInstance,0
mov hTT,eax

invoke GetDlgItem,hWin,1002
mov hLSV,eax

;(1) invoke SendMessage,hLSV,LVM_SETTOOLTIPS,0,hTT

invoke SendMessage,hLSV,LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES,
LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES

invoke SetWindowLong,hLSV,GWL_WNDPROC,offset LSVWinProc
mov OldLSVWinProc,eax

mov ti.cbSize,sizeof ti
mov ti.uFlags,TTF_SUBCLASS
push hLSV
pop ti.hWnd
mov ti.uId,0
invoke GetClientRect,hLSV,addr rect
push rect.left
pop ti.rect.left
push rect.top
pop ti.rect.top
push rect.right
pop ti.rect.right
push rect.bottom
pop ti.rect.bottom
mov ti.lpszText,offset szTooltip
;(2) mov ti.lpszText,LPSTR_TEXTCALLBACK
invoke SendMessage,hTT,TTM_ADDTOOL,0,addr ti



LSVWinProc

.if eax==WM_NOTIFY
mov edi,lParam
.if [edi].TOOLTIPTEXT.hdr.code==TTN_NEEDTEXT
mov [edi].TOOLTIPTEXT.hInst,0
mov [edi].TOOLTIPTEXT.lpszText,offset szTooltip
;(3) invoke CallWindowProc,OldLSVWinProc,hWin,uMsg,wParam,lParam
; ret

.else
invoke CallWindowProc,OldLSVWinProc,hWin,uMsg,wParam,lParam
ret
.endif
.else
invoke CallWindowProc,OldLSVWinProc,hWin,uMsg,wParam,lParam
ret

.endif
xor eax,eax
ret



Thanks
Title: Re: Listview tooltip problem
Post by: Gunner on May 17, 2010, 02:24:29 PM
using dialog boxes you don't use callwindowproc, you return true if you process the message and false to let the dialog manager process the message..  i'm not at a computer to look at my code, but i think that is right   
Title: Re: Listview tooltip problem
Post by: qWord on May 17, 2010, 03:30:31 PM
maybe I misunderstood what are you tyring to do,
but you you can set the LVS_EX_INFOTIP (http://msdn.microsoft.com/en-us/library/bb774732(v=VS.85).aspx) style for the listview, so that the parent then receives the LVN_GETINFOTIPA/W (http://msdn.microsoft.com/en-us/library/bb774835(v=VS.85).aspx) notification message.This gives you the ability to specific a string to be shown as a tooltip.

qword
Title: Re: Listview tooltip problem
Post by: minor28 on May 17, 2010, 04:07:04 PM
As I understand the listview default tooltip LVS_EX_INFOTIP only works on the first column. I want it to work over the whole client rectangle.
Title: Re: Listview tooltip problem
Post by: qWord on May 18, 2010, 01:13:41 AM
I've played a bit with it and found, that tool tip controll allways send the TTN_NEEDTEXTW/TTN_GETDISPINFOW message - the ANSI version is never send (all controlls are created with ANSI functions).
In the attachmend you will find an full working example (on vista32  :P)
regards qWord
Title: Re: Listview tooltip problem
Post by: minor28 on May 18, 2010, 06:42:16 AM
Thanks. The W did it.