Sign in to follow this  
Followers 0
KaFu

GUISwitch(0)

8 posts in this topic

#1 ·  Posted (edited)

HiHo Forum :),

I searched for a way to make a GUI DPI aware and found the excellent function _GetDPI() by Phillip123Adams. Now of course I'm lazy and wanted to write a respective wrapper for GUICtrlSetFont() and GUISetFont().

But how to obtain the handle of the "current" window? I just tried GUISwitch(0) in the function _GUISetFont_Ex() and it seems to work ;). Is this call okay, or are there any constraints I have to take into account?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $i_DPI_Ratio = _GetDPI()
$i_DPI_Ratio = $i_DPI_Ratio[2]

GUICreate("My GUI")
_GUISetFont_Ex(14, 400, 0, 'Arial')
GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 380, 380)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()


;; GetDPI.au3
;;
;; Get the current DPI (dots per inch) setting, and the ratio
;; between it and approximately 96 DPI.
;;
;; Author: Phillip123Adams
;; Posted: August, 17, 2005, originally developed 10/17/2004,
;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~   ;; Example
;~  #include<guiconstants.au3>
;~   ;;
;~   ;; Get the current DPI.
;~  $a1 = _GetDPI()
;~  $iDPI = $a1[1]
;~  $iDPIRat = $a1[2]
;~   ;;
;~   ;; Design the GUI to show how to apply the DPI adjustment.
;~  GUICreate("Applying DPI to GUI's", 250 * $iDPIRat, 120 * $iDPIRat)
;~  $lbl = GUICtrlCreateLabel("The current DPI value is " & $iDPI &@lf& "Ratio to 96 is " & $iDPIRat &@lf&@lf& "Call function _GetDPI.  Then multiply all GUI dimensions by the returned value divided by approximately 96.0.", 10 * $iDPIRat, 5 * $iDPIRat, 220 * $iDPIRat, 80 * $iDPIRat)
;~  $btnClose = GUICtrlCreateButton("Close", 105 * $iDPIRat, 90 * $iDPIRat, 40 * $iDPIRat, 20 * $iDPIRat)
;~  GUISetState()
;~   ;;
;~  while 1
;~   $iMsg = GUIGetMsg()
;~   If $iMsg = $GUI_EVENT_CLOSE or $iMsg = $btnClose then ExitLoop
;~  WEnd
;~  Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _GetDPI()
    ;; Get the current DPI (dots per inch) setting, and the ratio between it and
    ;; approximately 96 DPI.
    ;;
    ;; Retrun a 1D array of dimension 3.  Indices zero is the dimension of the array
    ;; minus one.  Indices 1 = the current DPI (an integer).  Indices 2 is the ratio
    ;; should be applied to all GUI dimensions to make the GUI automatically adjust
    ;; to suit the various DPI settings.
    ;;
    ;; Author: Phillip123Adams
    ;; Posted: August, 17, 2005, originally developed 6/04/2004,
    ;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
    ;;
    ;; Note: The dll calls are based upon code from the AutoIt3 forum from a post
    ;; by this-is-me on Nov 23 2004, 10:29 AM under topic "@Larry, Help!"  Thanks
    ;; to this-is-me and Larry.  Prior to that, I was obtaining the current DPI
    ;; from the Registry:
    ;;    $iDPI = RegRead("HKCU\Control Panel\Desktop\WindowMetrics", "AppliedDPI")
    ;;

    Local $a1[3]
    Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0
    Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd)
    Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy)
    Local $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC)
    $iDPI = $aRet[0]
    ;; Set a ratio for the GUI dimensions based upon the current DPI value.
    Select
        Case $iDPI = 0
            $iDPI = 96
            $iDPIRat = 94
        Case $iDPI < 84
            $iDPIRat = $iDPI / 105
        Case $iDPI < 121
            $iDPIRat = $iDPI / 96
        Case $iDPI < 145
            $iDPIRat = $iDPI / 95
        Case Else
            $iDPIRat = $iDPI / 94
    EndSelect
    $a1[0] = 2
    $a1[1] = $iDPI
    $a1[2] = $iDPIRat
    ;; Return the array
    Return $a1
