Jump to content

Help need to load pic from default dir


RyanOlson
 Share

Recommended Posts

$Pic2 = GUICtrlCreatePic(EnvGet("windir") & "\test\test.jpg", 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic2 = GUICtrlCreatePic(@WindowsDir & "\test\test.jpg", 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

I've used those 2 lines and neither works. If someone could tell me how to get the file to load from the windows dir to show our companies logo.

Link to comment
Share on other sites

$Pic2 = GUICtrlCreatePic(EnvGet("windir") & "\test\test.jpg", 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic2 = GUICtrlCreatePic(@WindowsDir & "\test\test.jpg", 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

I've used those 2 lines and neither works. If someone could tell me how to get the file to load from the windows dir to show our companies logo.

Hi Ryan

post some code.

the second line works fine. no need to use env vars when AutoIt has built in macros

the help file has examples for GUICtrlCreatePic().

Is the image in fact where your path is pointing to?

try placing your image path in this example

I included the GUICtrlCreatePic in the message loop as you want to use the image as a clickable control ($SS_NOTIFY)

what AutoIt version?

what OS? 98SE, Win2k, XP, Win2003, Vista?

do you use the SciTE editor?

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

Opt('MustDeclareVars', 1)

Global $gui, $Pic2, $msg, $sPicpath

$sPicpath = @WindowsDir & "\test\test.jpg" ; your image path here

If Not FileExists($sPicpath) Then
    MsgBox(262144,"Image not found", $sPicpath & @CRLF & "not found in:" & _
    @WindowsDir & @CRLF & "Using " & @WindowsDir & "\Help\Tours\htmlTour\intro_logo.jpg instead")
    $sPicpath = @WindowsDir & "\Help\Tours\htmlTour\intro_logo.jpg"
EndIf

$gui = GUICreate("My GUI picture", 400, 300, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU))
$Pic2 = GUICtrlCreatePic($sPicpath, 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
;GUICtrlSetState(-1, $GUI_DISABLE) ; only if not using pic as control or controls to be placed on top of image
GUICtrlSetTip(-1, "Click image")
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Pic2
            Beep(1000,5)
            MsgBox(262144,"Image Clicked","Image was clicked on")
    EndSwitch
WEnd

GUIDelete()
Exit

I see fascists...

Link to comment
Share on other sites

$Pic2 = GUICtrlCreatePic(EnvGet("windir") & "\test\test.jpg", 188, 49, 193, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

1) try to remove BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)

2) post what EnvGet("windir") gives you

missed that Zedna

didn't consider it could be an environment problem

what about %SystemRoot% ? (W2k and higher)

EnvGet("SystemRoot")

works with those styles.

don't know about using WS_GROUP as it just groups controls like its use in GuiCtrlCreateGroup

WS_CLIPSIBLINGS needed if disabled background pic with Tab or Listview controls

default style SS_NOTIFY needs to be re-added if bitoring styles and pic to be used as control

over to you OP

I see fascists...

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...