Leaderboard
Popular Content
Showing content with the highest reputation on 03/26/2025 in all areas
-
goto specific line in rich edit control
TheAutomator reacted to pixelsearch for a topic
Yes I know The purpose of my preceding post was just to indicate how to calculate precisely the number of the last visible line, which seems to me a very important step before doing anything else : remember the height of the scroll thumb should be recalculated when comparing the number of visible lines to the number of total lines, which will constantly change while the user adds/removes lines. In a 2nd step, I went a bit further, adding a registered WM_COMMAND message to take care of $EN_CHANGE or $EN_UPDATE, which could call a function dedicated to resize/move the scroll thumb (or hide it when all lines are visible in the richedit area) Maybe $EN_UPDATE is a better choice than $EN_CHANGE because the scrolling function will be called only from this place ($EN_UPDATE) . Because if you choose instead to monitor $EN_CHANGE, then you'll have to call the scrolling function from several other places (for example from inside WM_NOTIFY while you're using the mouse wheel to scroll [this triggers $EN_UPDATE but not $EN_CHANGE], or from a resize function, in case one day you allow the richedit control to be resized while you resize the GUI etc...) The annoyance with $EN_UPDATE is that it's called more often than $EN_CHANGE, which means the scrolling function will also be called more often when using $EN_UPDATE (compared to $EN_CHANGE) Anyway, all this is challenging for educational purpose. If I succeed achieving some working code, I"ll post it here. Glad to know you're feeling better1 point -
goto specific line in rich edit control
pixelsearch reacted to TheAutomator for a topic
Hi everyone, thanks for the replys! Normally I reply whitin a day, but I have been sick the last few days.. junkew, Thanks, it's a good start for me to experiment with The messages you listed are the ones that should work somehow if I combine them the right way yes. pixelsearch, Thanks for the effort I want a custom colored scrollbar is the reason, not the ugly white standart one that hurts your eyes when using a dark gui (like in my project). Your code has no scrollbar at all but the code can be helpfull for calculations! I already made the graphics to fit the dark theme, but the code is still a bit buggy and not completely working: I wish i could just hide the default one but send messages to it and get from it instead of reinventing the wheel to have a custom color... I'm gonna experiment a little more with the code and see how good i can get it for general use, for now my bar just moves the cursor and resets the selection when done scrolling (it works pretty well too but you can see the cursor move when you scroll and the bar stays on the same spot when you change the text). So what I already have now: - an image for the background and one for the thumb - the ability to drag the thumb image over the background and get the result als a value between 0 and 1 according to the position dragged - some code that works a bit but not fully as i would like (like a real scrollbar) When I have a few finished scripts i'll post them here1 point -
ioa747, Yeppers!...Ya' got it! What I do NOT understand, is that I always enable that feature...and thus, I have NO IDEA how that option got changed on UserA?!? • I mean, I actually wrote a script that enables that feature at the very beginning of my Windows installations. Here is that script [UpdateRegistry]: ; ----------------------------------------------- #RequireAdmin ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- UpdateRegKey() ; ----------------------------------------------- Func UpdateRegKey() Local $sSrcPath = RunWait('REGEDIT /S "D:\Assets\RegKeys\UpdateExplorer.reg"') ; ----------------- Local $sMessage = "Update Registry Key..." & @CRLF & @CRLF Local $iWidth = 450, $iHeight = 245, $iOpt = 5, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14 ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) ; ----------------------------------------------- For $i = 1 To $sSrcPath[0] Local $sResult = $sSrcPath[$i] ; ----------------------------------------------- Switch $sResult Case 0 $sResult = "The Registry WAS updated successfully!" Case 1 $sResult = "The Registry WAS NOT updated successfully!" EndSwitch ; ----------------------------------------------- $sMessage &= $sResult & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Update Registry Keys is now completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("NOTICE!!", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) Sleep(2000) SplashOff() EndFunc ;==>UpdateRegKey ; ----------------------------------------------- Here is the RegKey [UpdateExplorer.reg]: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced] ; Display the full path in the title bar: [CabinetState] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState] ; Display the full path in the title bar...; 1=Enabled, 0=Disabled, Status: Enabled "FullPath"=dword:00000001 Thanks again, 101747! You are very much "underdemciated!"....I mean "appreciated!"1 point
-
Good day, comes to my mind: https://www.autoitscript.com/forum/topic/212198-winmove-issues Check if both users have the Display the full path in the title bar in explorer options enable1 point
-
Help File/Documentation Issues. (Discussion Only)
argumentum reacted to pixelsearch for a topic
Hi everybody If I'm not mistaken, there are 2 examples in the help file where an inappropriate structure is created. Though the result is correct, it's a bit confusing. Topics are : _GUICtrlRichEdit_AutoDetectURL _GUICtrlRichEdit_GetTextInRange Here is the incorrect part : ... _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK) ... Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ... Case $iCode = $EN_LINK $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam) If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then $tEnLink = DllStructCreate($tagENLINK, $lParam) $iCpMin = DllStructGetData($tEnLink, "cpMin") $iCpMax = DllStructGetData($tEnLink, "cpMax") MsgBox($MB_SYSTEMMODAL, "", "Invoke your web browser here and point it to " & _ _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax)) EndIf ... EndFunc The structure $tagMSGFILTER has nothing to do with $EN_LINK . Only $EN_MSGFILTER should use $tagMSGFILTER . Imho both examples should be modified like this : ... _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK) ... Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ... Case $iCode = $EN_LINK $tEnLink = DllStructCreate($tagENLINK, $lParam) If DllStructGetData($tEnLink, "msg") = $WM_LBUTTONUP Then $iCpMin = DllStructGetData($tEnLink, "cpMin") $iCpMax = DllStructGetData($tEnLink, "cpMax") MsgBox($MB_SYSTEMMODAL, "", "Invoke your web browser here and point it to " & _ _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax)) EndIf ... EndFunc Thanks for reading1 point -
goto specific line in rich edit control
TheAutomator reacted to pixelsearch for a topic
Maybe you will tell us why you don't want to use a native vertical scrollbar in your richedit control, is it simply its color you don't like, or something else ? Because, as you already know, a simple $WS_SCROLL style would solve it all. Anyway, as you prefer to mimic the scrollbar (by using a vertical movable/resizable label control) , then imho the 1st step should be to constantly check what is the last visible line in your richedit control. Knowing the 1st visible line is easy, as there is a native windows message EM_GETFIRSTVISIBLELINE which indicates this. With AutoIt, the message is found in the function _GUICtrlRichEdit_GetNumberOfFirstVisibleLine() But unfortunately there is no "EM_GETLASTVISIBLELINE" Windows message (and it's a pity) but you can calculate it, using a couple of other messages, as shown in the script below. Now, when you got these 2 variables (1st and last visible lines) then it should be possible to mimic a vertical scrollbar, by comparing constantly the value of the 2 variables to the total number of lines in your richedit control, then move/resize accordingly your vertical label (the "scrollbar thumb") The script below got a scrollable richedit control (using mousewheel, without scrollbar) as discussed in our preceding posts. The purpose of the script is simply to indicate how to calculate the last visible line of a richedit control, which is (imho) the 1st step that could help to achieve your goal. Good luck #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hRichEdit Example() Func Example() Local $hGui, $idLblMsg, $idBtnNext, $aRect, $iCharIndex, $iLastVisibleLine $hGui = GUICreate("Last visible line richedit", 320, 320) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "Line # 01", 5, 5, 310, 214, _ BitOR($ES_MULTILINE, $ES_AUTOVSCROLL)) $idLblMsg = GUICtrlCreateLabel("", 5, 225, 310, 50) GUICtrlSetBkColor(-1, 0xFFFF00) ; yellow $idBtnNext = GUICtrlCreateButton("Scroll then Check last visible line", 70, 280, 180, 30) GUISetState(@SW_SHOW) _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Line # 02") For $i = 3 To 40 _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Line # " & StringFormat("%02i", $i)) Next _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 129) _GUICtrlRichEdit_SetCharAttributes($g_hRichEdit, "+bo") _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_SCROLLEVENTS) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) Exit Case $idBtnNext $aRect = _GUICtrlRichEdit_GetRECT($g_hRichEdit) ; ConsoleWrite("Formatting rectangle : " & $aRect[0] & " " & $aRect[1] & " " & $aRect[2] & " " & $aRect[3] & @crlf) $iCharIndex = _GUICtrlRichEdit_GetCharPosFromXY($g_hRichEdit, $aRect[0] + 2, $aRect[3] - 2) ; ConsoleWrite("$iCharIndex : " & $iCharIndex & @crlf) $iLastVisibleLine = _GUICtrlRichEdit_GetLineNumberFromCharPos($g_hRichEdit, $iCharIndex) ; ConsoleWrite("$iLastVisibleLine : " & $iLastVisibleLine & @crlf & "=================" & @crlf) GUICtrlSetData($idLblMsg, "First Visible Line : " & _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($g_hRichEdit) & @crlf & _ "Last Visible Line : " & $iLastVisibleLine & @crlf & _ "Count of all lines : " & _GUICtrlRichEdit_GetLineCount($g_hRichEdit)) ControlFocus($hGUI, "", $g_hRichEdit) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tFilter = DllStructCreate($tagMSGFILTER, $lParam) If $tFilter.hwndFrom = $g_hRichEdit Then _GUICtrlRichEdit_ScrollLines($g_hRichEdit, $tFilter.wParam ? 1 : -1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point -
goto specific line in rich edit control
TheAutomator reacted to junkew for a topic
This seems to work for both controls but you have to set the rich text box first to point 0,0 The reverse order is not working #include <EditConstants.au3> #include <GuiEdit.au3> #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui=GUICreate("My GUI edit and rich edit") ; will create a dialog box that when displayed is centered local $someTextLines=stringreplace("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","x", "line" & @crlf) Local $idMyedit = GUICtrlCreateEdit($someTextLines & @CRLF, 10, 10, 350, 180, $ES_MULTILINE+$ES_AUTOVSCROLL + $WS_VSCROLL) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, $someTextLines, 10, 210, 350, 180, bitor($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) ;~ Important line _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0) GUISetState(@SW_SHOW) ;~ GUICtrlSendMsg ($hRichEdit, $EM_LINESCROLL, 0, 0) local $i For $i=10 to 20 ;~ _GUICtrlEdit_LineScroll($idMyedit, 0, _GUICtrlEdit_GetLineCount($idMyedit)) ;~ _GUICtrlEdit_LineScroll($hRichEdit, 0, _GUICtrlEdit_GetLineCount($hRichEdit)) _GUICtrlEdit_LineScroll($idMyedit, 0, $i) _GUICtrlEdit_LineScroll($hRichEdit, 0, $i) ;~ GUICtrlSendMsg ($hRichEdit, $EM_LINESCROLL, 0, $i) ;~ Local $nIndex = GUICtrlSendMsg ($hRichEdit, $EM_LINEINDEX, $i, 0) ;~ GUICtrlSendMsg ($hRichEdit, $EM_SETSEL, $nIndex, 0) ;~ ControlCommand ($hGUI, "", $hRichEdit, "SetCurrentSelection", @CRLF) ;~ $iCharPosition = _GUICtrlRichEdit_GetFirstCharPosOnLine($hRichEdit, $i) ;~ _GUICtrlRichEdit_SetSel($hRichEdit, $iCharPosition, $iCharPosition + 4) sleep(250) next ;~ Important line ;~ _GUICtrlEdit_SetSel($idMyedit, -1, -1) ;~ _GUICtrlRichEdit_SetSel($hRichEdit, -1,-1) For $i=10 to 0 step -1 _GUICtrlEdit_LineScroll($idMyedit, 0, $i) _GUICtrlEdit_LineScroll($hRichEdit, 0, $i) sleep(250) next ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example1 point -
goto specific line in rich edit control
TheAutomator reacted to junkew for a topic
https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlRichEdit_FindText.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlRichEdit_GotoCharPos.htm Goto 0 and in a loop find carriage return Probably with those messages you will be able to do this EM_POSFROMCHAR EM_CHARFROMPOS EM_LINEFROMCHAR EM_LINEINDEX EM_LINESCROLL And the editcontrol functions should work also otherwise you need sendmessage function with windows messages https://learn.microsoft.com/en-us/windows/win32/controls/about-rich-edit-controls https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlEdit_LineScroll.htm1 point -
Need help with _GUICtrlRichEdit_SetEventMask
pixelsearch reacted to Melba23 for a topic
qwert, You need to register WM_COMMAND, not WM_NOTIFY - then you get a response whenever the content is changed: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $hGui = GUICreate("Drag Drop", 400, 300, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) GUISetFont(12, 400, 0, "Arial") $hEdit = _GUICtrlRichEdit_Create($hGui, "", 20, 30, 360, 120, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetFont($hEdit, 14, "Arial") _GUICtrlRichEdit_SetEventMask($hEdit, $ENM_CHANGE) GUICtrlCreateLabel("Drop text into above field", 24, 170, 200, 24) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; ConsoleWrite("Close" & @CRLF) _GUICtrlRichEdit_Destroy($hEdit) ; Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If $lParam = $hEdit And _WinAPI_HiWord($wParam) = $EN_CHANGE Then ConsoleWrite("Edit content changed" & @CRLF) EndIf EndFunc I am sorry that you find the GUIRegisterMsg tutorial in the Wiki less than satisfactory. It was only ever intended as a brief overview - if you want the full explanation of how Windows messaging works, I recommend MSDN, although it is very detailed. As to the crossover between GUIGetMsg and needing to register the Windows messages directly - look at the Help file pages <GUI Reference - MessageLoop/OnEvent Mode>. You will see that GUIGetMsg and GUI/GUICtrlSetOnEvent only have a limited set of messages to which they will respond, plus the controls created by AutoIt's native functions. Anything over and above that limited set (such as looking for a change in a UDF-created control as here) requires you to intercept the relevant message yourself. To do that you need to look in MSDN (or search the forum for a suitable crib ) and determine which message is sent and how to intercept it - I looked on MSDN and found this page from which I devised the above code. Does that make it any clearer? M231 point -
It is possible to display a PNG image in a pic control using GDI+. Example: ;coded by UEZ 2011 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $msg Global Const $hGUI = GUICreate("Display PNG Image in picture control", 600, 250) Global Const $idPic = GUICtrlCreatePic("", 215, 20) _GDIPlus_Startup() Global Const $png = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png") Global Const $hImage = _GDIPlus_ImageLoadFromFile($png) Global Const $Bmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp)) GUISetState() While True $msg = GUIGetMsg() Switch $msg Case $idPic MsgBox(0, "Information", "PNG image was clicked") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($Bmp) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndSwitch WEnd This example is using the png picture from the ExamplesGUI folder and displays it in a picture control. Br, UEZ1 point