Jump to content

_GUICtrlRichEdit_SetZoom parameter limitation


loganizzi
 Share

Recommended Posts

If you look at the help file for the above command, you'll see that it states that it only works for certain zoom values (100 and 200 to 6400).   I assume that this is due to an issue in an MSDN library that the command relies on.

After doing some investigating, I noticed that the GUIRichEdit.au3 library file contains the following code:

; #FUNCTION# ====================================================================================================================
; Authors........: Chris Haslam (c.haslam)
; Modified ......:
; ===============================================================================================================================
Func _GUICtrlRichEdit_SetZoom($hWnd, $iPercent)
    If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
    If Not __GCR_IsNumeric($iPercent, ">0") Then Return SetError(1021, 0, False)

    Local $iNumerator, $iDenominator
    Select
        Case Not ($iPercent = 100 Or ($iPercent >= 200 And $iPercent < 6400))
            Return SetError(1022, 0, False)
        Case $iPercent >= 100
            $iNumerator = 10000
            $iDenominator = 10000 / ($iPercent / 100)
        Case Else
            $iNumerator = 10000 * ($iPercent / 100)
            $iDenominator = 10000
    EndSelect
    Return _SendMessage($hWnd, $EM_SETZOOM, $iNumerator, $iDenominator) <> 0
EndFunc   ;==>_GUICtrlRichEdit_SetZoom

Which ensures that values are only within the bounds specified in the help file.    I found that if I comment out the portion of the code that limits the values, the function works fine for most (if not all) values.   I changed the code in the library file to this by simply commenting out the restricting lines of code:

; #FUNCTION# ====================================================================================================================
; Authors........: Chris Haslam (c.haslam)
; Modified ......:
; ===============================================================================================================================
Func _GUICtrlRichEdit_SetZoom($hWnd, $iPercent)
    If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
    If Not __GCR_IsNumeric($iPercent, ">0") Then Return SetError(1021, 0, False)

    Local $iNumerator, $iDenominator
    Select
;       Case Not ($iPercent = 100 Or ($iPercent >= 200 And $iPercent < 6400))
;           Return SetError(1022, 0, False)
        Case $iPercent >= 100
            $iNumerator = 10000
            $iDenominator = 10000 / ($iPercent / 100)
        Case Else
            $iNumerator = 10000 * ($iPercent / 100)
            $iDenominator = 10000
    EndSelect
    Return _SendMessage($hWnd, $EM_SETZOOM, $iNumerator, $iDenominator) <> 0
EndFunc   ;==>_GUICtrlRichEdit_SetZoom

 

I assume whatever windows bug existed at the time this was created, no longer exists so there is no need to restrict the values.   

Just wanted to point this out if anyone else is using this part of the library and required this functionality like I did.

 

Link to comment
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
 Share

×
×
  • Create New...