Just one small problem: as you can see, i highlighted the label specialy to see the real lenght of the text, it seems that it's a little longer then it should be. Any ideas why, or how to fix it correctly?

Share this post

Link to post

Share on other sites

Details 0

Details 0

cs_message("This should do the trick, it is a little thinking outside the box...")
cs_message("You can do whatever you want...",12)
cs_message("Thanks to the person who wrote it... it wasn't me...",8.5)
cs_message("Nice Work!",128,5000,0x0000ff00)Func cs_message($cs_tekst,$cs_font_grootte=18,$cs_sleep=3000,$cs_kleur=0xc6d6fd)If$cs_font_grootte=""Then$cs_font_grootte=18If$cs_kleur=""Then$cs_kleur=0xc6d6fd;default is Details! blauwLocal$cs_lengte=_GetTextLen($cs_tekst,"Arial",$cs_font_grootte,400)Local$cs_venster=GUICreate("Message",$cs_lengte+25,$cs_font_grootte+80,@DesktopWidth/2-($cs_lengte+25)/2,@DesktopHeight/2-($cs_font_grootte+80)/2-50,0x00000200,0x00020000);, $DS_SETFOREGROUND, $WS_EX_STATICEDGE)GUISetBkColor($cs_kleur)$mededeling=GUICtrlCreateLabel($cs_tekst,10,20,$cs_lengte,$cs_font_grootte+75)GUICtrlSetFont(-1,$cs_font_grootte)GUISetState(@SW_SHOW)WinSetOnTop($cs_venster,"",1)Sleep($cs_sleep)GUIDelete($cs_venster)EndFunc;==>cs_messageFunc_GetTextLen($s_WinText,$s_TextFont,$i_FontSize,$i_FontWeight=-1)LocalConst$DEFAULT_CHARSET=0; ANSI character setLocalConst$OUT_CHARACTER_PRECIS=2LocalConst$CLIP_DEFAULT_PRECIS=0LocalConst$PROOF_QUALITY=2LocalConst$FIXED_PITCH=1LocalConst$RGN_XOR=3LocalConst$LOGPIXELSY=90$h_WinTitle="Get Label Width"If$i_FontWeight=""Or$i_FontWeight=-1Then$i_FontWeight=400; default Font weightLocal$h_GUI=GUICreate($h_WinTitle,10,10,-100,-100,0x80880000,0x00000080)Local$hDC=DllCall("user32.dll","int","GetDC","hwnd",$h_GUI)Local$intDeviceCap=DllCall("gdi32.dll","long","GetDeviceCaps","int",$hDC[0],"long",$LOGPIXELSY)$intDeviceCap=$intDeviceCap[0]Local$intFontHeight=DllCall("kernel32.dll","long","MulDiv","long",$i_FontSize,"long",$intDeviceCap,"long",72)$intFontHeight=-$intFontHeight[0]Local$hMyFont=DllCall("gdi32.dll","hwnd","CreateFont","int",$intFontHeight,_"int",0,"int",0,"int",0,"int",$i_FontWeight,"int",0,_"int",0,"int",0,"int",$DEFAULT_CHARSET,_"int",$OUT_CHARACTER_PRECIS,"int",$CLIP_DEFAULT_PRECIS,_"int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$s_TextFont)DllCall("gdi32.dll","hwnd","SelectObject","int",$hDC[0],"hwnd",$hMyFont[0])Local$res=DllStructCreate("int;int")Local$ret=DllCall("gdi32.dll","int","GetTextExtentPoint32","int",$hDC[0],"str",$s_WinText,"long",StringLen($s_WinText),"ptr",DllStructGetPtr($res))Local$intLabelWidth=DllStructGetData($res,1)GUIDelete($h_GUI)Return$intLabelWidthEndFunc;==>_GetTextLen