EndFunc   ;==>_GetDPI

Func _GUICtrlSetFont_Ex($icontrolID = -1, $iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $iquality = 2)
    GUICtrlSetFont($icontrolID, $iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality)
EndFunc   ;==>_GUICtrlSetFont_Ex

Func _GUISetFont_Ex($iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $hWnd = Default, $iquality = 2)
    If Not IsHWnd($hWnd) Then $hWnd = GUISwitch(0)
    GUISetFont($iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $hWnd, $iquality)
EndFunc   ;==>_GUISetFont_Ex
Edited by KaFu
1 person likes this

Share this post


Link to post
Share on other sites



KaFu,

But how to obtain the handle of the "current" window?

What is wrong with WinGetHandle("[ACTIVE]") to get the handle of the active GUI? It has always worked for me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

What is wrong with WinGetHandle("[ACTIVE]") to get the handle of the active GUI? It has always worked for me. :idiot:

That's the active window, but not necessarily the "current" autoit window in the context of GUI creation.

What's wondering me a little more is that the handle returned by GuiSwitch(0) $hWnd is 0 :). Nevertheless it works, replace the $hwnd in GUISetFont() with 0 and you'll see that the font is not applied ;):idiot: ... something going on under the hood? I guess it's somehow related to the GuiSwitch() discussion in the Devs Forum some time again... have to look it up again.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $i_DPI_Ratio = _GetDPI()
$i_DPI_Ratio = $i_DPI_Ratio[2]

GUICreate("My GUI")
_GUISetFont_Ex(14, 400, 0, 'Arial')
GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 380, 380)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()


;; GetDPI.au3
;;
;; Get the current DPI (dots per inch) setting, and the ratio
;; between it and approximately 96 DPI.
;;
;; Author: Phillip123Adams
;; Posted: August, 17, 2005, originally developed 10/17/2004,
;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~   ;; Example
;~  #include<guiconstants.au3>
;~   ;;
;~   ;; Get the current DPI.
;~  $a1 = _GetDPI()
;~  $iDPI = $a1[1]
;~  $iDPIRat = $a1[2]
;~   ;;
;~   ;; Design the GUI to show how to apply the DPI adjustment.
;~  GUICreate("Applying DPI to GUI's", 250 * $iDPIRat, 120 * $iDPIRat)
;~  $lbl = GUICtrlCreateLabel("The current DPI value is " & $iDPI &@lf& "Ratio to 96 is " & $iDPIRat &@lf&@lf& "Call function _GetDPI.  Then multiply all GUI dimensions by the returned value divided by approximately 96.0.", 10 * $iDPIRat, 5 * $iDPIRat, 220 * $iDPIRat, 80 * $iDPIRat)
;~  $btnClose = GUICtrlCreateButton("Close", 105 * $iDPIRat, 90 * $iDPIRat, 40 * $iDPIRat, 20 * $iDPIRat)
;~  GUISetState()
;~   ;;
;~  while 1
;~   $iMsg = GUIGetMsg()
;~   If $iMsg = $GUI_EVENT_CLOSE or $iMsg = $btnClose then ExitLoop
;~  WEnd
;~  Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _GetDPI()
    ;; Get the current DPI (dots per inch) setting, and the ratio between it and
    ;; approximately 96 DPI.
    ;;
    ;; Retrun a 1D array of dimension 3.  Indices zero is the dimension of the array
    ;; minus one.  Indices 1 = the current DPI (an integer).  Indices 2 is the ratio
    ;; should be applied to all GUI dimensions to make the GUI automatically adjust
    ;; to suit the various DPI settings.
    ;;
    ;; Author: Phillip123Adams
    ;; Posted: August, 17, 2005, originally developed 6/04/2004,
    ;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
    ;;
    ;; Note: The dll calls are based upon code from the AutoIt3 forum from a post
    ;; by this-is-me on Nov 23 2004, 10:29 AM under topic "@Larry, Help!"  Thanks
    ;; to this-is-me and Larry.  Prior to that, I was obtaining the current DPI
    ;; from the Registry:
    ;;    $iDPI = RegRead("HKCU\Control Panel\Desktop\WindowMetrics", "AppliedDPI")
    ;;

    Local $a1[3]
    Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0
    Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd)
    Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy)
    Local $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC)
    $iDPI = $aRet[0]
    ;; Set a ratio for the GUI dimensions based upon the current DPI value.
    Select
        Case $iDPI = 0
            $iDPI = 96
            $iDPIRat = 94
        Case $iDPI < 84
            $iDPIRat = $iDPI / 105
        Case $iDPI < 121
            $iDPIRat = $iDPI / 96
        Case $iDPI < 145
            $iDPIRat = $iDPI / 95
        Case Else
            $iDPIRat = $iDPI / 94
    EndSelect
    $a1[0] = 2
    $a1[1] = $iDPI
    $a1[2] = $iDPIRat
    ;; Return the array
    Return $a1
