annelinn Posted August 25, 2010 Share Posted August 25, 2010 I'm trying to use GUICtrlSetGraphic() to draw simple shapes (squares and lines) within a specified area of a window. The script below creates a window, and creates a blue graphic control inside the window. Then it tries to draw a rectangle inside the blue area. The script is as close as possible to the example script given in the help file for GUICtrlSetGraphic(). Naturally, the example script works perfectly, and mine doesn't. What might I be doing wrong? #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; Create a GUI main window $Mwin_handle = GUICreate("Test", 1000, 600, 0, 0) GUISetState(@SW_SHOW) ; Create a graphic control within the window $Swin_handle = GUICtrlCreateGraphic(800, 400, 100, 100) GUICtrlSetBkColor(-1, 0x0000ff) ; Blue background GUICtrlSetColor(-1, 0x000000) ; Black border ; Try to draw a black square inside the blue area GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 20, 20) ; Prompt the user before terminating script MsgBox(1, "test", "waiting") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2010 Moderators Share Posted August 25, 2010 annelinn,Your code works prefectly for me. Perhaps your monitor makes it difficult to see the black rectangle on the blue background. Have you tried to change the blue to a lighter shade (0xC4C4FF for example)? 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...
annelinn Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) Perhaps your monitor makes it difficult to see the black rectangle on the blue background. Have you tried to change the blue to a lighter shade (0xC4C4FF for example)? Yes, I've tried various combinations of colours (including black on white, and vice-versa). I've also tried using different windows themes.Perhaps it's a Windows Vista problem. Edited August 25, 2010 by annelinn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2010 Moderators Share Posted August 25, 2010 annelinn,Perhaps it's a Windows Vista problemNo - I am running Vista. What exactly does not work when you run your code? Does the larger area display correctly?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...
annelinn Posted August 25, 2010 Author Share Posted August 25, 2010 The main window, and the blue area within it, are displayed properly. The little black boxes I'm trying to draw inside the blue area don't appear at all. Here's a screenshot. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted August 25, 2010 Share Posted August 25, 2010 (edited) Hmm, I get the same result as you, annelinn, I also am running Vista, Home Premium. Edited August 25, 2010 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
wraithdu Posted August 25, 2010 Share Posted August 25, 2010 It's a repaint issue. Add this after your drawing is finished _WinAPI_InvalidateRect($Mwin_handle) Alternatively, don't show your GUI (GuiSetState) until your drawing is finished. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2010 Moderators Share Posted August 25, 2010 wrathdu,It's a repaint issueWhich explains why it worked for me. The message box actually covered the graphics area on my display and I had to move it to see the small box - hence automatic repainting.Thanks. 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...
annelinn Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) Yes, that's the solution. Thank you, all, for your generous help. The fixed script is below for future reference. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <WinAPI.au3> ; Create a GUI main window $Mwin_handle = GUICreate("Test", 1000, 600, 0, 0) GUISetState(@SW_SHOW) ; Create a graphic control within the window $Swin_handle = GUICtrlCreateGraphic(800, 400, 100, 100) GUICtrlSetBkColor(-1, 0x0000ff) ; Blue background GUICtrlSetColor(-1, 0x000000) ; Black border ; Try to draw a black square inside the blue area GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 20, 20) _WinAPI_InvalidateRect($Mwin_handle) ; Prompt the user before terminating script MsgBox(1, "test", "waiting") Edited August 25, 2010 by annelinn 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