Jump to content

Search the Community

Showing results for tags 'edit control'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. I'm trying to get Word Wrap under (Format) to work in the program below and feel like the blind squirrel not finding the nut. The program has a built in string for testing and will accept drag and drop. I've tried combinations of GUICtrlSetStyle that I thought would work and searched the forum and nada. This blind squirrel needs some help. #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration ;Hack for Word Wrap v3c.au3 #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WindowsConstants.au3> Global $data = "", $file = "", $hGUI, $cEdit $hGUI = GUICreate("GUI Window", 920, 570, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX), BitOR($WS_EX_CLIENTEDGE, $WS_EX_ACCEPTFILES)) ;handle $cEdit = GUICtrlCreateEdit("", 10, 10, 800, 455, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_NOHIDESEL)) ;control ID ;normally I have the $cEdit occupying the full size of the client region of $hGUI - border here to make sure we can see what's happening GUICtrlSetState($cEdit, $GUI_DROPACCEPTED) ;allow drag and drop GUICtrlSetFont($cEdit, 10, 400, 0, "Courier New") ;change default font GUISetState(@SW_SHOW, $hGUI) ;Format Menu Local $idFormatMenu = GUICtrlCreateMenu("F&ormat") ;Create the Format menu. Underline o when Alt is pressed. ;sub-menus Local $idFormatMenu_WordWrap = GUICtrlCreateMenuItem("&Word Wrap" &@TAB& "", $idFormatMenu) ;Create the "Word Wrap" menu item. Underline W when Alt is pressed. $data = "8e4t9qn0rgup3qrelm0b9emp9061abjm9n9tyv44m2edpbfj1svwulpe02dcwjdqcyyajru4dfyfk8w0anlk86t335qcoeekm2baxv40nzqs9ka65lo09su8omqaw7" ;for testing _GUICtrlEdit_SetText($cEdit, $data) GUISetState(@SW_SHOW) ;display the GUI Local $nMsg While 1 $nMsg = GUIGetMsg() If $nMsg <> 0 Then Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idFormatMenu_WordWrap _WordWrap() Case $GUI_EVENT_DROPPED _GUICtrlEdit_SetText($cEdit, FileRead(@GUI_DragFile)) ;read and set the data to be displayed EndSwitch EndIf WEnd Func _WordWrap() If BitAND(GUICtrlRead($idFormatMenu_WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then ;turn off Word Wrap GUICtrlSetState($idFormatMenu_WordWrap, $GUI_UNCHECKED) ;uncheck Word Wrap GUICtrlSetStyle($cEdit, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_NOHIDESEL)) ;<- original style Else GUICtrlSetState($idFormatMenu_WordWrap, $GUI_CHECKED) ;turn on Word Wrap and show checked ;I can't seem to find the correct combination to get the text to Word Wrap. Check the forum and tried these. ;GUICtrlSetStyle($cEdit, $GUI_SS_DEFAULT_EDIT) ;does not work ;GUICtrlSetStyle($cEdit, $ES_AUTOVSCROLL) ;does not work ;GUICtrlSetStyle($cEdit, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) ;does not work but gets rid of hscroll till resize GUI Window then hscroll reappears ;GUICtrlSetStyle($cEdit, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) ;does not work and gets rid of vscroll and hscroll ;GUICtrlSetStyle($cEdit, $ES_AUTOVSCROLL) ;does not work ;GUICtrlSetStyle($cEdit, -1) ;does not work ;GUICtrlSetStyle($cEdit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) ;does not work ;GUICtrlSetStyle($cEdit, $GUI_SS_DEFAULT_EDIT) ;does not work ;GUICtrlSetStyle($cEdit, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_NOHIDESEL)) ;does not work ;GUICtrlSetStyle($cEdit, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_NOHIDESEL)) ;does not work and as soon as resize GUI the hscroll reappears GUICtrlSetStyle($cEdit, BitOR($GUI_SS_DEFAULT_EDIT, $WS_VSCROLL)) ;does not work ;This blind squirrel needs help EndIf EndFunc
  2. the concept comes from someone else here, though i forget who (if you, let me know and i'll be glad to give credit) rather than toggling line wrapping on and off in an AutoIt multi-line edit control, which apparently is not doable, this function destroys and recreates the control, preserving various aspects of the original it works by creating the new control with or without a horizontal scroll bar ($WS_HSCROLL) i'm no pro, so critique is welcome #include-once #include <WinAPI.au3> #include <GUIEdit.au3> #include <WindowsConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _EditCtrl_ToggleLineWrap ; Version .......; 1.1 (29-Jan-2014) ; Description ...: toggle line wrapping for an AutoIt multi-line edit control ; Syntax ........: _EditCtrl_ToggleLineWrap($hWnd, $iCtrlID[, $iResize = $GUI_DOCKAUTO[, $iChars = 999999[, $sFont = ""[, $hexColor = 0x000000[, $hexBgColor = 0xFFFFFF]]]]]) ; Parameters ....: $hWnd - handle to parent window ; $iCtrlID - edit control ID ; $iResize - [optional] (integer) edit control resizing value for GUICtrlSetResizing() - def=$GUI_DOCKAUTO ; $iChars - [optional] (integer) edit control max chars - def=999999 ; $sFont - [optional] (string) "|" seperated string 4 of parameters for GUICtrlSetFont() (size, weight, attribute, fontname) - def="" ; $hexColor - [optional] (hex) font color - def=0x000000 (black) ; $hexBgColor - [optional] (hex) edit control background color - def=0xFFFFFF (white) ; Return values .: -1 = Error ; : 0 = Wrapping off ; : 1 = Wrapping on ; Author ........: iCode ; Modified ......: 1-JAN-2014 ; Remarks .......: tested with AutoIt 3.3.10.2 ; : it appears that if the edit control is too close to the GUI border, it can be re-created with entirely wrong dimentions ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _EditCtrl_ToggleLineWrap($hWnd, $iCtrlID, $iResize = 1, $iChars = 999999, $sFont = "", $hexColor = 0x000000, $hexBgColor = 0xFFFFFF) Local $return, $aFont Local $string = GUICtrlRead($iCtrlID) Local $aCtrlPos = ControlGetPos($hWnd, "", $iCtrlID) If @error Or $aCtrlPos[2] < 1 Or $aCtrlPos[3] < 1 Then Return -1 Local $hCtrl = GUICtrlGetHandle($iCtrlID) If $hCtrl = 0 Then Return -1 Local $ctrlStyle = _WinAPI_GetWindowLong($hCtrl, $GWL_STYLE) If @error Then Return -1 Local $ctrlExStyle = _WinAPI_GetWindowLong($hCtrl, $GWL_EXSTYLE) If @error = 10 Then $ctrlExStyle = 0 Local $iMod = _GUICtrlEdit_GetModify($hCtrl) Local $aSel = _GUICtrlEdit_GetSel($hCtrl) Local $iLines = _GUICtrlEdit_GetFirstVisibleLine($hCtrl) GUICtrlDelete($iCtrlID) If BitAND($ctrlStyle, $WS_HSCROLL) Then $iCtrlID = GUICtrlCreateEdit("", $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3], $ctrlStyle - $WS_HSCROLL, $ctrlExStyle) $return = 1 Else $iCtrlID = GUICtrlCreateEdit("", $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3], $ctrlStyle + $WS_HSCROLL, $ctrlExStyle) $return = 0 EndIf GUICtrlSetResizing($iCtrlID, $iResize) GUICtrlSetBkColor($iCtrlID, $hexBgColor) GUICtrlSetColor($iCtrlID, $hexColor) If $sFont <> "" Then $aFont = StringSplit($sFont, "|") If $aFont[0] = 4 Then GUICtrlSetFont($iCtrlID, $aFont[1], $aFont[2], $aFont[3], $aFont[4]) EndIf EndIf GUICtrlSetLimit($iCtrlID, $iChars) GUICtrlSetData($iCtrlID, $string) _GUICtrlEdit_LineScroll($iCtrlID, 0, $iLines) _GUICtrlEdit_SetSel($iCtrlID, $aSel[0], $aSel[1]) _GUICtrlEdit_SetModify($iCtrlID, $iMod) Return $return EndFunc CHANGE LOG 29-Jan-2014 * fixed a bug that could cause incorrect extra style to be applied to edit control 1-Jan-2014 * restores the scroll position to the current line number * very minor changes 29-Dec-2013 * swapped the return values - they were backwards 28-Dec-2013 * include Martins suggestion to restore character selection * added check of edit control size to avoid problems if the control is less than 1x1 px
  3. Hi, I'm surprised about the behavior of controlsend to the edit control when using subclassing: #include <constants.au3> #include <windowsconstants.au3> #include <gdiplus.au3> #include <guiconstantsex.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("Test", 602, 198, 192, 124) Global Const $idEdit = GUICtrlCreateEdit("", 0, 0, 601, 145) GUICtrlSetFont($idEdit, 10, 400, 0, "Lucida Console") Global Const $hEdit = GUICtrlGetHandle($idEdit) Global Const $idButton1 = GUICtrlCreateButton("Send 2 Edit", 8, 160, 75, 25) Global Const $idButton2 = GUICtrlCreateButton("Exit", 520, 160, 75, 25) Global Const $hBitmap = CreateCaretBitmap() Global Const $iBlinkTime_save = DllCall('user32.dll', 'int', 'GetCaretBlinkTime') Global Const $iBlinkTime = Int($iBlinkTime_save[0] * 0.9) Global Const $hCaretProc = DllCallbackRegister("CaretProc", "ptr", "hwnd;uint;long;ptr") Global Const $hOldCaretProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hCaretProc)) GUISetState(@SW_SHOW) Global $hEditWndProc = DllCallbackRegister("EditWndProc", "long", "hwnd;uint;wparam;lparam") Global $hOldEditProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hEditWndProc)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton2 DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $iBlinkTime_save[0]) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $hOldCaretProc) DllCallbackFree($hCaretProc) _WinAPI_DeleteObject($hBitmap) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $hOldEditProc) DllCallbackFree($hEditWndProc) _GDIPlus_Shutdown() Exit Case $idButton1 ControlFocus($hGUI, "", $idEdit) ControlSend($hGUI, "", $idEdit, "This is a TEST" & @LF) EndSwitch WEnd Func EditWndProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_KEYDOWN ConsoleWrite("A key was pressed" & @LF) EndSwitch Return _WinAPI_CallWindowProc($hOldEditProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>EditWndProc Func CaretProc($hWnd, $iMsg, $wParam, $lParam) Local $iRet = _WinAPI_CallWindowProc($hOldCaretProc, $hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_SETFOCUS DllCall('user32.dll', 'int', 'CreateCaret', 'hwnd', $hWnd, 'ptr', $hBitmap, 'int', 0, 'int', 0) DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', $hWnd) DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $iBlinkTime) Case $WM_KILLFOCUS DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', $hWnd) DllCall('user32.dll', 'int', 'DestroyCaret') DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $iBlinkTime_save[0]) EndSwitch Return $iRet EndFunc Func CreateCaretBitmap($iW = 9, $iH = 14, $iColor = 0xFFC0C0C0) Local Const $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local Const $hBitmap = $aResult[6] Local Const $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor) _GDIPlus_GraphicsFillRect($hCtx, 0, $iH - 3, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hCtx) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBitmap EndFunc When you press the "Send 2 Edit" the string "This is a TEST" & @LF will be sent to the edit control but reversed! When you e.g. disable the 1st DllCallbackRegister() then it is working as expected. Any explanation for this behavior? Br, UEZ
×
×
  • Create New...