step887 Posted August 10, 2012 Share Posted August 10, 2012 I tried to use Melba23's GuiFrames, but I could not get it to work with richtext edit.. So coded my own version, and it works, but the issue is when I moved the dragbar, it flickers sometimes when there is a gui bkcolor specify...not a major issue, but an annoyance.. So I am looking for some feedback on how I might be able to do improve this Thanks in advance expandcollapse popup#include <WindowsConstants.au3> #include <Guirichedit.au3> #include <GUIConstantsEx.au3> Global $width = 300;of gui Global $height = 600;of gui Global $border = 6;around edit boxes Global $percent_height = .5;percentage of per each box Global $max_upper_height_percent = .2;set the upper limit that dragbox can be move too Global $max_lower_height_percent = .8;set the lower limit that dragbox can move too global $edit1_width, $edit1_height, $edit2_top, $edit2_height, $dragbar = False GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUIRegisterMsg($WM_SIZE, 'my_Resize') $bgcolor = _random_color();got bored and wanted varity _Update_values();I used this because when the height and width changed, the values did not update $GUI = GUICreate("My GUI", $width, $height, Default, Default, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetBkColor($bgcolor) $Edit1 = _GUICtrlRichEdit_Create($GUI, "", $border, $border, $edit1_width, $edit1_height, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $edit2 = GUICtrlCreateEdit("", $border, $edit2_top, $edit1_width, $edit2_height, BitOr("Ox503310C4", $WS_VSCROLL)) GUICtrlSetResizing(-1, $GUI_DOCKALL);did not want the gui to control resizing $label = GUICtrlCreateLabel("", 0, $border + $edit1_height, $width, $border, 0x0100) GUICtrlSetBkColor(-1, _random_color());set the dragbar to different color GUICtrlSetCursor(-1, 11);set to show up/down arrow GUICtrlSetResizing(-1, $GUI_DOCKALL);did not want the gui to control resizing GUISetState() Do If $dragbar = True Then; set by my_wm_command While _IsPressed("01");while left mouse button is pressed $arr = GUIGetCursorInfo($GUI) If _mousemove($arr[1]) Then;did not want to do anything unless mouse is moved If $arr[1] > $height * $max_upper_height_percent = .2 And $arr[1] < $height * $max_lower_height_percent Then;; limit the dragbar _WinAPI_MoveWindow($Edit1, $border, $border, $edit1_width, $arr[1] - $border); move rich edit box GUICtrlSetPos($label, 0, $arr[1], $width);move label --ie dragbar GUICtrlSetPos($edit2, $border, $arr[1] + $border, $edit1_width, $height - ($arr[1] - $border) - $border * 3);move regular edit box EndIf EndIf Wend $arr = GUIGetCursorInfo($GUI);get final postion of mouse $percent_height = ($arr[1] - $border) / $height;update the new percent height _Update_values() $dragbar = False EndIf until GUIGetMsg() = -3 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) local $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) If $nNotifyCode = $STN_CLICKED Then $dragbar = True Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func my_Resize($hWnd, $iMsg, $iwParam, $lParam) $height = BitShift($lParam, 16) $width = BitAND($lParam, 0xFFFF) _Update_values() _WinAPI_MoveWindow($Edit1, $border, $border, $edit1_width, $edit1_height) GUICtrlSetPos($edit2, $border, $edit2_top, $edit1_width, $edit2_height) GUICtrlSetPos($label, 0, $border + $edit1_height, $width, $border) Return 'GUI_RUNDEFMSG' EndFunc ;==>my_Resize Func _Update_values() $edit1_width = $width - $border * 2 $edit1_height = ($height - $border * 3) * $percent_height $edit2_top = $edit1_height + $border * 2 $edit2_height = $height - $edit1_height - $border * 3 EndFunc ;==>_Update_values Func _mousemove($orig) local $ret = GUIGetCursorInfo($GUI) If $orig = $ret[1] Then Return False Return True EndFunc ;==>_mousemove Func _random_color() local $i = "0x", $data = "1234567890abcdef" $data = StringSplit($data, "") for $c = 1 to 6 $i &= $data[Random(0, $data[0], 1)] Next Return $i EndFunc ;==>_random_color Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 10, 2012 Moderators Share Posted August 10, 2012 step887, I have no problem using my UDF with a RichEdit if I do it like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIRichEdit.au3> #include <GUIFrame.au3> Global $fChanged = False $hGUI = GUICreate("Test", 300, 600) ; Create a 1st level frame $iFrame_A = _GUIFrame_Create($hGUI, 1) GUISetState() ; Create the 2 edits _GUIFrame_Switch($iFrame_A, 1) $hTopFrame = _GUIFrame_GetHandle($iFrame_A, 1) $aWinSize = WinGetClientSize($hTopFrame) $hEdit1 = _GUICtrlRichEdit_Create($hTopFrame, "", 5, 5, $aWinsize[0] - 10, $aWinsize[1] - 10, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUIFrame_Switch($iFrame_A, 2) $hBottomFrame = _GUIFrame_GetHandle($iFrame_A, 2) $aWinSize = WinGetClientSize($hBottomFrame) $cEdit2 = GUICtrlCreateEdit("", 5, 5, $aWinsize[0] - 10, $aWinsize[1] - 10, BitOR("Ox503310C4", $WS_VSCROLL)) _GUIFrame_ResizeSet(0) ; Register the SIZE message to look for the seperator bar moving GUIRegisterMsg($WM_SIZE, "_WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; See if the frame has been resized If $fChanged = True Then ; Clear the flag $fChanged = False ; Resize the RichEdit $aWinSize = WinGetClientSize($hTopFrame) WinMove($hEdit1, "", 5, 5, $aWinsize[0] - 10, $aWinsize[1] - 10) EndIf WEnd Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Do the normal resizing frame resizing _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam) ; Set the flag if the top frame has been resized If $hWnd = $hTopFrame Then $fChanged = True EndIf EndFunc Does that help? As to the flickering, I have been trying to solve that problem for ages without success. Please let me know if you ever find a solution. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
step887 Posted August 10, 2012 Author Share Posted August 10, 2012 Thanks Melba, I try to do it that way (i think.. that was a couple days ago), but I could never get the richtext edit to appear.. And if you can not get the flickering to disappear then I sure I will not be able too. Link to comment Share on other sites More sharing options...
step887 Posted August 12, 2012 Author Share Posted August 12, 2012 Melba,So I think I found the answer.. I stumbled on to thishttp://www.catch22.net/tuts/flicker-free-drawingBasically, when you set the gui background and then you put a control on top, each time you resize, windows has to redraw the background color, which causes the flickerSo what I did in previous example, I did not set GUISetBkColor, instead I created labels for the borders and now I do not see the flicker..expandcollapse popup#include <WindowsConstants.au3> #include <Guirichedit.au3> #include <GUIConstantsEx.au3> Global $width = 300;of gui Global $height = 600;of gui Global $border = 6;around edit boxes Global $percent_height = .5;percentage of per each box Global $max_upper_height_percent = .2;set the upper limit that dragbox can be move too Global $max_lower_height_percent = .8;set the lower limit that dragbox can move too Global $edit1_width, $edit1_height, $edit2_top, $edit2_height, $dragbar = False GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUIRegisterMsg($WM_SIZE, 'my_Resize') $bgcolor = _random_color();got bored and wanted varity _Update_values();I used this because when the height and width changed, the values did not update $GUI = GUICreate("My GUI", $width, $height, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX,$WS_POPUPWINDOW)) ;>>>added borders and did not set the gui color $top_border = GUICtrlCreateLabel("",0,0,$width,$border) GUICtrlSetBkColor(-1,$bgcolor) GUICtrlSetResizing(-1, $GUI_DOCKALL) $left_border = GUICtrlCreateLabel("",0,0,$border,$height) GUICtrlSetBkColor(-1,$bgcolor) GUICtrlSetResizing(-1, $GUI_DOCKALL) $bottom_border = GUICtrlCreateLabel("",0,$height-($border),$width,$border) GUICtrlSetBkColor(-1,$bgcolor) GUICtrlSetResizing(-1, $GUI_DOCKALL) $right_border = GUICtrlCreateLabel("",$width - ($border),0,$border,$height) GUICtrlSetBkColor(-1,$bgcolor) GUICtrlSetResizing(-1, $GUI_DOCKALL) ;end adding borders $Edit1 = _GUICtrlRichEdit_Create($GUI, "", $border, $border, $edit1_width, $edit1_height, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetBkColor($edit1, _random_color()) $edit2 = GUICtrlCreateEdit("", $border, $edit2_top, $edit1_width, $edit2_height, BitOR("Ox503310C4", $WS_VSCROLL)) GUICtrlSetBkColor(-1,_random_color()) GUICtrlSetResizing(-1, $GUI_DOCKALL);did not want the gui to control resizing $label = GUICtrlCreateLabel("", 0, $border + $edit1_height, $width, $border, 0x0100) GUICtrlSetBkColor(-1, _random_color());set the dragbar to different color GUICtrlSetCursor(-1, 11);set to show up/down arrow GUICtrlSetResizing(-1, $GUI_DOCKALL);did not want the gui to control resizing GUISetState() Do If $dragbar = True Then; set by my_wm_command While _IsPressed("01");while left mouse button is pressed $arr = GUIGetCursorInfo($GUI) If _mousemove($arr[1]) Then;did not want to do anything unless mouse is moved If $arr[1] > $height * $max_upper_height_percent = .2 And $arr[1] < $height * $max_lower_height_percent Then;; limit the dragbar _WinAPI_MoveWindow($Edit1, $border, $border, $edit1_width, $arr[1] - $border); move rich edit box GUICtrlSetPos($label, 0, $arr[1], $width);move label --ie dragbar GUICtrlSetPos($edit2, $border, $arr[1] + $border, $edit1_width, $height - ($arr[1] - $border) - $border * 3);move regular edit box EndIf EndIf WEnd $arr = GUIGetCursorInfo($GUI);get final postion of mouse $percent_height = ($arr[1] - $border) / $height;update the new percent height _Update_values() $dragbar = False EndIf Until GUIGetMsg() = -3 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) If $nNotifyCode = $STN_CLICKED Then $dragbar = True Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func my_Resize($hWnd, $iMsg, $iwParam, $lParam) $height = BitShift($lParam, 16) $width = BitAND($lParam, 0xFFFF) _Update_values() _WinAPI_MoveWindow($Edit1, $border, $border, $edit1_width, $edit1_height) GUICtrlSetPos($edit2, $border, $edit2_top, $edit1_width, $edit2_height) GUICtrlSetPos($label, 0, $border + $edit1_height, $width, $border) GUICtrlSetPos($top_border,0,0,$width,$border) GUICtrlSetPos($left_border,0,0,$border,$height) GUICtrlSetPos($bottom_border,0,$height-($border),$width,$border) GUICtrlSetPos($right_border,$width - ($border),0,$border,$height) Return 'GUI_RUNDEFMSG' EndFunc ;==>my_Resize Func _Update_values() $edit1_width = $width - $border * 2 $edit1_height = ($height - $border * 3) * $percent_height $edit2_top = $edit1_height + $border * 2 $edit2_height = $height - $edit1_height - $border * 3 EndFunc ;==>_Update_values Func _mousemove($orig) Local $ret = GUIGetCursorInfo($GUI) If $orig = $ret[1] Then Return False Return True EndFunc ;==>_mousemove Func _random_color() Local $i = "0x", $data = "1234567890abcdef" $data = StringSplit($data, "") For $c = 1 To 6 $i &= $data[Random(0, $data[0], 1)] Next Return $i EndFunc ;==>_random_color Link to comment Share on other sites More sharing options...
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