EndFunc   ;==>_GetDPI

Func _GUICtrlSetFont_Ex($icontrolID = -1, $iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $iquality = 2)
    GUICtrlSetFont($icontrolID, $iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality)
EndFunc   ;==>_GUICtrlSetFont_Ex

Func _GUISetFont_Ex($iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $hWnd = Default, $iquality = 2)
    If Not IsHWnd($hWnd) Then $hWnd = GUISwitch(0)
    ConsoleWrite("GUISwitch(0)" & @TAB & $hWnd & @TAB & WinGetTitle($hWnd) & @CRLF)
    ConsoleWrite("WinGetHandle([ACTIVE])" & @TAB & WinGetHandle("[ACTIVE]") & @TAB & WinGetTitle(WinGetHandle("[ACTIVE]")) & @CRLF)
    GUISetFont($iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $hWnd, $iquality)
EndFunc   ;==>_GUISetFont_Ex
Edited by KaFu

Share this post


Link to post
Share on other sites

GUISwitch is supposed to use the Window handle as the calling parameter.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

GUISwitch is supposed to use the Window handle as the calling parameter.

Yeah, I know... but it still works. Replace the $hwnd in above GuiSetFont() call to 0 and you'll see that the custom font is not set.

Share this post


Link to post
Share on other sites

