Jump to content
xekon

GUI background always covers Controls, followed example docs, code provided, please help.

Recommended Posts

Posted (edited)

here is the full code:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Local $g_a_idArray[6]
Local $idMsg
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    GUISetBkColor(0x303030, $hGUI)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)   
    GUICtrlSetState($bg,$GUI_DISABLE)

    $g_a_idArray[1] = GUICtrlCreateGraphic(20, 50, 4, 4)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 4, 4)

    $g_a_idArray[2] = GUICtrlCreateGraphic(220, 50, 4, 4)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 4, 4)

    $g_a_idArray[3] = GUICtrlCreateGraphic(220, 150, 4, 4)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 4, 4)

    $g_a_idArray[4] = GUICtrlCreateGraphic(20, 200, 4, 4)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00ff)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 4, 4)

    $g_a_idArray[5] = GUICtrlCreateGraphic(20, 80, 4, 4)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ffff)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 4, 4)
    
    ;$bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)  
    ;GUICtrlSetState($bg,$GUI_DISABLE)

    GUISetState(@SW_SHOW)
EndFunc

I started out by creating a simple GUI with some clickable controls (colored dots):

01.thumb.png.517ae3095fe1f3ca74070dc78b3a748f.png

Next I wanted to add a background image, i have tried adding the image both before and after the other controls, neither works, with a background image the controls are no longer visible:

02.thumb.png.04caf9b72e2941366398351a5bace7ef.png

 

 

 

 

test.au3

Edited by xekon

Share this post


Link to post
Share on other sites

..you are drawing in the canvas and covering the canvas with a controls that holds an image. :think:
Draw on the image and click on the coordinate to simulate the graphic you'd like to click. ( I don't know how to code what I just said )
Hope this helps.

Share this post


Link to post
Share on other sites
Posted (edited)

Ahh so im guessing GUICtrlCreateGraphic is what is "drawing in the canvas"

maybe instead of using GUICtrlCreateGraphic I should just create an actual jpg image for the dots and use GUICtrlCreateButton for my buttons instead. I just thought that GUICtrlCreateGraphic was pretty neat.

Ultimately my project will have anywhere between 100 and 900 of those little dots, its a map project I am working on so the background image will be a streets map and the dots will be points of interest.

Edited by xekon

Share this post


Link to post
Share on other sites
Posted (edited)

GDI+ is very nice for this kind of things.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
Local $g_a_idArray[6]
Local $idMsg

_GDIPlus_Startup()

CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    GUISetBkColor(0x303030, $hGUI)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFff0000) ;color format AARRGGBB (hex)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 20, 50, 20, 20, $hBrush)

    _GDIPlus_GraphicsFillEllipse($hGraphic, 220, 150, 20, 20, _GDIPlus_BrushCreateSolid(0xFF00ff00))

    _GDIPlus_GraphicsFillEllipse($hGraphic, 20, 200, 20, 20, _GDIPlus_BrushCreateSolid(0xFF0000ff))

    GUISetState(@SW_SHOW)
EndFunc

 

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks so much guys, this is what I am using now:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
Local $idMsg
_GDIPlus_Startup()
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    ;the actual buttons created as transparent labels
    Local $b001 = GUICtrlCreateLabel("", 20, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b001, $GUI_BKCOLOR_TRANSPARENT)
    Local $b002 = GUICtrlCreateLabel("", 50, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b002, $GUI_BKCOLOR_TRANSPARENT)
    Local $b003 = GUICtrlCreateLabel("", 80, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b003, $GUI_BKCOLOR_TRANSPARENT)
    
    ;draw button pins directly onto backgroup picture at button locations
    Local $hBrushR = _GDIPlus_BrushCreateSolid(0xFFff0000) ;color format AARRGGBB (hex)
    Local $hBrushG = _GDIPlus_BrushCreateSolid(0xFF00ff00) ;color format AARRGGBB (hex)
    Local $hBrushB = _GDIPlus_BrushCreateSolid(0xFF0000ff) ;color format AARRGGBB (hex)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)    
    _GDIPlus_GraphicsFillEllipse($hGraphic, 20, 50, 7, 7, $hBrushR)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 50, 50, 7, 7, $hBrushG)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 80, 50, 7, 7, $hBrushB) 
EndFunc

 

Edited by xekon

Share this post


Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
Local $idMsg
_GDIPlus_Startup()
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    ;the actual buttons created as transparent labels
    Local $b001 = GUICtrlCreateLabel(ChrW(0x23FA), 20, 50, 17, 17, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b001, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xff0000)
    GUICtrlSetFont(-1, 14)
    Local $b002 = GUICtrlCreateLabel(ChrW(0x23FA), 50, 50, 21, 21, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b002, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x00ff00)
    GUICtrlSetFont(-1, 18)
    Local $b003 = GUICtrlCreateLabel(ChrW(0x23FA), 80, 50, 17, 17, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b003, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x0000ff)
