c.haslam Posted May 7, 2017 Share Posted May 7, 2017 I need to make the text in a RichEdit control more visible on the screen. How do I do it? I need to increase the display font size, the size in the GUI. _GUICtrlRichEdit_SetFont() is not the answer: it changes the font size of the text in a control. I have tried $editsAr[$i] = _GUICtrlRichEdit_Create($gWhForm1, "", $kLeft, $topsVec[$i], 300, 160,BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetFont(_WinAPI_GetDlgCtrlID($editsAr[$i]),12) but it doesn't work. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
benners Posted May 7, 2017 Share Posted May 7, 2017 Have a look in the help file for _GUICtrlRichEdit_ChangeFontSize, there's an example that may be of some help. Link to comment Share on other sites More sharing options...
benners Posted May 7, 2017 Share Posted May 7, 2017 Is this any use? #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) ; select all _GUICtrlRichEdit_ChangeFontSize($hRichEdit, 6) ; change point size _GUICtrlRichEdit_Deselect($hRichEdit) ; deselect all Local $idBtnDoIt = GUICtrlCreateButton("Do it", 270, 310, 40, 30) Local $iMsg GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit Case $iMsg = $idBtnDoIt _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.") EndSelect WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
c.haslam Posted May 7, 2017 Author Share Posted May 7, 2017 Thanks for the suggestion. Your method might work for increasing the font size of text that is already in the control, but I am looking for a way of setting the size of text that a user sees when he types into an empty edit box. For a regular edit box, GuiCtrlSetFont() does this, but it doesn't seem to work with Rich Edit. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
InunoTaishou Posted May 7, 2017 Share Posted May 7, 2017 _GUICtrlRichEdit_SetFont does exactly that expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $iFontSize = 12 Local $lblSize = GUICtrlCreateLabel("Current Size: " & $iFontSize, 10, 270, 150, 20) Local $btnIncrease = GUICtrlCreateButton("Increase", 10, 240, 100, 20) Local $btnDecrease = GUICtrlCreateButton("Decrease", 210, 240, 100, 20) ; Change it as soon as it's made ; RichEdit controls start out with MS Sans Serif size 8.5 by default ; You need to select the whole control and then set the font ChangeFontSize($hRichEdit, $iFontSize) GUISetState(@SW_SHOW) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit Case $btnIncrease $iFontSize += 1 ChangeFontSize($hRichEdit, $iFontSize) GUICtrlSetData($lblSize, "Current Size: " & $iFontSize) Case $btnDecrease If ($iFontSize - 1 > 0) Then $iFontSize -= 1 ChangeFontSize($hRichEdit, $iFontSize) GUICtrlSetData($lblSize, "Current Size: " & $iFontSize) EndIf EndSwitch WEnd EndFunc ;==>Example Func ChangeFontSize($hRichEdit, $iSize) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True) ; select all _GUICtrlRichEdit_SetFont($hRichEdit, $iSize) _GUICtrlRichEdit_Deselect($hRichEdit) ; deselect all EndFunc ;==>ChangeFontSize By default a richedit control starts out with 8.5 as the size, using font MS Sans Serif (Something like that). Even if you use _SetFont right after making it, that very first 0 position of the text data is going to have the 8.5 MS Sans Serif font. So you need to select all of the text (even if there is none) and then use _SetFont. Afterwards, deselect it argumentum 1 Link to comment Share on other sites More sharing options...
c.haslam Posted May 8, 2017 Author Share Posted May 8, 2017 Thank you. Your script works AOK. Now I have to figure out why mine is not! Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
benners Posted May 8, 2017 Share Posted May 8, 2017 3 hours ago, c.haslam said: Thanks for the suggestion. Your method might work for increasing the font size of text that is already in the control, but I am looking for a way of setting the size of text that a user sees when he types into an empty edit box. For a regular edit box, GuiCtrlSetFont() does this, but it doesn't seem to work with Rich Edit. Then just don't set any text when the RichEdit is initially created #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) ; select all _GUICtrlRichEdit_ChangeFontSize($hRichEdit, 4) ; change point size _GUICtrlRichEdit_Deselect($hRichEdit) ; deselect all Local $idBtnDoIt = GUICtrlCreateButton("Do it", 270, 310, 40, 30) Local $iMsg GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit Case $iMsg = $idBtnDoIt _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.") EndSelect WEnd EndFunc ;==>Example argumentum 1 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