msmith11 Posted November 3, 2014 Share Posted November 3, 2014 Simple code. Nothing elegant. Can't figure why adding a rectangle to a control disables some of the control buttons. Try activating the rectangle at line 21 and see what happens. On my system it shuts off the top 2 buttons. Buttons are linked to dummy messages just for testing activation. Code has been simplified just to exhibit the problem. Thanks so much for your input. expandcollapse popup;Func Display #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ColorConstantS.au3> Opt('MustDeclareVars', 1) Local $a_PositionLines[7][8] ;define the array holding the current stock Position information Local $msg Local $h_GUIWindow = GUICreate("Position Alerts", 745, 340 ) GUISetBkColor ( 0xFFCCCC ) Local $sFont = "Liberation Sans" Local $n_GridColor = 0x660000 #cs ;start horizontal grid lines...using rectangles for thickness Local $n_hLine1 = GUICtrlCreateGraphic(0, 0) ;First horizontal line. set to 0, 0 actual start position and length controlled in GUICtrlSetGraphic GUICtrlSetGraphic( $n_hLine1, $GUI_GR_COLOR, $n_GridColor, $n_GridColor ) GUICtrlSetGraphic( $n_hLine1, $GUI_GR_RECT, 10, 35, 725, 2 ) #ce ;start label row Local $h_Symbol = GUICtrlCreateLabel("Name", 25, 13, 50, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("Type", 100, 13, 40, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("%Change", 160, 13, 60, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("Entry", 236, 13, 80, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("Current", 331, 13, 90, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("Base", 433, 13, 85, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("%Change", 535, 13, 60, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) Local $h_Symbol = GUICtrlCreateLabel("Set", 645, 13, 55, 20, $SS_CENTER) GUICtrlSetFont ( $h_Symbol, 8, 700, 4, $sFont ) ;end label row ;Define Buttons Local $h_Row1Symbol = GUICtrlCreateButton("But1", 15, 46, 70, 30) GUICtrlSetFont ( $h_Row1Symbol, 10, 0, 1, $sfont ) ;Position #2 Local $h_Row2Symbol = GUICtrlCreateButton("But2", 15, 96, 70, 30) GUICtrlSetFont ( $h_Row2Symbol, 10, 0, 1, $sfont ) ;Position #3 Local $h_Row3Symbol = GUICtrlCreateButton("But3", 15, 146, 70, 30) GUICtrlSetFont ( $h_Row3Symbol, 10, 0, 1, $sfont ) ;Position #4 Local $h_Row4Symbol = GUICtrlCreateButton("But4", 15, 196, 70, 30) GUICtrlSetFont ( $h_Row4Symbol, 10, 0, 1, $sfont ) ;Position #5 Local $h_Row5Symbol = GUICtrlCreateButton("But5", 15, 246, 70, 30) GUICtrlSetFont ( $h_Row5Symbol, 10, 0, 1, $sfont ) ;Position #6 Local $h_Row6Symbol = GUICtrlCreateButton("But6", 15, 296, 70, 30) GUICtrlSetFont ( $h_Row6Symbol, 10, 0, 1, $sfont ) GUISetState( @SW_SHOW, $h_GUIWindow) ;Run the GUI until the window is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $h_Row1Symbol MsgBox(0, 'Button 1', '#1 button was pressed') Case $msg = $h_Row2Symbol MsgBox(0, 'Button 2', '#2 button was pressed') Case $msg = $h_Row3Symbol MsgBox(0, 'Button 3', '#3 button was pressed') Case $msg = $h_Row4Symbol MsgBox(0, 'Button 4', '#4 button was pressed') Case $msg = $h_Row5Symbol MsgBox(0, 'Button 5', '#5 button was pressed') Case $msg = $h_Row6Symbol MsgBox(0, 'Button 6', '#6 button was pressed') EndSelect WEnd Link to comment Share on other sites More sharing options...
msmith11 Posted November 3, 2014 Author Share Posted November 3, 2014 Maybe you'd like to know this form is mostly static by design and being data driven from a file to array load that is managed elsewhere. The buttons are the only active control. The rectangle is actually being used as a thickened line to develop grid lines on the form to create a spreadsheet look Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2014 Moderators Share Posted November 3, 2014 msmith11,You are not defining a size for the graphic control when you create it - so you get the default size which, as you can see if you add colour, overlaps the top 2 buttons:;start horizontal grid lines...using rectangles for thickness Local $n_hLine1 = GUICtrlCreateGraphic(0, 0) GUICtrlSetBkColor($n_hLine1, 0xCCFFCC) ; Colour the graphicThe solution is to correctly size the graphic control and adjust the coordinates of the line:Local $n_hLine1 = GUICtrlCreateGraphic(10, 35, 725, 2) ; Set correct size and location GUICtrlSetGraphic( $n_hLine1, $GUI_GR_COLOR, $n_GridColor, $n_GridColor ) GUICtrlSetGraphic( $n_hLine1, $GUI_GR_RECT, 0, 0, 725, 2 ) ; Coordinates relative to graphic controlNow there is no overlap and the buttons work again. Top Tip: As soon as controls become inactive after another control is added - suspect control overlap and check on the actual sizes of any added labels, checkboxes, radios, graphics, etc. 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...
msmith11 Posted November 4, 2014 Author Share Posted November 4, 2014 Neat trick for locating limits of graphic: Color the background. That feature also made me realize the "graphic" is the container for the "object" e.g. GUICtrlCreateGraphic creates the container and GUICtrlSetGraphic creates the object in the container (in my case the rectangle). I also didn't realize the coordinates in GUICtrlSetGraphic are an offset to the container. Never would have gotten there on my own. Thanks 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