Jump to content

Problem with GuiCtrlSetImage


Damein
 Share

Recommended Posts

I got the example working fine.. and I've looked through the forums for using $BS_BITMAP and I found a few scripts that use it.. but I just can't seem to get mine to work :graduated:

Here is my code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <IE.au3>
#Include <StaticConstants.au3>

HotKeySet("{`}", "Show")

Global $PanTask, $PanGUI, $CreateWindow

GuiCreate("Trainer",300,200)
GUICtrlCreatePic("Background.jpg", 0, 0, 300, 200)
$LoginButton = GuiCtrlCreateButton("Login", 10, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage(-1, "C:\Users\***\Documents\Website\Training\Login.bmp")
$TrainButton = GuiCtrlCreateButton("Train", 200, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage(-1, "C:\Users\***\Documents\Website\Training\Train.bmp")


While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
    WEnd

Func Show()
    GuiSetState(@SW_SHOW)
EndFunc

So atm, all I need to do is get it to use the images provided to display, but it just shows a blank white box.

I also tried:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <IE.au3>
#Include <StaticConstants.au3>

HotKeySet("{`}", "Show")

Global $PanTask, $PanGUI, $CreateWindow

GuiCreate("Trainer",300,200)
GUICtrlCreatePic("Background.jpg", 0, 0, 300, 200)
$LoginButton = GuiCtrlCreateButton("Login", 10, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage($LoginButton, "C:\Users\***\Documents\Website\Training\Login.bmp")
$TrainButton = GuiCtrlCreateButton("Train", 200, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage($TrainButton, "C:\Users\***\Documents\Website\Training\Train.bmp")


While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
    WEnd

Func Show()
    GuiSetState(@SW_SHOW)
EndFunc

Changing the ControlID to the specified var, but no go still

At a loss :(

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Works for me without problems:

;~ #include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <IE.au3>
#Include <StaticConstants.au3>

HotKeySet("{F2}", "Show")

Global $PanTask, $PanGUI, $CreateWindow

GuiCreate("Trainer",300,200)
GUICtrlCreatePic("Background.jpg", 0, 0, 300, 200)
$LoginButton = GuiCtrlCreateButton("Login", 10, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage(-1, "C:\2\image1.bmp")
$TrainButton = GuiCtrlCreateButton("Train", 200, 90, 62, 32, $BS_BITMAP)
GuiCtrlSetImage(-1, "C:\2\image2.bmp")

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

HotKeySet("{F2}")

Func Show()
    GuiSetState(@SW_SHOW)
EndFunc

Check these:

- if BMP is really bitmap not renamed GIF/JPG/ICO

- try short path to image

EDIT: You missed GuiCtrlSetState(-1,$GUI_DISABLE) after GUICtrlCreatePic()

GUICtrlCreatePic("Background.jpg", 0, 0, 300, 200)

GuiCtrlSetState(-1,$GUI_DISABLE)

Edited by Zedna
Link to comment
Share on other sites

Thanks, I'll try checking the image properties later. And yeah, I found that Disable thing out :graduated:

But, as a side note.. how would someone go about closing one GUI without exiting the script?

Like.. an GUI_EVENT_CLOSE that doesn't = exit, just a "Kill GUI that message was sent from"

Thanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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