Jump to content
Sign in to follow this  
Testy

Image issue

Recommended Posts

Testy

Hi all,

When I run this it will show the button 'sometimes' on the first execution. But running the script again from the editor it will not show the button until you click on the image.

Any ideas?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Local $sURL = "https://home.comcast.net/~mnjjames/new.jpg"
Local $sFilePath = @ScriptDir & "\test.jpg"
InetGet($sURL, $sFilePath)

$GUI = GuiCreate("Button v1.0", 175, 75)
GUICtrlSetColor(-1,0xFB1409)

$hListView = _GUICtrlListView_Create ($GUI, "", 2, 2, 596, 500, -1, -1, True)
_GUICtrlListView_SetBkImage ($hListView, $sFilePath)

$contextMenu = GuiCtrlCreateContextMenu()
GuiCtrlCreateMenuItem("Context Menu", $contextMenu)
GuiCtrlCreateMenuItem("", $contextMenu);separator
GuiCtrlCreateMenuItem("&Properties", $contextMenu)

$Button1r1 = GUICtrlCreateButton("Button", 66, 25, 40, 20)

GUISetState(@SW_SHOW)
                        
While 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1r1
            Run("notepad.exe")

Case $GUI_EVENT_CLOSE
            _Exit()
EndSwitch
Wend

Func _Exit()
    Exit
EndFunc

GUIDelete()

Share this post


Link to post
Share on other sites
zorphnog

I don't get it. Why are you using a listview control?

Share this post


Link to post
Share on other sites
zorphnog

If you want the image to just be a background then use something like this:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Local $sURL = "https://home.comcast.net/~mnjjames/new.jpg"
Local $sFilePath = @ScriptDir & "\test.jpg"
InetGet($sURL, $sFilePath)

$GUI = GuiCreate("Button v1.0", 175, 75)
GUICtrlSetColor(-1,0xFB1409)

GUICtrlCreatePic($sFilePath, 0, 0, 100, 67, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_DISABLE)

$contextMenu = GuiCtrlCreateContextMenu()
GuiCtrlCreateMenuItem("Context Menu", $contextMenu)
GuiCtrlCreateMenuItem("", $contextMenu);separator
GuiCtrlCreateMenuItem("&Properties", $contextMenu)

$Button1r1 = GUICtrlCreateButton("Button", 66, 25, 40, 20)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1r1
            Run("notepad.exe")
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
Wend

Share this post


Link to post
Share on other sites
Testy

If you want the image to just be a background then use something like this:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Local $sURL = "https://home.comcast.net/~mnjjames/new.jpg"
Local $sFilePath = @ScriptDir & "\test.jpg"
InetGet($sURL, $sFilePath)

$GUI = GuiCreate("Button v1.0", 175, 75)
GUICtrlSetColor(-1,0xFB1409)

GUICtrlCreatePic($sFilePath, 0, 0, 100, 67, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_DISABLE)

$contextMenu = GuiCtrlCreateContextMenu()
GuiCtrlCreateMenuItem("Context Menu", $contextMenu)
GuiCtrlCreateMenuItem("", $contextMenu);separator
GuiCtrlCreateMenuItem("&Properties", $contextMenu)

$Button1r1 = GUICtrlCreateButton("Button", 66, 25, 40, 20)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1r1
            Run("notepad.exe")
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
Wend
Thank you sir. As to why, the other code being in there, I'd adapted it out of the helpfile. Make perfect sense now. Thank you very much.

Share this post


Link to post
Share on other sites
Testy

Slight wrinkle.

Is there a way to make it to where the image doesn't make the tabs virtually invisible?

Share this post


Link to post
Share on other sites
zorphnog

Come on now. Read the documentation!

Remarks

...

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 is not enough for Tab or Listview control which behave differently. In this case you need to create the picture with the $WS_CLIPSIBLINGS style, GuiCtrlSetState(-1,$GUI_ONTOP) is necessary for the Tab or Listview control.

Share this post


Link to post
Share on other sites
Testy

Come on now. Read the documentation!

That is in there,

Does it have to be setup under the tab?

#include <GuiConstantsEx.au3>

#include <GuiListView.au3>

#include <WindowsConstants.au3>

Local $sURL = "https://home.comcast.net/~mnjjames/new.jpg"

Local $sFilePath = @ScriptDir & "\test.jpg"

InetGet($sURL, $sFilePath)

; GUI

$GUI = GuiCreate(" Helpabel v2.0", 370, 150)

GuiSetIcon("C:\WINDOWS\system32\shell32.dll", 45)

GUICtrlCreatePic($sFilePath, 0, 0, 370, 125, $WS_CLIPSIBLINGS)

GuiCtrlSetState(-1,$GUI_ONTOP)

;v2.0 - 3/28/08

GuiCtrlCreateLabel("v2.0", 336, 129, 136, 20)

GUICtrlSetColor(-1,0x867C92)

; CONTEXT MENU

$contextMenu = GuiCtrlCreateContextMenu()

GuiCtrlCreateMenuItem("Context Menu", $contextMenu)

GuiCtrlCreateMenuItem("", $contextMenu)

GuiCtrlCreateMenuItem("&Properties", $contextMenu)

Share this post


Link to post
Share on other sites
zorphnog

No no no. You use GuiCtrlSetState(-1, $GUI_ONTOP) on the tab control (which i don't even see in your code). You are talking about tab controls are you not?

Share this post


Link to post
Share on other sites
Testy

No no no. You use GuiCtrlSetState(-1, $GUI_ONTOP) on the tab control (which i don't even see in your code). You are talking about tab controls are you not?

That worked. I thank you heartily. I just want to say I'm trying here. I'm learning more daily, but I'm not an old hack at this yet.

It didn't occur to me that I should work in layers on this. It make better sense now. Again, thank you.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.