Modify ↓

#4111 closed Feature Request (Fixed)

GuiEdit Extensions

Reported by: MattyD Owned by: Jpm
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:

Description

Hi JPM,

Just a couple suggestions for expanding GuiEdit.au3, because I've been given a gentle nudge to submit them :)
I have an attachment sitting in ​this thread with the following extensions and a couple of examples:

Clipboard messages. (WM_CUT etc.)
 _GuiCtrlEdit_Clear - removes selected text.
 _GuiCtrlEdit_Copy
 _GuiCtrlEdit_Cut
 _GuiCtrlEdit_Paste

End of line funcs. (EM_SETENDOFLINE/EM_GETENDOFLINE) 
Includes "allowed" line-breaking chars and autodetect features.
 _GuiCtrlEdit_GetEOL
 _GuiCtrlEdit_GetEOLEx
 _GuiCtrlEdit_SetEOL
 _GuiCtrlEdit_SetEOLEx
 
Zoom funcs. (EM_SETZOOM etc.)
 _GuiCtrlEdit_GetIsZoomable
 _GuiCtrlEdit_GetZoom
 _GuiCtrlEdit_SetIsZoomable
 _GuiCtrlEdit_SetZoom

I was also thinking that wrapping WM_GETFONT/WM_SETFONT probably makes sense here too for an Edit control. So perhaps something simple like this is worth considering as well?

; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlEdit_SetFont
; Description ...: Sets a control's font
; Syntax ........: _GUICtrlEdit_SetFont($hWnd, $hFont[, $bRedraw = True])
; Parameters ....: $hWnd                - Control handle or control ID.
;                  $hFont               - The font handle (HFONT) to set.
;                  $bRedraw             - [optional] If True, the control is redrawn after setting the new font. Default is True.
; Return values .: None
; Remarks .......: Font handles are not freed automatically. Both old and new should be passed to _WinAPI_DeleteObject() when
;                  they are no longer required.
; ===============================================================================================================================
Func _GUICtrlEdit_SetFont($hWnd, $hFont, $bRedraw = True)
        If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
        Return _SendMessage($hWnd, $WM_SETFONT, $hFont, $bRedraw)
EndFunc   ;==>_GUICtrlEdit_SetFont

; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlEdit_GetFont
; Description ...: Gets a control's font handle
; Syntax ........: _GUICtrlEdit_GetFont($hWnd)
; Parameters ....: $hWnd                - Control handle or control ID.
; Return values .: a font handle (HFONT)
; ===============================================================================================================================
Func _GUICtrlEdit_GetFont($hWnd)
        If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
        Return _SendMessage($hWnd, $WM_GETFONT, 0, 0, 0, "wparam", "lparam", "handle")
EndFunc   ;==>_GUICtrlEdit_GetFont

Many thanks,
Matt

Attachments (1)

GuiEditEx.zip​ (19.0 KB ) - added by MattyD on Oct 2, 2026 at 3:18:51 AM.
Updated code, txt documentation, examples

Download all attachments as: .zip

Change History (5)

comment:1 by MattyD, on Sep 29, 2026 at 2:15:36 AM

RE: _GUICtrlEdit_SetFont..
I missed that we already have _WinAPI_SetFont in WinAPISysInternals for this. So I guess we can probably skip that function. However, there's no _WinAPI_GetFont that I can see.

comment:2 by Jpm, on Sep 29, 2026 at 8:33:11 AM

OK, but can you generate the .txt similar to the include one for those UDF's?
Thanks

###User Defined Function###
_GUICtrlEdit_SetReadOnly

###Description###
Sets or removes the read-only style ($ES_READONLY)

###Syntax###
#include <GuiEdit.au3>
_GUICtrlEdit_SetReadOnly ( $hWnd, $bReadOnly )

###Parameters###
@@ParamTable@@
$hWnd
	Control ID/Handle to the control
$bReadOnly
	Following values:
		True - Sets the $ES_READONLY style
		False - Removes the $ES_READONLY style
@@End@@

###ReturnValue###
@@ReturnTable@@
Success:	True.
Failure:	False.
@@End@@

###Remarks###
None.

###Related###
None.

###Example###
@@IncludeExample@@

by MattyD, on Oct 2, 2026 at 3:18:51 AM

Attachment: GuiEditEx.zip​ added

Updated code, txt documentation, examples

comment:3 by anonymous, on Oct 2, 2026 at 4:08:52 AM

Hows this JPM?

  • fixed up SetEOL.
  • Added setfont/getfont.
  • Removed the EolEx funcs. (realistically not that useful.)
  • Defined these consts rather than using WM_* etc. for shared messages, inkeeping with the existing udf.
    Global Const $__EDITCONSTANT_WM_GETFONT = 0x0031
    Global Const $__EDITCONSTANT_WM_CUT = 0x0300
    Global Const $__EDITCONSTANT_WM_COPY = 0x0301
    Global Const $__EDITCONSTANT_WM_PASTE = 0x0302
    Global Const $__EDITCONSTANT_WM_CLEAR = 0x0303
    
    ; EM_GETZOOM/EM_SETZOOM consts are already defined in RichEditConstants.au3
    Global Const $__EDITCONSTANT_WM_USER = 0x0400
    Global Const $__EDITCONSTANT_EM_GETZOOM = $__EDITCONSTANT_WM_USER + 224
    Global Const $__EDITCONSTANT_EM_SETZOOM = $__EDITCONSTANT_WM_USER + 225
    


comment:4 by Jpm, on Oct 4, 2026 at 7:35:41 PM

Owner: set to Jpm
Resolution: → Fixed
Status: new → closed

Fixed by revision [13550]

Added #4111: new _GUICtrlEdit_* - Get/Set IsZoomable, Get/Set EOL, Get/Edit Font, Get/Set Zoom, Paste, Cut, Clear, Copy

Modify Ticket

Action
as closed The owner will remain Jpm.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.