Your call to the _GUISetFont_Ex function is formatted wrong, you never send it the window handle. Here's an update that should work using the function with the Window handle or the Control ID, look for the ; <<<<<<<<<<<< in the code below.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $i_DPI_Ratio = _GetDPI()
$i_DPI_Ratio = $i_DPI_Ratio[2]
$hWnd = GUICreate("My GUI")
_GUISetFont_Ex(14, 400, 0, 'Arial', $hWnd) ; <<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 380, 380)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
;; GetDPI.au3
;;
;; Get the current DPI (dots per inch) setting, and the ratio
;; between it and approximately 96 DPI.
;;
;; Author: Phillip123Adams
;; Posted: August, 17, 2005, originally developed 10/17/2004,
;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~   ;; Example
;~  #include<guiconstants.au3>
;~   ;;
;~   ;; Get the current DPI.
;~  $a1 = _GetDPI()
;~  $iDPI = $a1[1]
;~  $iDPIRat = $a1[2]
;~   ;;
;~   ;; Design the GUI to show how to apply the DPI adjustment.
;~  GUICreate("Applying DPI to GUI's", 250 * $iDPIRat, 120 * $iDPIRat)
;~  $lbl = GUICtrlCreateLabel("The current DPI value is " & $iDPI &@lf& "Ratio to 96 is " & $iDPIRat &@lf&@lf& "Call function _GetDPI.  Then multiply all GUI dimensions by the returned value divided by approximately 96.0.", 10 * $iDPIRat, 5 * $iDPIRat, 220 * $iDPIRat, 80 * $iDPIRat)
;~  $btnClose = GUICtrlCreateButton("Close", 105 * $iDPIRat, 90 * $iDPIRat, 40 * $iDPIRat, 20 * $iDPIRat)
;~  GUISetState()
;~   ;;
;~  while 1
;~   $iMsg = GUIGetMsg()
;~   If $iMsg = $GUI_EVENT_CLOSE or $iMsg = $btnClose then ExitLoop
;~  WEnd
;~  Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _GetDPI()
    ;; Get the current DPI (dots per inch) setting, and the ratio between it and
    ;; approximately 96 DPI.
    ;;
    ;; Retrun a 1D array of dimension 3.  Indices zero is the dimension of the array
    ;; minus one.  Indices 1 = the current DPI (an integer).  Indices 2 is the ratio
    ;; should be applied to all GUI dimensions to make the GUI automatically adjust
    ;; to suit the various DPI settings.
    ;;
    ;; Author: Phillip123Adams
    ;; Posted: August, 17, 2005, originally developed 6/04/2004,
    ;; AutoIT 3.1.1.67 (but earlier v3.1.1 versions with DLLCall should work).
    ;;
    ;; Note: The dll calls are based upon code from the AutoIt3 forum from a post
    ;; by this-is-me on Nov 23 2004, 10:29 AM under topic "@Larry, Help!"  Thanks
    ;; to this-is-me and Larry.  Prior to that, I was obtaining the current DPI
    ;; from the Registry:
    ;;    $iDPI = RegRead("HKCU\Control Panel\Desktop\WindowMetrics", "AppliedDPI")
    ;;
    Local $a1[3]
    Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0
    Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd)
    Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy)
    Local $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC)
    $iDPI = $aRet[0]
    ;; Set a ratio for the GUI dimensions based upon the current DPI value.
    Select
        Case $iDPI = 0
            $iDPI = 96
            $iDPIRat = 94
        Case $iDPI < 84
            $iDPIRat = $iDPI / 105
        Case $iDPI < 121
            $iDPIRat = $iDPI / 96
        Case $iDPI < 145
            $iDPIRat = $iDPI / 95
        Case Else
            $iDPIRat = $iDPI / 94
    EndSelect
    $a1[0] = 2
    $a1[1] = $iDPI
    $a1[2] = $iDPIRat
    ;; Return the array
    Return $a1
EndFunc   ;==>_GetDPI
Func _GUICtrlSetFont_Ex($icontrolID = -1, $iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $iquality = 2)
    GUICtrlSetFont($icontrolID, $iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality)
EndFunc   ;==>_GUICtrlSetFont_Ex
Func _GUISetFont_Ex($iSize = 8.5, $iweight = 400, $iattribute = 0, $sfontname = Default, $hWnd = Default, $iquality = 2)
    If Not IsHWnd($hWnd) Then $hWnd = WinGetHandle($hWnd) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUISwitch($hWnd) ;<<<<<<<<<<<<<<<<<<<<
    ConsoleWrite("GUISwitch(0)" & @TAB & $hWnd & @TAB & WinGetTitle($hWnd) & @CRLF)
    ConsoleWrite("WinGetHandle([ACTIVE])" & @TAB & WinGetHandle("[ACTIVE]") & @TAB & WinGetTitle(WinGetHandle("[ACTIVE]")) & @CRLF)
    GUISetFont($iSize / $i_DPI_Ratio, $iweight, $iattribute, $sfontname, $hWnd, $iquality)
EndFunc   ;==>_GUISetFont_Ex

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

KaFu,

I started a topic about GUISwitch here - is that the one you were thinking of?

Although I an not sure it takes you any closer to a solution. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Your call to the _GUISetFont_Ex function is formatted wrong, you never send it the window handle. Here's an update that should work using the function with the Window handle or the Control ID, look for the ; <<<<<<<<<<<< in the code below.

Your example works because you pass the handle, in my example I try to obtain the handle with GuiSwitch(0) if the $hwnd is not explicitly set but is still = default.

GUISwitch(winhandle)

Success: Returns the handle of the previously current.

Failure: Returns a NULL handle.

So GUISwitch(0) fails and returns a 0... but nevertheless the "internal" handle seems to be correct... or my example in the first post wouldn't work :).

It seems as thought GUIDelete() destroys AutoIts internal handle to the currently active window...

This is what I was looking for, "internal" handle, something undocumented going on under the hood...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0