UEZ Posted February 7, 2011 Share Posted February 7, 2011 (edited) Is there a better and smoother way to scale label as I did in the code below? expandcollapse popup#include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Test", 800, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX)) Global $group = GUICtrlCreateGroup("", 224, 0, 569, 92) Global $title = GUICtrlCreateLabel("Scale this label dynamically ", 228, 14, 559, 75) GUICtrlSetColor(-1, 0x000080) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Resize_Font() Global $aWDim = WinGetPos($hGUI) Global $w = $aWDim[2], $h = $aWDim[3] GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE Resize_Font() EndSwitch WEnd Func Resize_Font() $aPOS = ControlGetPos("", "", $group) GUICtrlSetFont($title, $aPOS[2] / 16, 400, 0, "Impact") EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Resize_Font() Return "GUI_RUNDEFMSG" EndFunc Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $w) ; min X DllStructSetData($minmaxinfo, 8, $h) ; min Y Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO What I want is when I resize the window the label should be scaled appropriately with group control size that it fits to the group control as when starting the code. Any suggestions? Br, UEZ Edited August 30, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
guinness Posted February 7, 2011 Share Posted February 7, 2011 (edited) Ignore, I got it wrong! Sorry. Edited February 7, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
bogQ Posted February 7, 2011 Share Posted February 7, 2011 Did not understand 100%, did you mean something like GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM) TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
UEZ Posted February 7, 2011 Author Share Posted February 7, 2011 I tried it also with GUI_DOCK* but is not working properly. The width and height of label will become larger than the group control size and further it is not scaling smoothly. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
bogQ Posted February 7, 2011 Share Posted February 7, 2011 (edited) Hell if i know what i am dooing expandcollapse popup#include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Test", 900, 250, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX)) Global $group = GUICtrlCreateGroup("", 224, 0, 600, 100) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM) Global $title = GUICtrlCreateLabel("Scale this label dynamically ", 226, 14, 589, 75) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM) GUICtrlSetColor(-1, 0x000080) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Resize_Font() Global $aWDim = WinGetPos($hGUI) Global $w = $aWDim[2], $h = $aWDim[3] GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $pos = ControlGetPos($hGUI, "", $group) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE Resize_Font() EndSwitch WEnd Func Resize_Font() $aPOS = ControlGetPos("", "", $group) If $aPOS[2] / $aPOS[3] < 6 Then GUICtrlSetFont($title, $aPOS[2] / 16, 400, 0, "Impact") Else GUICtrlSetFont($title, (($aPOS[2] / 16)-(($aPOS[2] / $aPOS[3])-6)*6)-(($aPOS[2]-600)*0.0025)+0.0025, 400, 0, "Impact") EndIf EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Resize_Font() Return "GUI_RUNDEFMSG" EndFunc Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $w) ; min X DllStructSetData($minmaxinfo, 8, $h) ; min Y Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO At least il get order for bravery even if thats not it I did change some sizes and positions Edit: your problem is that font is ower the limit? or only not scaling smoothly is problem? Edited February 7, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
UEZ Posted February 7, 2011 Author Share Posted February 7, 2011 (edited) Thanks bogQ for you version! I will have a closer look tomorrow.Meanwhile I got a new idea but the scaling within the group control is not working properly:expandcollapse popup#include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 800, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_MAXIMIZEBOX)) Global $group = GUICtrlCreateGroup("", 224, 0, 569, 92) Global $pic = GUICtrlCreatePic("", 226, 8, 565, 82) GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER) GUICtrlCreateGroup("", -99, -99, 1, 1) $hBmp = CreateLogo("Label soll sich dyn. anpassen", "Impact") Global Const $STM_SETIMAGE = 0x0172 GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBmp) GUISetState(@SW_SHOW) Global $aWDim = WinGetPos($hGUI) Global $w = $aWDim[2], $h = $aWDim[3] GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp) GUIDelete($hGUI) _GDIPlus_Shutdown() Exit Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE EndSwitch WEnd Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $w) ; min X DllStructSetData($minmaxinfo, 8, $h) ; min Y Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO Func CreateLogo($text, $fname, $fsize = 60, $brushcolor = 0xFF000080) Local $hBrush = _GDIPlus_BrushCreateSolid($brushcolor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $tLayout = _GDIPlus_RectFCreate (0, 0, 0, 0) Local $hFamily = _GDIPlus_FontFamilyCreate($fname) Local $hFont = _GDIPlus_FontCreate ($hFamily, $fsize, 0) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle(AutoItWinGetTitle())) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $text, $hFont, $tLayout, $hFormat) Local $width = Floor(DllStructGetData($aInfo[0], "Width") * 0.98) Local $height = Floor(DllStructGetData($aInfo[0], "Height") * 0.925) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($width, $height) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hContext, 2) _GDIPlus_GraphicsClear($hContext, "0xFF" & Hex(_WinAPI_GetSysColor($COLOR_3DFACE), 6)) _GDIPlus_GraphicsDrawStringEx ($hContext, $text, $hFont, $aInfo[0], $hFormat, $hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) _GDIPlus_GraphicsDispose ($hContext) Local $hImage = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_ImageDispose($hBitmap) Return $hImage EndFunc Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0If I could position the label (pic) within the group control it would be great.This was what I was looking for!Last little issue is the ugly looking label... Now it looks better but can it be still look better?Br,UEZ Edited February 8, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now