April 27, 2024, 10:11:32 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Tooltip fonts and sizes

Started by Andy, May 05, 2012, 01:08:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

$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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Larry,

You are a star again!

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

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.