Jump to content

Recommended Posts

Posted

Okay here's the code:

#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#Include <Misc.au3>

; Create main form, set icon
$frmGui = GUICreate("My Gui", 1025, 769, -1, -1)
GUISetIcon(".\icon.ico")

; Create cast button
$btnOne = GUICtrlCreateButton("", 592, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnOne.bmp", 0)

; Create lure button
$btnTwo = GUICtrlCreateButton("", 614, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnTwo.bmp", 0)

; Create bobber button
$btnThree = GUICtrlCreateButton("", 630, 170, 80, 90, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnThree.bmp")
ControlHide("My Gui", "", $btnThree)

$picScreen = GUICtrlCreatePic(".\screen.jpg", 0, 0, 1024, 768)
GUISetState(@SW_SHOW)

CheckEvents()

Func CheckEvents()
    While 1
       ; Check for keypress
        $dll = DllOpen("user32.dll")
        If _IsPressed("31", $dll) Then
            MsgBox(0,"Keypress", "'1' Key Pressed")
        ElseIf _IsPressed("32", $dll) Then
            MsgBox(0,"Keypress", "'2' Key Pressed")
        ElseIf _IsPressed("33", $dll) Then
            MsgBox(0,"Keypress", "'3' Key Pressed")
        EndIf
        DllClose($dll)   
       
       ; check for button click
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $nMsg = $btnOne
                MsgBox(0, 'Testing', 'Button one was pressed')
            Case $nMsg = $btnTwo
                MsgBox(0, 'Testing', 'Button two was pressed')
            Case $nMsg = $btnThree
                MsgBox(0, 'Testing', 'Button three was pressed')
        EndSelect
    WEnd
EndFunc

My issue is this: I have to create the buttons before I add the picture or they get covered. Is there a way to set which "layer" things are on? Additionally, the buttons are sort of hidden, mousing over shows them and then they stay visible.

I'm sure I'm doing something simple wrong but I'll be damned if I can find it.

Posted

#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#Include <Misc.au3>

; Create main form, set icon
$frmGui = GUICreate("My Gui", 1025, 769, -1, -1)
GUISetIcon(".\icon.ico")

$picScreen = GUICtrlCreatePic(".\screen.jpg", 0, 0, 1024, 768)
GUICtrlSetState(-1,$GUI_DISABLE)

; Create cast button
$btnOne = GUICtrlCreateButton("", 592, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnOne.bmp", 0)

; Create lure button
$btnTwo = GUICtrlCreateButton("", 614, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnTwo.bmp", 0)

; Create bobber button
$btnThree = GUICtrlCreateButton("", 630, 170, 80, 90, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnThree.bmp")
ControlHide("My Gui", "", $btnThree)

GUISetState(@SW_SHOW)

CheckEvents()

Func CheckEvents()
    While 1
      ; Check for keypress
        $dll = DllOpen("user32.dll")
        If _IsPressed("31", $dll) Then
            MsgBox(0,"Keypress", "'1' Key Pressed")
        ElseIf _IsPressed("32", $dll) Then
            MsgBox(0,"Keypress", "'2' Key Pressed")
        ElseIf _IsPressed("33", $dll) Then
            MsgBox(0,"Keypress", "'3' Key Pressed")
        EndIf
        DllClose($dll)   
       
      ; check for button click
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $nMsg = $btnOne
                MsgBox(0, 'Testing', 'Button one was pressed')
            Case $nMsg = $btnTwo
                MsgBox(0, 'Testing', 'Button two was pressed')
            Case $nMsg = $btnThree
                MsgBox(0, 'Testing', 'Button three was pressed')
        EndSelect
    WEnd
EndFunc

Posted

Thanks for the reply DjDeep00. So basically my issue is not setting the GUI to disabled with the following line?

GUICtrlSetState(-1,$GUI_DISABLE)

Posted

@Lee Bussy...From the help file...

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

Also you should place the GuictrlcreatePic() before you create any other controls.

Posted

@Lee Bussy...From the help file

Now that you've pointed it out, I see it. Sometimes I read so much it doesn't all stick. Thanks for taking the time to explain.
  • 1 month later...
Posted

I had the same problem (buttons and labels getting overlapped) and DjDeep00 solution solved that .. thanks :P

But, in the other hand disabling the background pic disabled it's draggable functionality too :o

My GUI is declared as so:

$Form1 = GUICreate("", 396, 231, 251, 186, $WS_POPUP)
$Pic1 = GUICtrlCreatePic(".\mypic.jpg", 0, 0, 393, 229, BitOR($WS_GROUP,$WS_CLIPSIBLINGS,$SS_NOTIFY), $GUI_WS_EX_PARENTDRAG)
$Label1 = GUICtrlCreateLabel("My Label", 81, 8, 240, 17, BitOR($SS_CENTER,$WS_GROUP))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetCursor (-1, 0)

It seems I can't keep the buttons and labels visible, transparent and at the same time the background pic draggable ! :P

Any ideas will be very appreciated.

Posted

Thanks for the reply DjDeep00. So basically my issue is not setting the GUI to disabled with the following line?

GUICtrlSetState(-1,$GUI_DISABLE)

1. Use a $WS_CLIPSIBLINGS style in the pic. control

2. Open a DLL once.

#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#Include <Misc.au3>

Global $dll = DllOpen("user32.dll")

; Create main form, set icon
$frmGui = GUICreate("My Gui", 1025, 769, -1, -1)
GUISetIcon(".\icon.ico")

; Create cast button
$btnOne = GUICtrlCreateButton("", 592, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnOne.bmp", 0)

; Create lure button
$btnTwo = GUICtrlCreateButton("", 614, 710, 22, 22, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnTwo.bmp", 0)

; Create bobber button
$btnThree = GUICtrlCreateButton("", 630, 170, 80, 90, BitOR($BS_BITMAP, $BS_FLAT))
GUICtrlSetImage(-1, ".\btnThree.bmp")
ControlHide("My Gui", "", $btnThree)

$picScreen = GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 1024, 768, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1,$GUI_DISABLE)

GUISetState(@SW_SHOW)

CheckEvents()

DllClose($dll)

Func CheckEvents()
    While 1
       ; Check for keypress
        If _IsPressed("31", $dll) Then
            MsgBox(0,"Keypress", "'1' Key Pressed")
        ElseIf _IsPressed("32", $dll) Then
            MsgBox(0,"Keypress", "'2' Key Pressed")
        ElseIf _IsPressed("33", $dll) Then
            MsgBox(0,"Keypress", "'3' Key Pressed")
        EndIf
       
       ; check for button click
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $nMsg = $btnOne
                MsgBox(0, 'Testing', 'Button one was pressed')
            Case $nMsg = $btnTwo
                MsgBox(0, 'Testing', 'Button two was pressed')
            Case $nMsg = $btnThree
                MsgBox(0, 'Testing', 'Button three was pressed')
        EndSelect
    WEnd
EndFunc
Posted

I had the same problem (buttons and labels getting overlapped) and DjDeep00 solution solved that .. thanks :P

But, in the other hand disabling the background pic disabled it's draggable functionality too :o

My GUI is declared as so:

$Form1 = GUICreate("", 396, 231, 251, 186, $WS_POPUP)
$Pic1 = GUICtrlCreatePic(".\mypic.jpg", 0, 0, 393, 229, BitOR($WS_GROUP,$WS_CLIPSIBLINGS,$SS_NOTIFY), $GUI_WS_EX_PARENTDRAG)
$Label1 = GUICtrlCreateLabel("My Label", 81, 8, 240, 17, BitOR($SS_CENTER,$WS_GROUP))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetCursor (-1, 0)

It seems I can't keep the buttons and labels visible, transparent and at the same time the background pic draggable ! :P

Any ideas will be very appreciated.

Try this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <MenuConstants.au3>

$Form1 = GUICreate("", 396, 231, 251, 186, $WS_POPUP)

$Pic1 = GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 393, 229, BitOR($WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)

$Label1 = GUICtrlCreateLabel("My Label", 81, 8, 240, 17, BitOR($SS_CENTER,$WS_GROUP))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetCursor (-1, 0)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            DllCall("user32.dll", "int", "SendMessage", "hwnd", $Form1, "int", $WM_SYSCOMMAND, _
                    "int", BitOR($SC_MOVE, $HTCAPTION), "int", 0)
    EndSwitch
WEnd

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...