Sign in to follow this  
Followers 0
OnTheFly

Pic problem

5 posts in this topic

Hi, i recently had a problem with background color. Now i also want an image. I do it like this:

#include <GUIConstants.au3>

;Read the GUI size from the config file
$width = IniRead("VelkyPortable/config/conf.ini", "gui", "width", 450)
$height = IniRead("VelkyPortable/config/conf.ini", "gui", "height", 600)

;Read the left position
$left = IniRead("VelkyPortable/config/conf.ini", "gui", "left", "left")

If Not StringIsInt($left) Then
    If StringLower($left) = "left" Then
        $left = 0
    ElseIf StringLower($left) = "right" Then
        $left = @DesktopWidth - $width
    EndIf
EndIf

;Read the top position
$top = IniRead("VelkyPortable/config/conf.ini", "gui", "top", "bottom")

If Not StringIsInt($top) Then
    If StringLower($top) = "top" Then
        $top = 0
    ElseIf StringLower($top) = "bottom" Then
        $top = @DesktopHeight - $height
    EndIf
EndIf

;Create the gui
$gui = GUICreate("VelkyPortable", $width, $height, $left, $top, $WS_POPUP)

$pic_main = GUICtrlCreatePic(@ScriptDir & "/VelkyPortable/gfx/main.gif", -1, -1, $width, $height)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

@error is 1 after GUICtrlCreatePic() so the file is found. But the window is just gray. No image. Does anyone know why?

Share this post


Link to post
Share on other sites



@error is 1 after GUICtrlCreatePic() so the file is found. But the window is just gray. No image. Does anyone know why?

You need to check the value returned by the function to know if _GUICtrlCreatePic could create the picture. @error doesn't get mentioned in the help.

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

#3 ·  Posted (edited)

Look at this:

$pic_main = GUICtrlCreatePic(@ScriptDir & "/VelkyPortable/gfx/main.gif", -1, -1, $width, $height)

$pic_main = GUICtrlCreatePic(@ScriptDir & "\VelkyPortable\gfx\main.gif", -1, -1, $width, $height)

The same also for INI path ...

Edited by Zedna

Share this post


Link to post
Share on other sites

Look at this:

$pic_main = GUICtrlCreatePic(@ScriptDir & "/VelkyPortable/gfx/main.gif", -1, -1, $width, $height)

$pic_main = GUICtrlCreatePic(@ScriptDir & "\VelkyPortable\gfx\main.gif", -1, -1, $width, $height)

The same also for INI path ...

Are you sure that's a problem? I know what you put is the correct way but I think AutoIt will automatically convert '/' to '\' in a path string.


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

Are you sure that's a problem? I know what you put is the correct way but I think AutoIt will automatically convert '/' to '\' in a path string.

This isn't true... -.- I never moved the "main.gif" to that folder. :)

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