Jump to content

How can I make an image the background?


ssjfulkon198
 Share

Recommended Posts

  • 1 month later...
  • 5 weeks later...

Function Reference

GUICtrlCreatePic

--------------------------------------------------------------------------------

Creates a Picture control for the GUI.

GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename filename of the picture to be loaded.

left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.

top The top of the control. If -1 is used then top will be computed according to GUICoordMode.

width [optional] The width of the control (default is the previously used width).

height [optional] The height of the control (default is the previously used height).

style [optional] Defines the style of the control. See GUI Control Styles Appendix.

default (-1) : $SS_NOTIFY

forced style : $SS_BITMAP

exStyle [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: Returns the identifier (controlID) of the new control.

Failure: Returns 0 if picture cannot be created.

Remarks

To set or change information in the control see GUICtrlSet....

To update the picture after the dialog box is displayed just use GUICtrlSetImage

If you want to have a picture having the same size as the file content just use width=height=0.

To have a transparent picture it is needed to use a .gif image with the transparency color set and to create the window with WS_EX_LAYERED extended style. See example 2.

Animated .gif are not supported.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_PIC, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control : GuiCtrlSetState(-1,$GUI_DISABLE). This does not work with Tab control which behave differently. in this case you need to create the picture with the $WS_CLIPSIBLINGS style, some $GUI_ONTOP can still be necessary for the tab control.

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no $WS_CAPTION style in GUICreate).

To set the background to transparent, use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT).

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

Example

;----- example 1 ----

#include <GUIConstants.au3>

GUICreate("My GUI picture",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; will create a dialog box that when displayed is centered

GUISetBkColor (0xE0FFFF)

$n=GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg",50,50, 200,50)

GUISetState ()

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

GUISetState ()

; resize the control

$n=GUICtrlSetPos($n,50,50,200,100)

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

;----- example 2

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 100)

$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)

GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)

GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")

HotKeySet("{LEFT}", "left")

HotKeySet("{RIGHT}", "right")

HotKeySet("{DOWN}", "down")

HotKeySet("{UP}", "up")

$picPos = WinGetPos($pic)

$guiPos = WinGetPos($gui)

do

$msg = GUIGetMsg()

until $msg = $GUI_EVENT_CLOSE

Exit

Func main()

$guiPos = WinGetPos($gui)

WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)

EndFunc

Func left ()

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0]-10,$picPos[1])

EndFunc

Func right()

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0]+10,$picPos[1])

EndFunc

Func down()

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0],$picPos[1]+10)

EndFunc

Func up()

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0],$picPos[1]-10)

EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

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