Jump to content

Using a png in my program


Recommended Posts

I want the child guis created from the main one to be independent and i dont want them to have a window border around them.

i changed this line:

$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y,-1,-1,$parent)

to:

$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED),$parent)

but when i changed it no windows show up anymore?

Tested without my code and it's still not showing up, so it's definitely how you're creating the child (how I don't know). Maybe start a new thread based on this code:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
$parent=GUICreate("")
GUISetState()
$child=GUICreate("Child number: 1",400,300,10,10,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED),$parent)
GUISetState()

Sleep(10000)

To get some help on creating the child :)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

What do you mean when you say its how Im creating the child guis. It's all your code i only changed one line. im creating the child the same way you did i just want it without the window border and transparent

What I'm saying is that it's obvious that the styles you defined are the wrong thing here as you could see in my reproducer. Maybe childs cannot have the $WS_EX_LAYERED style or something. I seriously don't know.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • 2 weeks later...

Ok, heres the code: its simple and its just like i want it except i need to get rid of the window border and want everything but the green fish to be transparent. how?

#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#include <misc.au3>

Global $GUI_OBJECT[1][5]; 0=hwnd, 1=width, 2=height, 3=graphics obj, 4 = img obj

Opt("GUIOnEventMode",1)
$hwnd=GUICreate("Parent",400,300)
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
GUISetState()


_GDIPlus_Startup()

$GUI_OBJECT[0][0]=$hwnd
$GUI_OBJECT[0][1]=26
$GUI_OBJECT[0][2]=26
$GUI_OBJECT[0][3]=_GDIPlus_GraphicsCreateFromHWND($hwnd)
$GUI_OBJECT[0][4]=_GDIPlus_ImageLoadFromFile("background.png")
_RePaint($GUI_OBJECT[0][0],0,0,0)

GUIRegisterMsg($WM_PAINT,"_RePaint")



Do
    Sleep(20)
    If _IsPressed("01") And WinActive($hwnd) Then
        _CreateChild($hwnd,Random(0,@DesktopWidth,1),Random(0,@DesktopHeight,1),26,26,"background.png")
        Do
            Sleep(10)
        Until Not _IsPressed("01")
    EndIf
    
    
Until False


Func _CreateChild($parent,$x,$y,$w,$h,$imagename)
    ReDim $GUI_OBJECT[Ubound($GUI_OBJECT)+1][5]
    
    $GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y)
    GUISetState(@SW_SHOW,$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0])
    $GUI_OBJECT[Ubound($GUI_OBJECT)-1][1]=$w
    $GUI_OBJECT[Ubound($GUI_OBJECT)-1][2]=$h
    $GUI_OBJECT[Ubound($GUI_OBJECT)-1][3]=_GDIPlus_GraphicsCreateFromHWND($GUI_OBJECT[Ubound($GUI_OBJECT)-1][0])
    $GUI_OBJECT[Ubound($GUI_OBJECT)-1][4]=_GDIPlus_ImageLoadFromFile($imagename)
    GUISetOnEvent($GUI_EVENT_CLOSE,"close",$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0])
    _RePaint($GUI_OBJECT[Ubound($GUI_OBJECT)-1][0],0,0,0)
    
    

EndFunc


Func _RePaint($hwndparam,$msg,$wparam,$lparam)
    For $i=0 To UBound($GUI_OBJECT)-1
        If $hwndparam=$GUI_OBJECT[$i][0] Then
            _GDIPlus_GraphicsDrawImageRect($GUI_OBJECT[$i][3],$GUI_OBJECT[$i][4],0,0,$GUI_OBJECT[$i][1],$GUI_OBJECT[$i][2])
            ExitLoop
        EndIf
    Next
    
    Return $GUI_RUNDEFMSG
EndFunc



Func close()
    If @GUI_WinHandle<>$hwnd THen
        For $i=0 To UBound($GUI_OBJECT)-1
            If @GUI_WinHandle=$GUI_OBJECT[$i][0] Then
                _GDIPlus_GraphicsDispose($GUI_OBJECT[$i][3])
                _GDIPlus_ImageDispose($GUI_OBJECT[$i][4])
                GUIDelete($GUI_OBJECT[$i][0])
                _ArrayDelete($GUI_OBJECT,$i)
                Return
            EndIf
        Next
    EndIf
    
    
    
    For $i=0 To UBound($GUI_OBJECT)-1
        _GDIPlus_GraphicsDispose($GUI_OBJECT[$i][3])
        _GDIPlus_ImageDispose($GUI_OBJECT[$i][4])
    Next
    _GDIPlus_Shutdown()
       Exit
EndFunc

when i add these styles $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED) to the end of the gui creation part which should take care of my problems, now there are no little guis that show.

Edited by AustrianOak
Link to comment
Share on other sites

i don't know if someone posted this before but did you try _WinAPI_UpdateLayeredWindow

you will find a nice example in %SystemDrive%\Program Files\AutoIt3\Examples\GUI\Advanced\AlphaBlend.au3

and there's lod3n's great example : http://www.autoitscript.com/forum/index.ph...=lod3n+launcher

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

I dont think this is what I was looking for. I need my window to be a toolwindow so it doesnt show up in taskmanager and needs to be a pop-up so it wont have a border and needs to be layered so the background of the gui will be transparent and only the picture can be seen. as in my code i posted above when i add the necessary styles to the gui creation part i think i mentioned that no little guis pop-up whatsoever.

see this post: http://www.autoitscript.com/forum/index.ph...st&p=620087

Edited by AustrianOak
Link to comment
Share on other sites

@AustrianOak

Its exactly what I said...

Make gui with hidden state then create transparent child of hidden window an put your image on (image will be visible of course so use _WinApi_SetLayeredWindowAttributes ...)

Cheers, FireFox.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...