
mike1950r
-
Posts
237 -
Joined
-
Last visited
Reputation Activity
-
mike1950r got a reaction from MattyD in Richedit Delete Question
Many thanks MattyD,
this works perfectly.
I needed your second example.
Cheers mike
-
mike1950r reacted to MattyD in Richedit Delete Question
Or something to mimic BS and Del Keys...
#include <GUIConstants.au3> #include <GuiRichEdit.au3> Local $GUI = GUICreate("", 180, 150) Local $hRE = _GUICtrlRichEdit_Create($GUI, "aaaaaaaaaa", 4, 40, 172, 102) _GuiCtrlRichEdit_SetSel($hRE, 2, 6) Local $hBtn = GUICtrlCreateButton("Delete", 4, 4, 80, 24) Local $hBtn2 = GUICtrlCreateButton("BS", 88, 4, 80, 24) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hBtn $aSel = _GuiCtrlRichEdit_GetSel($hRE) If $aSel[0] = $aSel[1] Then _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0] + 1) _GUICtrlRichEdit_ReplaceText($hRE, "") _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0]) Case $hBtn2 $aSel = _GuiCtrlRichEdit_GetSel($hRE) If $aSel[0] = $aSel[1] Then _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], ($aSel[0]) ? $aSel[0] - 1 : 0) $aSel[0] = ($aSel[0]) ? $aSel[0] - 1 : 0 EndIf _GUICtrlRichEdit_ReplaceText($hRE, "") _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0]) EndSwitch WEnd
-
mike1950r got a reaction from donnyh13 in RichEdit Vertical Scroll Problem
thanks for your posts.
I have recorded a gif-video to be opened with your browser.
It's for showing how it is visible on my system.
Cheers mike
-
mike1950r got a reaction from pixelsearch in GUICtrlGetState Can't get enabled/disabled state
Hi,
thanks for the answer.
I think, the problem comes from the initial value.
If the controls are created but not state is set yet, i get the value 0, which is not $enabled or $disabled.
So far as I see the values should be:
$enabled = 128
$disabled = 64
If i have set the values first time I get the right values with my code above.
i just do not understand, that controls, which are active by default respond with 0, until setting is changed for the first time.
cheers mike
-
mike1950r reacted to Andreik in _GUICtrlRichEdit_SetText (No Undo)
I'm not sure what are you talking about. Selection has nothing to do with undo, as you can see below:
#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Local $hGui = GUICreate("RichEdit Get/Set Text (v" & @AutoItVersion & ")", 340, 350) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 320, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState(@SW_SHOW) Sleep(5000) _GUICtrlRichEdit_SetText2($hRichEdit, "This is Set text.", True) Sleep(5000) _GUICtrlRichEdit_Undo($hRichEdit) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Func _GUICtrlRichEdit_SetText2($hWnd, $sText, $bCanUndo = False) If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False) Local $tSetText = DllStructCreate($tagSETTEXTEX) DllStructSetData($tSetText, 1, ($bCanUndo ? $ST_KEEPUNDO : $ST_DEFAULT)) DllStructSetData($tSetText, 2, $CP_ACP) Local $iRet If StringLeft($sText, 5) <> "{\rtf" And StringLeft($sText, 5) <> "{urtf" Then DllStructSetData($tSetText, 2, $CP_UNICODE) $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "wstr") Else $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "STR") EndIf If Not $iRet Then Return SetError(700, 0, False) Return True EndFunc
-
mike1950r reacted to pixelsearch in TAB in Inputbox
Hi mike1950r
My post was more an answer to abberration who thought it was impossible to disable the forced $WS_TABSTOP style, so I suggested him a way to do it.
Have you tried Andreik's script above ?
It seems to do what you expect.
-
mike1950r reacted to Nine in Multiple Folders Selector
I made this because I wanted a specific behavior when selecting multiple folders at once. With this UDF, you select the folders you want by checking the TreeView checkbox of each folder. Automatically, it will show in the selection ListBox at the right of the TreeView. If you uncheck the folder, it will be removed from the ListBox. By selecting (highlighting) a folder, a list of the files included in that specific folder will replace the selection ListBox. If you check/uncheck a folder, the selection ListBox will reappear.
I also needed a Root Selector that enables Drives and Network (UNC) selection that can serve to start the Multiple Folders Selector. This is practical if you need to select a large number of folders from a specific part of the tree. Be careful though when selecting a Root that includes hundreds of subfolders. Selecting C:\ as a root can take quite some time to be shown.
Version 2024-05-01
* Added support for horizontal scrollbars in folders and files list boxes when appropriate
Version 2021-03-04
* Added optional list of folders to be pre-checked (must be full path name and 0-based)
Here a simple example :
#include <Array.au3> #include "MultiFoldersSelectorUDF.au3" ; Select root folder and return all chosen folders Local $sSelectedRoot = _MFS_SelectRootFolder() If @error Then Exit Local $aListFolder = _MFS_SelectMultipleFolders($sSelectedRoot) If Not @error Then _ArrayDisplay($aListFolder) ; Pre-check all folders starting with "Aut" in AutoIt3 root folder and returns new checked/unchecked list of folders Local $aPreChecked = _FileListToArrayRec(@ProgramFilesDir & "\AutoIt3", "Aut*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) _ArrayDelete($aPreChecked, 0) $aListFolder = _MFS_SelectMultipleFolders(@ProgramFilesDir & "\AutoIt3", $aPreChecked) If Not @error Then _ArrayDisplay($aListFolder) Let me know if you find it useful.
MultiFoldersSelectorUDF.au3
-
mike1950r reacted to Andreik in Multiple keystroke handling
#include <MsgBoxConstants.au3> HotKeySet("{ESC}", "HotKeyPressed") HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d While 1 Sleep(100) WEnd Func HotKeyPressed() Switch @HotKeyPressed ; The last hotkey pressed. Case "{ESC}" ; String is the {ESC} hotkey. Exit Case "+!d" ; String is the Shift-Alt-d hotkey. HotKeySet("+!d") MsgBox($MB_SYSTEMMODAL, "", "This is a message.") HotKeySet("+!d", "HotKeyPressed") EndSwitch EndFunc ;==>HotKeyPressed
-
mike1950r got a reaction from pixelsearch in richedit resizable scrollbars
Hi pixelsearch,
I found another methode for resizing without disabled dummy-label:
GUIRegisterMsg($WM_SIZE, "ON_WINDOW_EDIT_RESIZE") Func ON_WINDOW_EDIT_RESIZE($hWnd, $iMsg, $wParam, $lParam) Local $iHeight, $iWidth If $hWnd = $hGlo_WE_GUI Then $iWidth = _WinAPI_LoWord($lParam) $iHeight = _WinAPI_HiWord($lParam) _WinAPI_MoveWindow($hGlo_WE_Control, 0, 0, $iWidth, $iHeight) Return 0 EndIf Return $GUI_RUNDEFMSG EndFunc ;==>ON_WINDOW_EDIT_RESIZE This works excellent in my program.
Cheers mike
-
mike1950r reacted to pixelsearch in richedit resizable scrollbars
Mike, you should resize the RichEdit control when the GUI is resized, then you shouldn't have issues with the RichEdit scrollbars. Below are a couple of functions (from a personal long script) where you can pick what you want (e.g the resize part) to solve your richedit scrollbar issue :
;=================================================================
Func _GuiPrev()
If $g_hGuiPrev = 0 Then ; only once during whole script
$g_hGuiPrev = GUICreate("Preview in RichEdit control (read-only)", $g_iGui_W, $g_iGui_H, -1, -1, _
BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
; $g_cLabel just to allow resizing of a richedit control !
; Melba23 - https://www.autoitscript.com/forum/topic/204198-richedit-resize/?do=findComment&comment=1466930
$g_cLabel = GUICtrlCreateLabel("", 1, 1, $g_iGui_W - 2, $g_iGui_H - 2)
GUICtrlSetResizing($g_cLabel, 1)
GUICtrlSetState($g_cLabel, $GUI_DISABLE) ; Most important! (Melba23)
$g_hRichEdit = _GUICtrlRichEdit_Create($g_hGuiPrev, "", 1, 1, $g_iGui_W - 2, $g_iGui_H - 2, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_WANTRETURN, $ES_NOHIDESEL, $ES_READONLY)) ; no hozizontal scrollbar
; BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $ES_NOHIDESEL, $ES_READONLY)) ; horizontal scrollbar
; To do (done) : switch $ES_READONLY off/on after richedit creation (keep the interesting Malkey's link below +++)
; https://www.autoitscript.com/forum/topic/141238-richedit-friendly-name-hyperlinks/?do=findComment&comment=993231
; No need to use _GUICtrlRichEdit_SetBkColor as white background hurts my eyes. Keep the following line for its syntax
; _GUICtrlRichEdit_SetBkColor($g_hRichEdit, 0x00FFFFFF) ; white (note: my background is grey). White to match Forum background
; 2 following lines to allow clickable url's inside richedit controls, not forgetting $EN_LINK in Func WM_NOTIFY
_GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK)
_GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True) ; True to detect URLs in text, False not to
; Nine's - https://www.autoitscript.com/forum/topic/206070-setup-permanent-font-for-richedit-control/?do=findComment&comment=1484072
Local $hFont = _WinAPI_CreateFont(14, 0, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, _
$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Lucida Console') ; trying to match $g_idEdit font
_SendMessage($g_hRichEdit, $WM_SETFONT, $hFont, True) ; True = the control redraws itself
_WinAPI_DeleteObject($hFont)
_SetTabStops($g_hRichEdit, 14) ; 14 corresponds approx. to 4 characters width (as my Scite) in this RichEdit control with this font
Else
_GUICtrlRichEdit_SetText($g_hRichEdit, "") ; useful on 2nd(+) preview, to erase the text that was in the richedit control
EndIf
GUISetState(@SW_DISABLE, $g_hGui)
GUISetState(@SW_SHOW, $g_hGuiPrev)
_PreviewOrGenerate(1) ; 1 = Preview (in RichEdit control)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; to take care of clickable url's in richedit control
GUIRegisterMsg($WM_SIZE, "WM_SIZE") ; to resize richedit control when its Gui is resized
While 4
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE ; close $g_hGuiPrev (as $g_hGui is disabled at this stage)
ExitLoop; While 4
Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE ; goal is to resize correctly... the richedit control in $g_hGuiPrev
_Resize()
EndSwitch
Wend
GUIRegisterMsg($WM_SIZE, "")
GUIRegisterMsg($WM_NOTIFY, "")
GUISetState(@SW_HIDE, $g_hGuiPrev)
GUISetState(@SW_ENABLE, $g_hGui)
ControlFocus($g_hGui, "", $g_idEdit)
EndFunc ;==>_GuiPrev
;=================================================================
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
If $hWnd = $g_hGuiPrev Then
_Resize()
; Return 0 ; "If an application processes this message, it should return zero." (msdn) ... but bad display in this script !
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
;=================================================================
Func _Resize()
; Get the new position and size of the label...
Local $aPos = ControlGetPos($g_hGuiPrev, "", $g_cLabel)
; ...and set the RichEdit to the same position and size
WinMove($g_hRichEdit, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndFunc ;==>_Resize
I applied it to the code you presented in your post, it worked fine :
#include <EditConstants.au3>
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; GUI
$iWidth = 800
$iHeight = 600
$iLeft = 0
$iTop = 0
$hStyle = BitOR($WS_CAPTION, $WS_SYSMENU, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)
$hExStyle = $WS_EX_DLGMODALFRAME
$hGlo_WE_GUI = GUICreate("Gui title", $iWidth , $iHeight, $iLeft, $iTop, $hStyle, $hExStyle)
; $g_cLabel just to allow resizing of a richedit control !
; Melba23 - https://www.autoitscript.com/forum/topic/204198-richedit-resize/?do=findComment&comment=1466930
$g_cLabel = GUICtrlCreateLabel("", 0, 0, $iWidth - 100, $iHeight - 100)
GUICtrlSetResizing($g_cLabel, 1)
GUICtrlSetState($g_cLabel, $GUI_DISABLE) ; Most important! (Melba23)
; Richedit Control
$hStyle = BitOR($ES_MULTILINE, $ES_WANTRETURN, $ES_NOHIDESEL, $WS_VSCROLL, $WS_HSCROLL)
$hExStyle = $WS_EX_CLIENTEDGE
$hGlo_WE_Control = _GUICtrlRichEdit_Create($hGlo_WE_GUI, "", 0, 0, $iWidth - 100, $iHeight - 100, $hStyle, $hExStyle)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE") ; to resize richedit control when its Gui is resized
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hGlo_WE_Control)
Exit
Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE ; goal is to resize correctly... the richedit control in $hGlo_WE_GUI
_Resize()
EndSwitch
WEnd
;=================================================================
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
If $hWnd = $hGlo_WE_GUI Then
_Resize()
; Return 0 ; "If an application processes this message, it should return zero." (msdn) ... but bad display in this script !
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
;=================================================================
Func _Resize()
; Get the new position and size of the label...
Local $aPos = ControlGetPos($hGlo_WE_GUI, "", $g_cLabel)
; ...and set the RichEdit to the same position and size
WinMove($hGlo_WE_Control, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndFunc ;==>_Resize
In my script, I still have a minor issue with the resize part (solved with a workaround) but let's hope you won't face it.
Good luck
-
mike1950r reacted to pixelsearch in Richedit horizontal scroll right arrow problem
Mike, the following script solves partially your issue.
If you immediately drag the horizontal scroll box at its rightmost position, then the horizonal scroll right arrow will be deactivated, as discussed before. But this is not enough, as some other ways of scrolling aren't solved by the script.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiScrollBars.au3>
Global $sText = "", $hGui, $hRichEdit
For $n = 2 To 100
$sText &= $n & " - This is a single long line intended to cause a hoizontal scroll bar to appear in the RichEdit control." & @CRLF
Next
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, $sText, 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $WS_HSCROLL))
; _GUICtrlRichEdit_SetEventMask($hRichEdit, BitOR($ENM_SCROLL, $ENM_SCROLLEVENTS))
_GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_SCROLLEVENTS)
GUISetState(@SW_SHOW)
$tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($hRichEdit, $OBJID_HSCROLL)
$iMaxScrollHoriz = $tSCROLLBARINFO.Right - $tSCROLLBARINFO.xyThumbTop - $tSCROLLBARINFO.Left
ConsoleWrite("$iMaxScrollHoriz = " & $iMaxScrollHoriz & @crlf & @crlf)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit)
Exit
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
#forceref $iMsg, $iWparam
Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hRichEdit
Select
Case $iCode = $EN_MSGFILTER
$tMsgFilter = DllStructCreate($tagMSGFILTER, $iLparam)
Switch DllStructGetData($tMsgFilter, "msg")
Case $WM_HSCROLL ; 276
Local $iRightScrollThumb = _GUIScrollBars_GetScrollBarXYThumbBottom($hRichEdit, $OBJID_HSCROLL)
ConsoleWrite("$iRightScrollThumb = " & $iRightScrollThumb & " / " & _
"$iMaxScrollHoriz = " & $iMaxScrollHoriz & @crlf)
If $iRightScrollThumb = $iMaxScrollHoriz Then
_GUIScrollBars_EnableScrollBar($hRichEdit, $SB_HORZ, $ESB_DISABLE_RIGHT)
Else
_GUIScrollBars_EnableScrollBar($hRichEdit, $SB_HORZ, $ESB_ENABLE_BOTH)
EndIf
Case $WM_VSCROLL ; 277
EndSwitch
EndSelect
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Anyway, that's a start, better than nothing
-
mike1950r reacted to KaFu in Create Object Handling
If it's an "include" library you can also define the Global variable at the top of the include file itself.
GDIPlus.au3 does something similar with $__g_hGDIPDll.
Aalso you could test the variable with isobj() at the beginning of the single functions, and throw an error when false.
-
-
mike1950r got a reaction from pixelsearch in Richedit tab size - (Moved)
I have modified my function like this:
Func WindowEditSetDefaultFont($hWnd, $iPoints, $sName, $iTabWidth = 4) Local $hFont, $iTabStops $hFont = _WinAPI_CreateFont($iPoints + 3, 0, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, $sName) _SendMessage($hWnd, $WM_SETFONT, $hFont, True) _WinAPI_DeleteObject($hFont) $iTabStops = $iTabWidth * 4 _SendMessage($hWnd, $EM_SETTABSTOPS, 1, $iTabStops, 0, "wparam", "uint*") EndFunc ;==>WindowEditSetDefaultFont You can enter $iTabWidth value directly 4 or 6 etc. always 100% fitting.
thanks lot, pixelsearch,
cheers mike
-
mike1950r reacted to pixelsearch in Richedit tab size - (Moved)
Yes it matches perfectly, even after 100 characters have been typed on the precedent line (25 tabs on the following line match exactly 100 characters on preceding line). I already tested that 16 would fit, just after you indicated "Lucida Console, fontsize 10, $FW_NORMAL"
As you're using a function WindowEditSetDefaultFont in this post which adds +3 to fontsize (10+3 = 13) then it's important for our readers to understand that "Lucida Console, fontsize 13, $FW_NORMAL" requires a Tab parameter of 16 for the _SetTabStops() function, so @TAB will correspond exactly to 4 characters width, in a RichEdit control using these font parameters.
It's longer to explain than just modifying the value
-
mike1950r reacted to pixelsearch in Richedit tab size - (Moved)
@mike1950r May I suggest you adapt the following code to your script, changing the value of 14 with another value that will suit your needs.
#include <SendMessage.au3>
...
$g_hRichEdit = _GUICtrlRichEdit_Create(...)
...
_SetTabStops($g_hRichEdit, 14) ; 14 corresponds approx. to 4 characters width (as my Scite) in this RichEdit control with this font
...
Func _SetTabStops($hWnd, $iTabStops)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
; next line _SendMessage based on _GUICtrlEdit_SetTabStops / _GUICtrlRichEdit_SetTabStops, with "uint*" instead of "struct*" of course.
_SendMessage($hWnd, $EM_SETTABSTOPS, 1, $iTabStops, 0, "wparam", "uint*")
EndFunc ;==>_SetTabStops
Please indicate what value made it for you, as we don't have the same fonts installed on our computers.
Good luck
-
mike1950r got a reaction from pixelsearch in Display .xcu file in richedit control
Pixelsearch,
I tried this modification to automate the wrap if needed:
Func _GUICtrlRichEdit_WordWrapAuto($hWnd, $sText) Local $bEnable $bEnable = False If StringLen($sText) > 8192 Then If Not StringInStr($sText, @CRLF) Then $bEnable = True EndIf EndIf If (IsHWnd($hWnd) = False) Then Return SetError(1, 0, False) EndIf DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $EM_SETTARGETDEVICE, "wparam", 0, "lparam", Not $bEnable) If (@Error) Then Return SetError(2, @extended, False) EndIf Return True EndFunc cheers and thanks again
mike
-
mike1950r reacted to pixelsearch in Display .xcu file in richedit control
@mike1950r I did a few tests, here are the results :
_GUICtrlRichEdit_SetLimitOnText isn't required if we paste directly Plain text in a RichEdit control, but it is required to bypass the 32KB/64KB limits when we paste RTF text ( e.g a long string starting with "{\rtf or "{urtf" ) . Also, the limit value we indicate is the number of characters in the string of RTF text, minus the RTF keywords lenght present in the string (more or less)
In my tests, the value I indicated in _GUICtrlRichEdit_SetLimitOnText was much more than 64KB : I indicated 2.000.000 characters as a limit, then pasted an RTF string of 1.000.000 RTF text characters in the RichEdit control : all the RTF text appeared correctly (especially the very last characters) so I don't know why this 64KB limit is mentioned everywhere. Please anyone, share your knowledge about this if you got infos, thanks.
Now let's talk about the string found in your file "registrymodifications.xcu", it's a string of 41KB which contains characters and spaces, but doesn't contain any line break. Let's see what happens in NotePad, WordPad, an AutoIt RichEdit control or Scite, when Wrap is not ticked
1) Scite : the easiest one first.
The 41KB string is displayed on 1 line (when Wrap is unticked) and fully visible from the beginning till the end, great !
2) NotePad : the string is displayed on 41 lines, when Wrap is unticked (as Notepad's right limit is 1024 chars) so 1024 *41 is more or less 41KB (the file size)
If Wrap is ticked, then of course much more of than 41 lines are displayed (wrapping occurs if a space is found between words, or if a 'line' covers the whole width of the Notepad window, without any space in it, then it wraps inside a word as no space has been found). So we can say all text is always visible in NotePad, as you indicated in your post.
3) WordPad : now the issues start when Wrap is unticked :
- If a string got less than 10.772 characters (and doesn't contain any line break) then it is correctly displayed and fully visible on 1 line, there is an horizontal (scrollbar and if you press Home/End keys, the caret will be placed automatically at the beginning or the end of the string : so far so good.
- If the string got exactly 10.772 characters, then the scrollbar disappears, the End key isn't functional and you see only a part of the string.
- If the string got more than 10.772 characters then nothing good will happen too (you won't be able to see the end of the line, because Wrap is unticked. The horizontal scrollbar may appear or not, depending on how many characters have been added to 10.772 , a kind of cycle)
4) AutoIt RichEdit control (with Wrap unticked) :
It's exactly the same issues than WordPad, except the limit is 8.192 characters (instead of 10.772 for WordPad)
The solution (in WordPad and RichEdit control) should be to check Wrap in this case, so all lines appear on the screen. A good thing could be to have an option, in a GUI containing a RichEdit control, to wrap/unwrap the content of the control, when user needs it.
@InunoTaishouindicated in this post how to do it for a RichEdit control (wrap/unwrap, on the fly)
There's also a post here where we discussed the way to do it for a regular edit control, which could be handy when needed.
Hope it helps
-
mike1950r reacted to jugador in Richedit TABkey
think it's working
by mixing @Musashi hint CRTL+TAB & GUICtrlCreateDummy
#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> __Example() Func __Example() Local $iMsg Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) Local $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) Local $id_Dummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{TAB}", $id_Dummy]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes GUIDelete($hGui) Exit Case $iMsg = $id_Dummy _InsertEightSpaces() EndSelect WEnd EndFunc Func _InsertEightSpaces() Send('^{TAB}') EndFunc
-
mike1950r got a reaction from argumentum in Randomn AutoIt3_x64 Crashes with dmp file created
Thanks lot for your information.
I will take care of these.
Best regards
mike
-
mike1950r reacted to Danp2 in ASC wrong number
@mike1950r You should be able to do it with a single regex --
Func StringIsANSI($sString) Local $bSuccess, $iLen $bSuccess = True $iLen = StringLen($sString) If $iLen And StringRegEx($sString, "[^\x00-\xFF]") Then $bSuccess = False EndIf Return $bSuccess EndFunc ;==>StringIsANSI This returns True for an empty string, but otherwise it should match your earlier code.
-
mike1950r reacted to jchd in ASC wrong number
; sample Unicode strings in AutoIt encoding (UCS2) Local $a = [ _ "All lower ASCII here!", _ "Some characters ¼½¾ÀÁÇÖæÿ in upper ANSI 1252", _ "Some characters > 0xFF: Μεγάλο πρόβλημα" _ ] For $s In $a ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "^[\x00-\x7F]*$") ? "" : "NOT ") & "only lower ASCII" & @LF) ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "[\x80-\xFF]") ? "some" : "NO ") & "upper ASCII" & @LF) ConsoleWrite('"' & $s & '"' & " contains " & (StringRegExp($s, "[\x{100}-\x{FFFF}]") ? "" : "NO ") & "characters > 0x100" & @LF) Next
-
mike1950r reacted to jchd in Wrong result with FileGetEncoding(
Here's the underlying issue with text files.
Extended ANSI uses one byte per character and has 128 "upper" characters codes [0x80, 0xFF] which are assigned to a set of characters defined by the codepage in use. The codepage is not explicit and this is a problem for information interchange.
Unicode has a very large character set encompassing all glyphs ever used by humans. The range of Unicode characters is [0x000000, 0x10FFFF] which is 1 114 112 possible characters!
Obviously an Unicode character (a codepoint) must use something larger than one byte to represent, contrary to previous codepages. This is where encoding enters the scene.
A useful encoding is UTF8 which uses sequences of 1 to 4 bytes to represent a character. See UTF8 to understand how this encoding works.
The lower part of ANSI is mapped verbatim to the first 128 Unicode codepoints. In UTF8, a byte > 0x7F introduces a sequence one more than one byte and this sequence has to conform to UTF8 encoding. This is what FileGetEncoding tries to determine.
The word "España" has different representations in Windows Occidental codepage and UTF8:
ANSI Occidental codepage 1252 E s p a ñ a 45 73 70 61 F1 61 UTF8 (NoBOM) E s p a ñ a ┌─┴─┐ 45 73 70 61 C3 B1 61 UTF8 (BOM) E s p a ñ a ┌─┴─┐ EF BB BF 45 73 70 61 C3 B1 61 └──┬───┘ BOM The optional BOM (Byte Order Mark) serves as a special marker to help distinguish UTF8 from byte codepages.
If you FileOpen a file with the first content without specifying a mode, AutoIt will try to find in the first 64k bytes if there are invalid UTF8 sequences. If found the file will be open as ANSI, else UTF8. The sequence 0xF1 0x61 is an invalid UTF8 sequence, hence file is treated as ANSI.
If a file with the second example is mistakenly open as ANSI it would display as "Espaïa" which is probably not what users want.
If an UTF8 BOM is found, it is ignored but the file is treated as UTF8 without further examination.
EDIT:
The file you provided is empty, hence will by default be considered as UTF8 w/o BOM.
-
-
mike1950r reacted to jchd in ASC wrong number
The Unicode codepoint of ć is 0x107, that is decimal 263, not 262.
ConsoleWrite(AscW("ć") & @LF)