Jump to content

ILLBeBack

Active Members
  • Posts

    70
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ILLBeBack's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Please forget what I requested about dragging the Top and Left borders! No program that I've found with scrollbars works that way!
  2. LarsJ, Thank you very much for taking the time to look into the latest issues. I’ve run your new code, and indeed the repositioning of the controls no longer occurs. However, as you’ve stated, in order to achieve these results, the GUI is scrolled to the upper left upon completion of the Resizing, which is not ideal behavior. For example, if the GUI is scrolled to display a particular area of a GUI, that same area should be shown when the resizing is complete (plus or minus the area affected by the resize, depending upon which border was dragged). In other words, how your code in post #2 worked (but without the relocation of the controls). In the new version (your post 15), the GUI will have to be re-scrolled to the desired area after resizing. To that end, I registered $WM_EXITSIZEMOVE, which restores both scrollbars to their original positions after the resizing is complete. For this, I added code to func WM_ENTERSIZEMOVE to capture the scrollbar positions prior to resizing. While this appears to be functioning properly when the Bottom and/or Right hand borders are dragged in any direction, that’s not the case when the Left and Top borders are dragged inward, as the scrollbars should move accordingly in those cases. Any ideas how to resolve this issue would be appreciated. Again, thank you very much for your efforts! ILLBeBack ;; Something_Wrong_Between_Docking_and_GUI_ScrollBars.au3 ;; Notes: ;; 1. This script is based upon the example in the AutoIt help ;; file for UDF function _GUIScrollBars_Init. Similar effects ;; can be observed using that example, although the child GUIs ;; seem to behave correctly. ;; ;; 2. Melba23's UDF, "Scrollbars Made Easy" also exhibits issue #1, but not #2. ;; http://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-new-version-9-aug-14/ #include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> Global $hGUI, $iCharX, $iCharY, $fScroll = False Global $GiHPos, $GiVPos Example() Func Example() Local $hGUIMsg Local $iMaxHScroll = 425 Local $iMaxVScroll = 325 Local $iGUIHeight = 300 $hGUI = GUICreate("2 ScrollBar Issues", 400, $iGUIHeight, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) GUISetBkColor(0x88AABB) $b0 = GUICtrlCreateButton("0,0 x 100,40", 0, 0, 100, 40) GUICtrlSetResizing(-1, $GUI_DOCKALL) $b1 = GUICtrlCreateButton("Show Issue 1", 120, 0, 100, 40) GUICtrlSetResizing(-1, $GUI_DOCKALL) $b2 = GUICtrlCreateButton("Show Issue 2", 230, 0, 100, 40) GUICtrlSetResizing(-1, $GUI_DOCKALL) Local $sIssue1 = _ " 1. Start the script." & @LF & _ " 2. Note the location of the leftmost button is 0,0." & @LF & _ " 3. Drag the horizontal scroll bar a little to the right." & @LF & _ " The left button scrolls off the left side as it should." & @LF & _ " So far, all is well." & @LF & _ " 4. Drag the bottom of the GUI up or down, noting that the button" & @LF & _ " moves completely into view (it should NOT do that!)." & @LF & _ " This note moves too, just like the button." & @LF & _ " 5. Drag the horizontal scroll bar all the way to the left." & @LF & _ " 6. Note the location of the leftmost button and this note. " & @LF & _ " They're NOT where they should be. The leftmost button" & @LF & _ " should be at 0,0. Click that button to get its position." & @LF & _ " 7. Drag the bottom of the GUI up or down, " & @LF & _ " and the button repositions correctly." & @LF & _ " 8. The same thing happens with the vertical scroll bar," & @LF & _ " and/or combinations of dragging the GUI borders." & @LF & _ " 9. This is NOT an issue if the window cannot be resized." & @LF & _ "10. This same issue occurs in Melba23's 'Scrollbars Made Easy' UDF." Local $sIssue2 = _ " 1. The height of the vertical scroll bar thumb, and its maximum " & @LF & _ " range are incorrect. Since the height of the GUI is " & $iGUIHeight & ", and" & @LF & _ " function _GUIScrollBars_Init specifies the maximum vertical " & @LF & _ " value as " & $iMaxVScroll & ", the height of the thumb should be greater" & @LF & _ " then it is, and the movement should be very little, much like" & @LF & _ " the horizontal scroll bar." ;; Start with Issue 1 displayed in the label $l1 = GUICtrlCreateLabel($sIssue1, 60, 45, 400, 240) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetBkColor(-1, 0xffffff) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUIRegisterMsg($WM_ENTERSIZEMOVE, "WM_ENTERSIZEMOVE") GUIRegisterMsg($WM_ExitSIZEMOVE, "WM_ExitSIZEMOVE") GUISetState(@SW_SHOW) ;; _GUIScrollBars_Init($hGUI) ;; _GUIScrollBars_Init($hGUI, $iMaxHScroll, $iMaxVScroll) _GUIScrollBars_Init($hGUI) $iCharX = $__g_aSB_WindowInfo[0][2] $iCharY = $__g_aSB_WindowInfo[0][3] $__g_aSB_WindowInfo[0][0] = 0 _GUIScrollBars_Init($hGUI, -1, Round($iMaxVScroll / $iCharY)) ; $iMaxHScroll is calculated properly by _GUIScrollBars_Init While 1 $hGUIMsg = GUIGetMsg() Switch $hGUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $b0 Local $a1 = ControlGetPos("2 ScrollBar Issues", "", $b0) MsgBox(4096, "Button Position", "The position of this button is " & $a1[0] & "," & $a1[1]) Case $b1 ;; Display issue 1 GUICtrlSetData($l1, $sIssue1) Case $b2 ;; Display issue 2 GUICtrlSetData($l1, $sIssue2) EndSwitch WEnd Exit EndFunc ;==>Example Func WM_ENTERSIZEMOVE($hWnd, $iMsg, $wParam, $lParam) $fScroll = True $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_VERT) $GiVPos = DllStructGetData($tSCROLLINFO, "nPos") $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_HORZ) $GiHPos = DllStructGetData($tSCROLLINFO, "nPos") EndFunc ;; This function runs after the resizing is complete. Func WM_EXITSIZEMOVE($hWnd, $iMsg, $wParam, $lParam) _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_HORZ, $GiHPos) _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $GiVPos) EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) If $fScroll Then $fScroll = False Local $tSCROLLINFO ; Reset position of scroll box on horizontal scroll bar $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) DllStructSetData($tSCROLLINFO, "nPos", 0) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ; Reset position of scroll box on vertical scroll bar $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) DllStructSetData($tSCROLLINFO, "nPos", 0) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) EndIf ; Retrieve the dimensions of the client area. Local $iClientX = BitAND($lParam, 0x0000FFFF) Local $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[0][4] = $iClientX $__g_aSB_WindowInfo[0][5] = $iClientY ; Get vertical scroll bar info Local $vSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_VERT) Local $vMax = DllStructGetData($vSCROLLINFO, "nMax") Local $vPage = Int($iClientY / $iCharY) Local Static $vScrollBarHidden = ($vPage > $vMax) ; Get horizontal scroll bar info Local $hSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_HORZ) Local $hMax = DllStructGetData($hSCROLLINFO, "nMax") Local $hPage = Int($iClientX / $iCharX) Local Static $hScrollBarHidden = ($hPage > $hMax) ; Set vertical scroll bar info DllStructSetData($vSCROLLINFO, "nPage", $vPage) If $hScrollBarHidden <> ($hPage > $hMax) Then DllStructSetData($vSCROLLINFO, "nPos", 0) $hScrollBarHidden = ($hPage > $hMax) EndIf _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $vSCROLLINFO) ; Set horizontal scroll bar info DllStructSetData($hSCROLLINFO, "nPage", $hPage) If $vScrollBarHidden <> ($vPage > $vMax) Then DllStructSetData($hSCROLLINFO, "nPos", 0) $vScrollBarHidden = ($vPage > $vMax) EndIf _GUIScrollBars_SetScrollInfo($hGUI, $SB_HORZ, $hSCROLLINFO) Return $GUI_RUNDEFMSG ;Return 0 EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL
  3. M23, Thank you! I fully appreciate how complex scrollbars are, unfortunately. I'm looking at your code too, and just found where you are forcing the scrollbars back to their zero position (Kafu's technique, I think) in order to prevent the controls from shifting within the GUI after Resizing the GUI. Now I'm trying to determine why that's necessary, and how to defeat it. If I figure it out, I'll certainly let you know. I've been able to reproduce the misplacement of controls when using LarsJ's fix. Run his code, scroll the GUI all the way down, drag the bottom of the window down a little, scroll all the way back up, and see that the buttons are in the wrong place. The same is true in the horizontal direction if scrolled all the way to the right. If not scrolled to the horizontal or vertical limits, the misalignment does not occur. ILLBeBack
  4. 1. Sometimes LarsJ’s fix doesn’t work, and controls do shift around. Unfortunately, I’m unable to nail down what’s causing it. 2. As I stated, I was looking to see if anything had improved since LarsJ’s fix. That, of course, led me to your UDF. I hope I didn’t offend you because of that one thing I don’t like about your Scrollbars UDF, as I like it very much other than that, and I appreciate your making it available to the community. If I were smart enough, I would look into changing that behavior, but I’m not. 3. I responded to KingBob’s post because it missed the point that the controls actually do shift.
  5. Yes, what you say is correct, but that’s not the issue. The issue is if you Scroll, then Resize the window, then Scroll back, the controls have been repositioned away from their original positions. Compare the code provided in post 2, by LarsJ, against the code I posted (which was based upon the code in the help file). I’m only reviewing this post because I need Scrollbars again, and am looking to see if things have improved, as the help file still does not correctly handle resizing GUIs with Scrollbars. I see that Melba23 has added Resizing support to GUIScrollBars_Ex (click HERE). That appears to work. However, while resizing the window, the GUI temporarily shifts to display the controls in the upper left corner, and I am looking for a way around that as I find it distracting. Unfortunately, the bug report (ticket 2902) that I submitted 11 months ago was flagged 7 weeks ago as “Won’t Fix”, even though LarsJ fix was provided.
  6. M23, I finally found time to try your StringSize UDF, after your referral a few days ago on a post I made about “Automatic Height issue with GUI Labels and word wrap”. I'm writing to say the function is working perfectly, is incredibly well documented, and was very easy to implement. The only stuff I don’t understand are the DLL Calls (the heart of the function), but that’s my problem, and something I really should learn. Thanks M23 for sharing your work!
  7. Thanks M23! I'll look at your StringSize UDF later tonight!
  8. Can someone confirm that GuiCtrlCreateLabel does not calculate the correct height, when the height parameter is omitted (allowing the function to calculate the required height) and the width of the text string causes word wrapping. I find the description of the height parameter a bit unclear, but believe it should calculate the correct height if the height parameter is omitted, is –1, or is Default. It does so when a multi-line string (one containing @LF to avoid word wrapping), is used, but not if word wrapping occurs. Here’s a simple GUI demonstrating this issue: #include <GUIConstants.au3> GUICreate("Automatic Height issue with GUI Labels", 500, 380, -1, -1) $iY = 10 $sText = "When the height parameter for a GUI Label is not specified, or set to -1, or Default, the height " & @LF & _ "of the label is incorrect when word wrapping occurs. The height does not take into account " & @LF & _ "the number of lines added by the word wrapping! Below are examples demonstrating this" & @LF & _ "issue, what the label should look like ( @LF is used to avoid word wrapping )." & @LF & _ @LF & _ "The doc for GUICtrlCreateLabel says what follows for the height parameter:" GUICtrlCreateLabel($sText, 10, $iY, 450, Default) $iY += 80 GUICtrlCreateLabel(" height, [optional] The height of the control (default text autofit in height)", 10, $iY, 450, Default) GUICtrlSetFont(-1, -1, 600) GUICtrlSetColor(-1, 0x0000ff) $iY += 60 GUICtrlCreateLabel("Word Wrap Example (label height is incorrect)", 10, $iY, 450, Default, $SS_Center) GUICtrlSetFont(-1, 12, 600) GUICtrlSetColor(-1, 0xff0000) $iY += 20 ;; Word Wrap example: $sText = "This is an example showing that when the height parameter of a GuiCtlrCreateLabel " & _ "is set to -1, or left as optional, the height of the control does not take word " & _ "wrap into consideration, producing an incorrect height for the string." GUICtrlCreateLabel($sText, 10, $iY, 450, Default) GUICtrlSetBkColor(-1, 0xffff00) $iY += 40 GUICtrlCreateLabel("What the above should show (@LF used)", 10, $iY, 450, Default, $SS_Center) GUICtrlSetFont(-1, 12, 600) GUICtrlSetColor(-1, 0x0000ff) $iY += 20 $sText = "This is an example showing that when the height parameter of a GuiCtlrCreateLabel is set to -1," & @LF & _ "or left as optional, the height of the control does not take word wrap into consideration," & @LF & _ "producing an incorrect height for the string." GUICtrlCreateLabel($sText, 10, $iY, 450, Default) GUICtrlSetBkColor(-1, 0xffff00) $iY += 90 $sText = "While the height produced when @LF is used to avoid word wrapping does not cut off text, " & @LF & _ "the height is a little too large by about 1/2 line height." GUICtrlCreateLabel($sText, 10, $iY, 450, Default) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit
  9. I'm sorry, but doesn't the attached script in post 1 reproduce the issue?
  10. Thanks LarsJ! I submitted a bug report, ticked #2902: https://www.autoitscript.com/trac/autoit/ticket/2902
  11. Thanks LarsJ. Nice job coding around the issues! I see you’ve completely rewritten Func WM_SIZE. Hopefully this gets corrected in the AutoIt help file. Do you have anything to do with getting that accomplished? The same WM_SIZE coding also appears in the examples for functions _GUIScrollBars_SetScrollInfo and _GUIScrollBars_ScrollWindow. Also, it appears that UDF function _GUIScrollBars_Init needs to be modified so that specifying the maximum vertical scroll value is straight forward, just like the horizontal value. Having to call that function twice, with calculations between them to determine the values of $iCharX and $iCharY (as quoted below) is not very intuitive. I've tested your coding in v3.3.12.0 and 3.3.13.19 beta, and both work perfectly.
  12. While playing with the example in the help file for the UDF on “GUI Scroll Bars”, I’ve encountered 2 issues as follow: 1. When the GUI is resizable (not done in the help file examples), resizing the GUI, after scrolling horizontally or vertically, causes all objects in the GUI to reposition within the GUI. 2. The vertical Scroll Bar thumb size, and the maximum movement are incorrect. Issue #1 also occurs with Melba23’s “Scrollbars Made Easy” UDF (?do=embed' frameborder='0' data-embedContent>'?do=embed' frameborder='0' data-embedContent> title="?do=embed' frameborder='0' data-embedContent>">?do=embed' frameborder='0' data-embedContent>). Issue #2 does not. Attached is a script that describes each step to reproduce the issues. Use the buttons “Show Issue 1” and "Show Issue 2” to display the steps to follow for each issue. Just perform those steps in the order given. The script is based upon the example for UDF function _GUIScrollBars_Init, with modifications to the GUI section, but no modifications to functions WM_SIZE, WM_HSCROLL or WM_VSCROLL. Same results in AutoIt v3.3.12.0 and 3.3.13.19 beta. If I’m doing something wrong, or overlooking something, please advise. ILLBeBackSomething_Wrong_Between_Docking_and_GUI_ScrollBars.au3
  13. Thanks water, I didn't know this. FYI, Some controls are not supported by Koda, and will not import. For example, the RichEdit control provided by the UDF <GuiRichEdit.au3>.
  14. According to the doc, _GUICtrlRichEdit_GetFont should return an empty string when the selection contains mixed font. This makes sense, and is similar to what happens in VB for RichText. However, this is not what happens. Instead, the name of the font at the start of the selection is returned (depends on direction of selection). The example script below will demonstrate this. When started, the 3 lines of text in the RichEdit box will be selected. Each line is a different font face. WIth all 3 lines selected, click the button to show the font face (in the label below the RichEdit) that is returned by _GUICtrlRichEdit_GetFont. It also demonstrates a second issue, that being the inability to make another selection after _GUICtrlRichEdit_GetFont is used. Note: The 2nd issue is related to the “invisible selection” issue reported at http://www.autoitscript.com/forum/topic/154905-selection-goes-invisible-after-guictrlrichedit-getfont/ #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $lblMsg, $hRichEdit Example() Func Example() Local $hGui, $iMsg, $btnNext, $sMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 370, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is the default font of this RichEdit box." & @CR, 10, 10, 330, 120, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $lblMsg = GUICtrlCreateLabel(@LF & "Leave all text selected and click the button.", 10, 135, 330, 175) GUICtrlSetBkColor(-1, 0xffffd5) $btnNext = GUICtrlCreateButton(" Click Me to list the font face of the selection ", 75, 320) GUISetState() _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Comic Sans MS") _GUICtrlRichEdit_AppendText($hRichEdit, "This is Comic Sans MS" & @CR) _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Times New Roman") _GUICtrlRichEdit_AppendText($hRichEdit, "This is Times New Roman" & @CR) _GUICtrlRichEdit_SetSel($hRichEdit, 0, 100, False) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes Exit Case $iMsg = $btnNext Local $aRet = _GUICtrlRichEdit_GetFont($hRichEdit) $sMsg = "The selection is font face " & $aRet[1] & "," & @LF & _ "but there are 3 fonts in the selection, and _GUICtrlRichEdit_GetFont" & @LF & _ "should have returned an empty string per the doc." & @LF & _ @LF & _ "Instead, it returned the font face at the start of the selecton." & @LF & _ @LF & _ "Next, select what you'd like and press button to see what happens." & @LF & _ "That leads to issue #2, which is, after _GUICtrlRichEdit_GetFont" & @LF & _ "the selection is invisible, and it's difficult to make another" & @LF & _ "selection. Before a selection can be made, click anywhere on the" & @LF & _ "text in the RichEdit box, then click the button. Then you'll be" & @LF & _ "able to make another selection, and the issues repeat. Try various" & @LF & _ "selections (right to left, one font through another, etc." GUICtrlSetData($lblMsg, $sMsg) EndSelect WEnd EndFunc ;==>Example Exit Anyone have any thoughts? Should I report this a a bug?
  15. In a RichEdit control, the selection goes invisible (not the text, the highlighting) after using UDF _GUICtrlRichEdit_GetFont. The selection remains invisible even if _GUICtrlRichEdit_SetSel is used afterwards. The script below will demonstrate this. Run the script and click the button to get started. A series of message boxes will pause the script at each step for verification. Can someone please confirm this. #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hRichEdit, $hGui, $iMsg, $btnNext, $aFontAtts $hGui = GUICreate("_GUICtrlRichEdit_GetFont", 300, 150, (@DesktopWidth - 300) / 2, 100) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Selection NOT visible after _GUICtrlRichEdit_GetFont", 10, 10, 300, 90, BitOR($ES_MULTILINE, $ES_NOHIDESEL)) $btnNext = GUICtrlCreateButton(" Click Me To Start ", 110, 110) GUISetState() While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $iMsg = $btnNext GUICtrlSetState($btnNext, $GUI_DISABLE) _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) ; <<<< Selection is visible. MsgBox(4096, "1", "The word 'Selection' should be visually selected!") $aFontAtts = _GUICtrlRichEdit_GetFont($hRichEdit) ; <<<< Causes selection to go invisible. MsgBox(4096, "2", _ "The UFD _GUICtrlRichEdit_GetFont function was called." & @LF & _ "Is the word 'Selection' still visually selected?" & @LF & _ "It should be, but it's not." & @LF & _ @LF & _ "It's actually selected, although not visually." & @LF & _ @LF & _ "Click OK to do _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9).") _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) ; <<<< Setting Seletion again does not make selecion visible. ; _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9, False) ; <<<< Setting Seletion again does not make selecion visible. MsgBox(4096, "3", _ "Is the word 'Selection' selected?" & @LF & _ "_GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) was called" & @LF & _ "but the selection is still invisible." & @LF & _ @LF & _ "Even if _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9, False)" & @LF & _ "is called, the selection is still invisible." & @LF & _ @LF & _ "Click OK and it's back to visually selected (I don't know why).") EndSelect WEnd Exit
×
×
  • Create New...