Sign in to follow this  
Followers 0
svaneenoo

GUICtrlCreatePic

6 posts in this topic

Hi,

I want to display a picture on my form.

However, the picture is not displayed.

I have no clue why.

I am a beginning AutIT'er, so apologies...I guess this is a basic question. :mellow:

The picture exists on the indicated loaction.

Hope somebody can help me.

Thanks in advance for any help an replys

Stefaan

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $gui, $guiPos, $Pic, $picPos

Example1()

Func Example1()

Local $Pic, $msg

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

GUISetBkColor(0xE0FFFF)

$Pic = GUICtrlCreatePic("C:\Documents and Settings\SvanEenoo\Desktop\Paint.NET\Images_Hotspot\mouse2.jpg", 50, 50, 50, 50)

GUICtrlSetState($Pic,$GUI_DISABLE)

GUISetState()

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

; resize the control

$picPos = GUICtrlSetPos($Pic, 50, 50, 50, 50)

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

GUIDelete()

EndFunc ;==>Example1

Share this post


Link to post
Share on other sites



Hi svaneenoo,

Welcome to AUTOIT Comuunity.

Here is your script:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $Pic, $msg, $gui,$guiPos,$picPos
Opt('MustDeclareVars', 1)

Example1()


Func Example1()


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

GUISetBkColor(0xE0FFFF)
$Pic = GUICtrlCreatePic("C:\Documents and Settings\SvanEenoo\Desktop\Paint.NET\Images_Hotspot\mouse2.JPG", 50,50) ;make sure extension .jpg or .JPG?
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

GUIDelete()
EndFunc ;==>Example1

[size="5"] [/size]

Share this post


Link to post
Share on other sites

I don't understand what Sh3llC043r's reply is saying, but the suggestion that you need to worry about the case of any letters in a path is incorrect because Windows reads file names without case sensitivity.

I don't see what is wrong with your script as far as showing the image is concerned so I think you need to add some extra code to find the problem.

Try adding

If Not FileExists("C:\Documents and Settings\SvanEenoo\Desktop\Paint.NET\Images_Hotspot\mouse2.jpg") then MsgBox(262144,"Whoops", "No pic")

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

Hi,

I tried another picture, and it works.

I notice that is does not work with transparent .png

Is this normal known behaviour?

Cheers

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

I tried another picture, and it works.

I notice that is does not work with transparent .png

Is this normal known behaviour?

Cheers

Posting an example which uses a jpg for a problem with using a png is not normal behaviour. :mellow:

Nor, I would like to think, is starting a thread before reading the help. :(

TEDIT: To use a transparent png for a pic use Yashied's Icons.au3 udf in example forums.

Edited by martin

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

Hi,

I tried another picture, and it works.

I notice that is does not work with transparent .png

Is this normal known behaviour?

Cheers

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  
Followers 0