IonicWind Software

IWBasic => General Questions => Topic started by: Andy on May 05, 2012, 01:08:55 AM

Title: Tooltip fonts and sizes
Post by: Andy on May 05, 2012, 01:08:55 AM
Hi,

Was just wondering if it's possible to set the font and size of text in a tooltip?

hTooltip = ToolTipControl(e1,@TTS_ALWAYSTIP|@TTS_BALLOON,0) 
ttAddTool hTooltip,@TTF_SUBCLASS|@TTF_IDISHWND,GetControlHandle(e1,button_901),hTooltip,"Tip1"
ttAddTool hTooltip,@TTF_SUBCLASS|@TTF_IDISHWND,GetControlHandle(e1,button_3),hTooltip,"Tip2"
ttAddTool hTooltip,@TTF_SUBCLASS|@TTF_IDISHWND,GetControlHandle(e1,button_454),hTooltip,"Tip3"

If so how do I change the above for example to:
"Arial" font size 12?

Thanks,
Andy.
Title: Re: Tooltip fonts and sizes
Post by: LarryMc on May 05, 2012, 08:58:58 AM
$include "windowssdk.inc"
window form
LOGFONT lf
int height, weight
uint hdc,font,oldfont
'main form window
OpenWindow form,2,51,400,400,@size,0,"",&main
centerwindow form
CONTROL form, @button, "test", 40, 40, 80, 30, 0, 444
hTooltip = ToolTipControl(form,@TTS_ALWAYSTIP|@TTS_BALLOON,0) 
ttAddTool hTooltip,@TTF_SUBCLASS|@TTF_IDISHWND,GetControlHandle(form,444),hTooltip,"Tip1"
height=20
weight =700
ZeroMemory(lf,LEN(LOGFONT))
lstrcpynA(lf.lfFaceName,"Arial",32)
hdc = GetHDC(form)
lf.lfHeight = -MulDiv(height,GetDeviceCaps(hdc,90 /*LOGPIXELSY*/),72)
lf.lfWeight = weight
lf.lfQuality = 1 /*DRAFT_QUALITY*/
lf.lfPitchAndFamily = 0 /*DRAFT_PITCH*/
lf.lfItalic = 1
lf.lfUnderline = 1
lf.lfStrikeOut = 1
font = CreateFontIndirectA(lf)
oldfont = SendMessageA(hTooltip,WM_GETFONT,0,0)
SendMessageA(hTooltip,WM_SETFONT,NULL,0)
SendMessageA(hTooltip,WM_SETFONT,font,1)
IF(oldfont) THEN DeleteObject(oldfont)
ReleaseHDC(form,hdc)
waituntil form=0
end

SUB main(),int
    select @MESSAGE
case @IDCLOSEWINDOW
        CLOSEWINDOW form
    ENDselect
RETURN 0
ENDSUB


LarryMc
Title: Re: Tooltip fonts and sizes
Post by: Andy on May 05, 2012, 10:58:43 PM
Larry,

You are a star again!

I was on the right track, but that's great - works well.

Thanks,
Andy.
:)