WhyTea Posted September 26, 2009 Posted September 26, 2009 I have created an edit control for a file to be loaded, is there a way to jump to a specific line and highlight it? /Why Tea
Mat Posted September 26, 2009 Posted September 26, 2009 You need to use GUICtrlSendMsgGUICtrlSendMsg ($hEdit, $EM_LINESCROLL, 0, $nLine) $nIndex = GUICtrlSendMsg ($hEdit, $EM_LINEINDEX, $nLine, 0) $nLen = StringLen (ControlCommand ($hGUI, "", $hEdit, "GetLine", $nLine)) GUICtrlSendMsg ($hEdit, $EM_SETSEL, $nIndex, $nIndex + $nLen)I haven't tried the code, but those are the messages you need. Read MSDN for details.Mat AutoIt Project Listing
WhyTea Posted September 26, 2009 Author Posted September 26, 2009 On 9/26/2009 at 11:27 AM, 'Mat said: You need to use GUICtrlSendMsg GUICtrlSendMsg ($hEdit, $EM_LINESCROLL, 0, $nLine) $nIndex = GUICtrlSendMsg ($hEdit, $EM_LINEINDEX, $nLine, 0) $nLen = StringLen (ControlCommand ($hGUI, "", $hEdit, "GetLine", $nLine)) GUICtrlSendMsg ($hEdit, $EM_SETSEL, $nIndex, $nIndex + $nLen) I haven't tried the code, but those are the messages you need. Read MSDN for details. Mat Thanks Matt. The code does go to the line number offset from the first line in the edit box, however the line of text is not highlighted. But that's good enough for I need to do. /Why Tea
Mat Posted September 26, 2009 Posted September 26, 2009 Doesn't highlight it? Thats the bit I thought WOULD work lol. Once you get to know how to use GUICtrlSendMsg you can do a lot more than you normally would be able to, so its good to read MSDN on it, I have got a similar thing to work before, and I think I used a similar code to that... I will look into it and post a better version soon! Mat AutoIt Project Listing
WhyTea Posted September 26, 2009 Author Posted September 26, 2009 On 9/26/2009 at 12:15 PM, 'Mat said: Doesn't highlight it? Thats the bit I thought WOULD work lol.Once you get to know how to use GUICtrlSendMsg you can do a lot more than you normally would be able to, so its good to read MSDN on it, I have got a similar thing to work before, and I think I used a similar code to that... I will look into it and post a better version soon!MatI'm looking forward to it. Thanks in advance!/Why Tea
Mat Posted September 26, 2009 Posted September 26, 2009 Weird, testng it now and the old code works fine... Run this and tell me what happens. #include<editConstants.au3> $hGUI = GUICreate ("Test", 200, 200) $hEdit = GUICtrlCreateEdit ("", 2, 2, 196, 196) For $i = 1 to 500 GUICtrlSetData ($hEdit, @CRLF & "This is line: " & $i & ".", 1) Next GUISetstate () Sleep (1000) _EditScrollAndHighliteLine ($hEdit, 250, $hGUI) Sleep (5000) Func _EditScrollAndHighliteLine ($hEdit, $nLine, $hGUI) GUICtrlSendMsg ($hEdit, $EM_LINESCROLL, 0, $nLine) $nIndex = GUICtrlSendMsg ($hEdit, $EM_LINEINDEX, $nLine, 0) $nLen = StringLen (ControlCommand ($hGUI, "", $hEdit, "GetLine", $nLine)) GUICtrlSendMsg ($hEdit, $EM_SETSEL, $nIndex, $nIndex + $nLen) EndFunc ; ==> _EditScrollAndHighliteLine Mat AutoIt Project Listing
Yashied Posted September 26, 2009 Posted September 26, 2009 On 9/26/2009 at 1:25 PM, 'Mat said: Weird, testng it now and the old code works fine... Run this and tell me what happens. #include<editConstants.au3> $hGUI = GUICreate ("Test", 200, 200) $hEdit = GUICtrlCreateEdit ("", 2, 2, 196, 196) For $i = 1 to 500 GUICtrlSetData ($hEdit, @CRLF & "This is line: " & $i & ".", 1) Next GUISetstate () Sleep (1000) _EditScrollAndHighliteLine ($hEdit, 250, $hGUI) Sleep (5000) Func _EditScrollAndHighliteLine ($hEdit, $nLine, $hGUI) GUICtrlSendMsg ($hEdit, $EM_LINESCROLL, 0, $nLine) $nIndex = GUICtrlSendMsg ($hEdit, $EM_LINEINDEX, $nLine, 0) $nLen = StringLen (ControlCommand ($hGUI, "", $hEdit, "GetLine", $nLine)) GUICtrlSendMsg ($hEdit, $EM_SETSEL, $nIndex, $nIndex + $nLen) EndFunc ; ==> _EditScrollAndHighliteLine Mat You do not need to use GUICtrlSendMsg(), all you need is present in the GUIEdit.au3 native AutoIt library. My UDFs: Reveal hidden contents iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Mat Posted September 26, 2009 Posted September 26, 2009 oh year!! completely forgot about that! Although in my defence, that UDF does just use SendMessage to get the job done... Thats a much easier way to do it, but its a bit less exciting, don't you think? Mat AutoIt Project Listing
Yashied Posted September 26, 2009 Posted September 26, 2009 On 9/26/2009 at 1:38 PM, 'Mat said: Thats a much easier way to do it, but its a bit less exciting, don't you think? Most certainly. My UDFs: Reveal hidden contents iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
WhyTea Posted September 27, 2009 Author Posted September 27, 2009 On 9/26/2009 at 1:25 PM, 'Mat said: Weird, testng it now and the old code works fine... Run this and tell me what happens. #include<editConstants.au3> $hGUI = GUICreate ("Test", 200, 200) $hEdit = GUICtrlCreateEdit ("", 2, 2, 196, 196) For $i = 1 to 500 GUICtrlSetData ($hEdit, @CRLF & "This is line: " & $i & ".", 1) Next GUISetstate () Sleep (1000) _EditScrollAndHighliteLine ($hEdit, 250, $hGUI) Sleep (5000) Func _EditScrollAndHighliteLine ($hEdit, $nLine, $hGUI) GUICtrlSendMsg ($hEdit, $EM_LINESCROLL, 0, $nLine) $nIndex = GUICtrlSendMsg ($hEdit, $EM_LINEINDEX, $nLine, 0) $nLen = StringLen (ControlCommand ($hGUI, "", $hEdit, "GetLine", $nLine)) GUICtrlSendMsg ($hEdit, $EM_SETSEL, $nIndex, $nIndex + $nLen) EndFunc ; ==> _EditScrollAndHighliteLine Mat Matt, your code work perfectly as it is. But when I called it from a button, it scrolled to the right line, but the line wasn't highlighted? Perhaps it's the highlighting color? When I manually selected the text it's the standard white on blue. /Why Tea
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