Jump to content
Sign in to follow this  
Greek

GDI+: Get Invisible Ellipse

Recommended Posts

Greek

Hi

How do i get this Ellipse invisible and the Gui still black?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

HotKeySet ( "!a", "_ende" )

_GDIPlus_Startup()


$hgui = GUICreate ( "MyGUI", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST ) )
GUISetBkColor ( 0x000000 )
_WinAPI_SetLayeredWindowAttributes($hgui, 0xABCDEF, 255)
GUISetState ( @SW_SHOW )

$hwnd=_GDIPlus_GraphicsCreateFromHWND ( $hgui )

;~ $schwarz=_GDIPlus_PenCreate ( 0xFF000000, 500, 2 )
$stift=_GDIPlus_BrushCreateSolid ( 0xFFABCDEF )

;~ _GDIPlus_GraphicsDrawEllipse ( $hwnd, @DesktopWidth/2, @DesktopHeight/2-100, 50, 50, $schwarz )
_GDIPlus_GraphicsFillEllipse ( $hwnd, @DesktopWidth/2-100, @DesktopHeight/2-100, 200, 200, $stift )


While 1
   $msg = GUIGetMsg()
   Switch $msg
      Case $GUI_EVENT_CLOSE
         Exit
         
   EndSwitch
WEnd

;~ _GDIPlus_PenDispose ( $schwarz )
_GDIPlus_BrushDispose ( $stift )
_GDIPlus_GraphicsDispose ( $hwnd )
_GDIPlus_Shutdown()

Func _ende()
    Exit
EndFunc

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
   ; progandy
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc  ;==>_WinAPI_SetLayeredWindowAttributes

Greek

Share this post


Link to post
Share on other sites
Greek

indeed that would be a solution, but i want to make it with GDI+

Share this post


Link to post
Share on other sites
youknowwho4eva

Just to clarify, you want the circle still there, but transparent? Or you want it gone?

change this

$stift=_GDIPlus_BrushCreateSolid ( 0xFFABCDEF )

to

$stift=_GDIPlus_BrushCreateSolid ( 0x00ABCDEF )

Still there, just transparent

Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites
Greek

Just to clarify, you want the circle still there, but transparent? Or you want it gone?

change this

$stift=_GDIPlus_BrushCreateSolid ( 0xFFABCDEF )

to

$stift=_GDIPlus_BrushCreateSolid ( 0x00ABCDEF )

Still there, just transparent

Then i only get a black screen without the Ellipse :S

Share this post


Link to post
Share on other sites
martin

Just to clarify, you want the circle still there, but transparent? Or you want it gone?

change this

$stift=_GDIPlus_BrushCreateSolid ( 0xFFABCDEF )

to

$stift=_GDIPlus_BrushCreateSolid ( 0x00ABCDEF )

Still there, just transparent

Is that a serious suggestion? ^_^

Try drawing a filled rectangle in any colour you like over the whole screen. Then draw an elipse or any other shape, and also try a line, using the transparent colour to generate transparent sections.


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
youknowwho4eva

That's why I was asking for clarification ^_^ you asked for an invisible ellipse.


Giggity

Share this post


Link to post
Share on other sites
martin

Is that a serious suggestion? ^_^

Try drawing a filled rectangle in any colour you like over the whole screen. Then draw an elipse or any other shape, and also try a line, using the transparent colour to generate transparent sections.

Here's another example of the problem. I'm sure it's a matter of understanding transparent colours and GDI+ which I don't, but I've not seen a convincing excplanation yet.


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
martin

That's why I was asking for clarification ;) you asked for an invisible ellipse.

I suppose that's a fair enough reason ^_^


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
youknowwho4eva

go to the GDI+ examples, and look at my last post there. I faked the transparency there, but the behind the scenes is visible. I just cheated ^_^.


Giggity

Share this post


Link to post
Share on other sites
Greek

Here's another example of the problem. I'm sure it's a matter of understanding transparent colours and GDI+ which I don't, but I've not seen a convincing excplanation yet.

Thats mine topic xD

Hm it seems that the Funktion _WinAPI_SetLayeredWindowAttributes don't works with GDI+

Share this post


Link to post
Share on other sites
martin

Thats mine topic xD

Hm it seems that the Funktion _WinAPI_SetLayeredWindowAttributes don't works with GDI+

Yes.

You can do it with a graphic though

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>

$gui = GUICreate("a",1000,800,100,100,-1,$WS_EX_LAYERED);can be $WS_POPUP

GUISetState()
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)
$g1 = GUICtrlCreateGraphic(0,0,500,500)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR,0xABCDEF,0xABCDEF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 50, 50, 200, 330, 270)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
sleep(7000)




Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
  ; progandy
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

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
Greek

Yes.

You can do it with a graphic though

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>

$gui = GUICreate("a",1000,800,100,100,-1,$WS_EX_LAYERED);can be $WS_POPUP

GUISetState()
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)
$g1 = GUICtrlCreateGraphic(0,0,500,500)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR,0xABCDEF,0xABCDEF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 50, 50, 200, 330, 270)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
sleep(7000)




Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
 ; progandy
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes
ok, thank you =D

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  

×