Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: carriage return line feed tooltip balloon dialog multiple
;ToolTip control ;Guido 09/2002 - Made into UDF's Iain Dickason 1/2003 ;Baloon tooltips Guido 01/03 ;Multiline tooltips Guido 03/03 ;Ref: ;http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/tooltip/reflist.asp ;------------------------------------------------------------------------------; ;TTCreate : Creates a tool window ; ;------------------------------------------------------------------------------; ;dlghandle : wil dialog handle ; ;balloon : @true baloon tooltips (Comctl32.dll v.5.8 Internet Explorer 5) ; ; @false normal tooltips ; ;------------------------------------------------------------------------------; ;Returns : tool window handle ; ;------------------------------------------------------------------------------; #DefineFunction TTCreate(dlghandle,balloon) if balloon then TTS_BALLOON=64 else TTS_BALLOON=0 ICC_BAR_CLASSES=4 WM_USER=1024 WS_POPUP=2147483648 WS_EX_TOPMOST=8 HWND_TOPMOST=-1 ICC_BAR_CLASSES=4 USEDEFAULT=2147483648 TTS_ALWAYSTIP=1 TTS_NOPREFIX=2 TTF_SUBCLASS=16 TTF_IDISHWND=1 TTM_ADDTOOL=WM_USER+4 SWP_NOSIZE=1 SWP_NOMOVE=2 SWP_NOACTIVATE=16 user32=DllLoad(StrCat(DirWindows(1),"user32.dll")) hinst=DllHinst("") ;init common controls COMMONCONTROLSEX=BinaryAlloc(8) BinaryPoke4(COMMONCONTROLSEX,0,8) BinaryPoke4(COMMONCONTROLSEX,4,ICC_BAR_CLASSES) comctl32=StrCat(DirWindows(1),"comctl32.dll") r=DllCall(comctl32,long:"InitCommonControlsEx",lpbinary:COMMONCONTROLSEX) BinaryFree(COMMONCONTROLSEX) ;create toolwindow htt=DllCall(user32,long:"CreateWindowExA",long:WS_EX_TOPMOST,lpstr:"tooltips_class32",lpstr:"",long:WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP|TTS_BALLOON,long:USEDEFAULT,long:USEDEFAULT,long:USEDEFAULT,long:USEDEFAULT,long:dlghandle,long:0,long:hinst,long:0) DllCall(user32,long:"SetWindowPos",long:htt,long:HWND_TOPMOST,long:0,long:0,long:0,long:0,long:SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE) dllfree(user32) Return htt #EndFunction ;------------------------------------------------------------------------; ;TTAdd : Adds a tooltip to a control ; ;------------------------------------------------------------------------; ;htt : tool window handle returned by TTCreate() ; ;dlghandle : the handle of the dialog (passed from the dialog callback) ; ;ctrlid : real control id obtained with roboscripter ; ;text : the text to display as the tooltip ; ;------------------------------------------------------------------------; ;Returns : Returns TRUE if successful, or FALSE otherwise. ; ;------------------------------------------------------------------------; #DefineFunction TTAdd(htt,dlghandle,ctrlid,text) WM_USER=1024 TTM_ADDTOOL=WM_USER+4 TTF_SUBCLASS=16 user32=DllLoad(StrCat(DirWindows(1),"user32.dll")) hinst=DllHinst("") RECT=BinaryAlloc(16) ;get control handle ctrhandle=dllcall(user32,long:"GetDlgItem",long:dlghandle,long:ctrlid) ;get button location DllCall(user32,long:"GetClientRect",long:ctrhandle,lpbinary:RECT) ;tooltip text textbuf=BinaryAlloc(StrLen(text)+1) BinaryPokeStr(textbuf,0,text) textad=IntControl(42,textbuf,0,0,0) ;fill structure TOOLINFO=BinaryAlloc(44) BinaryPoke4(TOOLINFO,0,44) ;cbSize BinaryPoke4(TOOLINFO,4,TTF_SUBCLASS) ;uFlags BinaryPoke4(TOOLINFO,8,ctrhandle) ;hwnd BinaryPoke4(TOOLINFO,12,0) ;uId BinaryPoke4(TOOLINFO,16,BinaryPeek4(RECT,0)) ;rect.left BinaryPoke4(TOOLINFO,20,BinaryPeek4(RECT,4)) ;rect.top BinaryPoke4(TOOLINFO,24,BinaryPeek4(RECT,8)) ;rect.right BinaryPoke4(TOOLINFO,28,BinaryPeek4(RECT,12));rect.bottom BinaryPoke4(TOOLINFO,32,hinst) ;hinst BinaryPoke4(TOOLINFO,36,textad) ;lpszText BinaryPoke4(TOOLINFO,40,0) ;lParam ;add tooltip r=DllCall(user32,long:"SendMessageA",long:htt,long:TTM_ADDTOOL,long:0,lpbinary:TOOLINFO) DllFree(user32) BinaryFree(RECT) BinaryFree(TOOLINFO) Return r #EndFunction ;--------------------------------------------------------------------------------; ;TTSetMaxTipWidth : Sets the maximum width for a ToolTip window. ; ; Use this function only if you want a multiline tooltip. ; ;--------------------------------------------------------------------------------; ;htt : tool window handle ; ;width : Maximum ToolTip window width to be set. ; ;--------------------------------------------------------------------------------; ;Returns : The previous maximum ToolTip width. ; ;--------------------------------------------------------------------------------; ;Remarks : The maximum ToolTip width value does not indicate a ToolTip window's ; ;actual width. Rather, if a ToolTip string exceeds the maximum width, the control; ;breaks the text into multiple lines, using spaces to determine line breaks. ; ;If the text cannot be segmented into multiple lines, it will be displayed on a ; ;single line. The length of this line may exceed the maximum ToolTip width. ; ; ; ;Note : you can force a line break with a @crlf , use strcat() ; ;--------------------------------------------------------------------------------; #definefunction TTSetMaxTipWidth(htt,width) user32=StrCat(DirWindows(1),"user32.dll") TTM_SETMAXTIPWIDTH=1024+24 return dllcall(user32,long:"SendMessageA",long:htt,long:TTM_SETMAXTIPWIDTH,long:0,long:width) #endfunction ;========================================== ;TEST ; ;DIALOG CALLBACK #DefineSubRoutine dialogproc(handle,DialogMessage,DialogControlID,p4,p5) Switch DialogMessage Case 0 ;Init DialogProcOptions(handle,2,1) ;Push buttons ;create tool window htt=TTCreate(handle,0) ;balloon ;set max width (just if you want a multiline tooltip) TTSetMaxTipWidth(htt,20) ;add tips TTAdd(htt,handle,100,"This will close the dialog") ;force line brake TTAdd(htt,handle,101,strcat("A",@crlf,"nd this will cancel it")) Break Case 2 ;Button pushed Switch DialogControlID Case 1 ;OK Return -1 Break Case 2 ;cancel Return -2 Break EndSwitch EndSwitch Return -1 #EndSubRoutine ;DIALOG MyDialogFormat=`WWWDLGED,6.1` MyDialogCaption=`ToolTip Control` MyDialogX=-1 MyDialogY=-1 MyDialogWidth=234 MyDialogHeight=098 MyDialogNumControls=002 MyDialogProcedure=`dialogproc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialog001=`053,077,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`145,077,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog") ;END SCRIPT
Article ID: W15452
File Created: 2014:07:18:09:50:36
Last Updated: 2014:07:18:09:50:36