Jump to content
Sign in to follow this  

GUICtrlCreateGraphic is a container for GDI Api?

Recommended Posts



My be I lack of information, but If I create a Graphic control via GUICtrlCreateGraphic the subsequent instructions gdi e.g _GDIPlus_GraphicsDrawRect are related to control and not on the windows indicated in _GDIPlus_GraphicsCreateFromHWND

Incidentally if this is correct is better for me.


John Rossati

Share this post

Link to post
Share on other sites

A graphic control created with GuiCtrlCreateGraphic is not intended to be usd with the _GDIPlus_* functions.. To draw on the graphic control you need to look up GuiCtrlSetGraphic.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post

Link to post
Share on other sites

Hello Martin

yes this is true, but I checked the instructions _GDIPlus_GraphicsDrawRect draw a rectangle in the graphic control, instead of in the window.

Can be an Autoit error?

John Rossati

Share this post

Link to post
Share on other sites

You can also draw with GDI+ into a picture control.


#include <gdiplus.au3>
#include <staticconstants.au3>

$hGUI = GUICreate("Test", 320, 256)
$iW = 120
$iH = 224
$idPic = GUICtrlCreatePic("", 80, 16, $iW, $iH, $SS_SUNKEN)
GUICtrlSetBkColor($idPic, 0xF0F0F0)
$hPic = GUICtrlGetHandle($idPic)
$hGfx = _GDIPlus_GraphicsCreateFromHWND($hPic)
_GDIPlus_GraphicsClear($hGfx, 0xFFF0F0F0)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
$hPen = _GDIPlus_PenCreate(0xFFFF0000)
_GDIPlus_GraphicsDrawLine($hGfx, 0, 0, $iW, $iH, $hPen)

Until GUIGetMsg() = -3



GDI+ can only draw to a graphics handle or directly to a bitmap but not into a window handle.



Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites


This is a respons that I need, my errors was of thinking that the handle of _GDIPlus_GraphicsCreateFromHWND was the handle of a window (as saith in the help and in the example).

Jonh Rossati

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • argv1
      By argv1
      Hi folks,
      I would like to create a traffic light like gui object, where the user (me) can see if something went well or not.
      For that I wrote this:
      $Kontrolllampe1 = GUICtrlCreateGraphic(432, 20, 31, 32) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== yellow GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19) I got seven traffic lights.
      When I would like to change the color, what did I need to do?
      I tried this:
      Case $ButtonErstellen $Kontrolllampe1 = GUICtrlCreateGraphic(432, 20, 31, 32) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== green GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19) but I have to click the button twice to see a result
      Is there a possibility that I use something like
      Case $ButtonErstellen $Kontrolllampe1 = GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== green (I know this doesn't work)
      Thank you in advance
    • Xandy
      By Xandy
      Waxworks Code Wheel.
      Written in AutoIt with SDL.
    • binhn211
      By binhn211
      I need help with graphics
      I need to drawimage out the desktop continuous image is not removed, without the support of the "while"
      when I used while the image will blink

    • dreamzboy
      By dreamzboy

      I would like to know how to go about making the following item clear and transparent.   They're currently being highlight by a blue/black bar over the texts.  I've read through pages and pages of "transparent group, radios, and checkboxes" but none looks like a simple implemenation nor does it apply to my case.
      Groups Text Radio Text Also, I'm unable to see my tabs perhaps it's being hidden by the background picture? (see figure 2 for what it's supposed to look like).  Using the code from AdmiralClaws, it made the radio graphic or style a little plain and I would like to restore it.  I don't need the tab section transparent, just the dark grey area around it.
      $chk = GUICtrlCreateCheckbox("This is checkbox - Lorem ipsum dolor sit amet.", 20, 20) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) $lbl = GUICtrlCreateLabel("This is label - Lorem ipsum dolor sit amet", 20, 100) $rdo = GUICtrlCreateRadio("This is radio - Lorem ipsum dolor sit amet", 20, 180) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) Test Program
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 300) ; GUICtrlCreatePic (".\background.bmp", 0, 0, 400, 300) GUICtrlCreateTab (20, 20, 360, 260) GUICtrlCreateTabItem ("Option 1") GUICtrlCreateGroup ("Radio", 40, 60, 320, 200) $radio1 = GUICtrlCreateRadio ("Radio 1", 60, 80) ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($radio1), "wstr", 0, "wstr", 0) $radio2 = GUICtrlCreateRadio ("Radio 2", 60, 110) ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($radio2), "wstr", 0, "wstr", 0) GUICtrlCreateTab (30, 30, 360, 260) GUICtrlCreateTabItem ("Option 2") GUICtrlCreateGroup ("Radio", 40, 60, 320, 200) $radio3 = GUICtrlCreateRadio ("Radio 3", 60, 80) ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) $radio4 = GUICtrlCreateRadio ("Radio 4", 60, 110) ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete the previous GUIs and all controls. GUIDelete($hGUI) EndFunc ;==>Example
      (Figure 1)

      (Figure 2)
    • eukalyptus
      By eukalyptus
      Direct2D UDF
      Is Direct2D the new GDIPlus?
      Hmm - I think it is not! It is too complicated and Microsoft failed at the design
      But Direct2D is hardware accelerated and it has some features I always missed in GDIPlus, like loading/saving animated GIF´s, combining path´s or drawing bitmap´s in a perspective view...
      check out the examples to see, what can be done
      Download: https://autoit.de/index.php/Attachment/70-Direct2D-7z/
      Or visit the original topic at the german forum - link in my signature