;~     ;draw button pins directly onto backgroup picture at button locations
;~     Local $hBrushR = _GDIPlus_BrushCreateSolid(0xFFff0000) ;color format AARRGGBB (hex)
;~     Local $hBrushG = _GDIPlus_BrushCreateSolid(0xFF00ff00) ;color format AARRGGBB (hex)
;~     Local $hBrushB = _GDIPlus_BrushCreateSolid(0xFF0000ff) ;color format AARRGGBB (hex)
;~     Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
;~     _GDIPlus_GraphicsFillEllipse($hGraphic, 20, 50, 7, 7, $hBrushR)
;~     _GDIPlus_GraphicsFillEllipse($hGraphic, 50, 50, 7, 7, $hBrushG)
;~     _GDIPlus_GraphicsFillEllipse($hGraphic, 80, 50, 7, 7, $hBrushB)
EndFunc

..see if that is the same to you.

Share this post


Link to post
Share on other sites

Thanks argumentum, it does seem that the labels also work if the GUISetState(@SW_SHOW) is called prior to creating them just like in the GDI example posted by careca.
This most closely resembles the appearance I am going for if I went without GDIPlus, its a solid square pin instead of round:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Local $idMsg
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    GUICreate("Test", 1024, 768)
    Local $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    ;the actual buttons created as square labels with a solid background color
    Local $b001 = GUICtrlCreateLabel("", 20, 50, 7, 7)
    GUICtrlSetBkColor($b001, 0xff0000)
    Local $b002 = GUICtrlCreateLabel("", 50, 50, 7, 7)
    GUICtrlSetBkColor($b002, 0x00ff00)
    Local $b003 = GUICtrlCreateLabel("", 80, 50, 7, 7)
    GUICtrlSetBkColor($b003, 0x0000ff)
EndFunc

I really wish Auto it had a simple built in way to create round labels in addition to rectangle ones, that would be perfect. The square labels dont look that bad and its also less lines of code but I think I like the round pins just a bit better achieved by using the GDIPlus:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
Local $idMsg
_GDIPlus_Startup()
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    ;the actual buttons created as transparent labels
    Local $b001 = GUICtrlCreateLabel("", 20, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b001, $GUI_BKCOLOR_TRANSPARENT)
    Local $b002 = GUICtrlCreateLabel("", 50, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b002, $GUI_BKCOLOR_TRANSPARENT)
    Local $b003 = GUICtrlCreateLabel("", 80, 50, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b003, $GUI_BKCOLOR_TRANSPARENT)
    
    ;draw button pins directly onto backgroup picture at button locations
    Local $hBrushR = _GDIPlus_BrushCreateSolid(0xFFff0000) ;color format AARRGGBB (hex)
    Local $hBrushG = _GDIPlus_BrushCreateSolid(0xFF00ff00) ;color format AARRGGBB (hex)
    Local $hBrushB = _GDIPlus_BrushCreateSolid(0xFF0000ff) ;color format AARRGGBB (hex)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)    
    _GDIPlus_GraphicsFillEllipse($hGraphic, 20, 50, 7, 7, $hBrushR)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 50, 50, 7, 7, $hBrushG)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 80, 50, 7, 7, $hBrushB) 
EndFunc

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
22 minutes ago, xekon said:

really wish Auto it had a simple....

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
Local $idMsg
_GDIPlus_Startup()
CreateChild()

Do; Loop until the user exits.
    $idMsg = GUIGetMsg(1)
    If $idMsg[0] > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg[2], 1)
Until $idMsg[0] = $GUI_EVENT_CLOSE

Func CreateChild()
    Local $hGUI = GUICreate("Test", 1024, 768)
    $bg = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 1024, 768)
    GUICtrlSetState($bg,$GUI_DISABLE)
    GUISetState(@SW_SHOW)

    ;the actual buttons with the GDI
    Local $b001 = EatTheCakeAndHaveItToo(20, 50, 0xFFff0000, $hGUI)
    Local $b002 = EatTheCakeAndHaveItToo(50, 50, 0xFF00ff00, $hGUI)
    Local $b003 = EatTheCakeAndHaveItToo(80, 50, 0xFF0000ff, $hGUI)
EndFunc

Func EatTheCakeAndHaveItToo($x, $y, $color, $hGUI)
    Local $b001 = GUICtrlCreateLabel("", $x, $y, 7, 7, $WS_EX_TRANSPARENT)
    GUICtrlSetBkColor($b001, $GUI_BKCOLOR_TRANSPARENT)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBrushR = _GDIPlus_BrushCreateSolid($color) ;color format AARRGGBB (hex)
    _GDIPlus_GraphicsFillEllipse($hGraphic, $x, $y, 7, 7, $hBrushR)
    Return $b001
EndFunc

:)

Edited by argumentum

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...