Jump to content

Slider won't respond (Fixed)


Recommended Posts

Hey guys, I have two forms and a slider on one of them. It shows up perfectly but when I click to move it nothing happens, it doesn't move, the window doesn't close (thankfully, so there's no error in code there), simply nothing happens. Ideas on what might be wrong? I've tried various combinations of options but still nothing works. Here is the entire code for what I'm working on. Maybe something farther down causes a conflict? Hope you guys (and girls) can help me out with this.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=game.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;~ ============================================================================================================================================================
;~ |                                                                Includes                                                                                  |
;~ ============================================================================================================================================================

#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiSlider.au3>

;~ ============================================================================================================================================================
;~ |                                                          Declare Variables                                                                               |
;~ ============================================================================================================================================================

Dim $checked = 0
Dim $x = 0
Dim $y = 0
Dim $width = @DesktopWidth
Dim $height = @DesktopHeight
Dim $bits = @DesktopDepth
Dim $res = @DesktopRefresh
Dim $Vol = 85

;~ ============================================================================================================================================================
;~ |                                                                 Draw GUIs                                                                                |
;~ ============================================================================================================================================================


#Region ### START Koda GUI section ### Form=c:\documents and settings\kevin\desktop\game\frmmaingame.kxf
        $frmMainGame = GUICreate("Main Game", 801, 601, -1, -1, $WS_POPUP, 0)
        GUISetBkColor(0x000000)
        $btnQuit = GUICtrlCreateButton("Quit", 328, 376, 137, 41, 0)
        GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetBkColor(-1, 0x000080)
        $btnOptions = GUICtrlCreateButton("Options", 328, 312, 137, 41, 0)
        GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetBkColor(-1, 0x000080)
        $btnHelp = GUICtrlCreateButton("Help", 328, 248, 137, 41, 0)
        GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetBkColor(-1, 0x000080)
        $btnPlay = GUICtrlCreateButton("Play", 328, 184, 137, 41, 0)
        GUICtrlSetBkColor(-1, 0x000080)
        GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFFFFFF)
        $picBG = GUICtrlCreatePic(@ScriptDir & "\Images\bg.bmp", 0, 0, 800, 600, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
        GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### START Koda GUI section ### Form=c:\documents and settings\kevin\desktop\game\options.kxf
    $Options = GUICreate("Options", 321, 241, 193, 125, BitOR($WS_POPUP,$WS_CLIPSIBLINGS), 0)
    GUISetBkColor(0x000000)
    $chkFullScrn = GUICtrlCreateCheckbox("Full Screen", 8, 16, 113, 17)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x000080)
    $btnMM = GUICtrlCreateButton("Main Menu", 72, 200, 177, 17, 0)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x000080)
    $picBgOpt = GUICtrlCreatePic("C:\Documents and Settings\Kevin\My Documents\My Pictures\bg opt.bmp", 0, 0, 320, 240, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $sldVolume = GUICtrlCreateSlider(8, 56, 297, 20)
    GUICtrlSetData(-1, 85)
#EndRegion ### END Koda GUI section ###

    
;~ ============================================================================================================================================================
;~ |                                                               Main Program                                                                               |
;~ ============================================================================================================================================================

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $btnQuit
            GUISetState(@SW_HIDE,$frmMainGame)
            If @DesktopHeight <> $height Then
                DisplayChangeRes($width,$height,$bits,$res)
            EndIf
            Exit
        Case $btnHelp
            
        Case $btnPlay
        
        Case $btnOptions
            DrawOpts()
        Case $chkFullScrn
            IF GUICtrlRead($chkFullScrn) = $GUI_CHECKED Then
                DisplayChangeRes(800,600,32,60)
                GUISetState(@SW_HIDE,$Options)
                $checked = 1
                DrawOpts()
            ElseIf GUICtrlRead($chkFullScrn) = $GUI_UNCHECKED Then
                DisplayChangeRes($width,$height,$bits,$res)
                GUISetState(@SW_HIDE,$Options)
                $checked = 0
                DrawOpts()
            EndIf
        Case $btnMM
            If GUICtrlRead($chkFullScrn) = $GUI_CHECKED Then
                GUISetState(@SW_HIDE,$Options)
                DrawMain()
            Else
                GUISetState(@SW_HIDE,$Options)
                DrawMain()
            EndIf
        Case $sldVolume
            $Vol = GUICtrlRead($sldVolume)
            SoundSetWaveVolume($Vol)
            MsgBox("","Sound Percentage", "The sound is at " & $Vol & "%")
    EndSwitch
WEnd

;~ ============================================================================================================================================================
;~ |                                                            Global Functions                                                                              |
;~ ============================================================================================================================================================

Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ)
$DM_PELSWIDTH = 0x00080000
$DM_PELSHEIGHT = 0x00100000
$DM_BITSPERPEL = 0x00040000
$DM_DISPLAYFREQUENCY = 0x00400000
$CDS_TEST = 0x00000002
$CDS_UPDATEREGISTRY = 0x00000001
$DISP_CHANGE_RESTART = 1
$DISP_CHANGE_SUCCESSFUL = 0
$HWND_BROADCAST = 0xffff
$WM_DISPLAYCHANGE2 = 0x007E
$DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]")
$B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE))
If @error Then
$B = 0
Else
$B = $B[0]
EndIf
If $B <> 0 Then
DllStructSetData ($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
DllStructSetData ($DEVMODE, 4, $WIDTH, 2)
DllStructSetData ($DEVMODE, 4, $HEIGHT, 3)
DllStructSetData ($DEVMODE, 4, $BPP, 1)
DllStructSetData ($DEVMODE, 4, $FREQ, 5)
$B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_TEST)
If @error Then
$B = -1
Else
$B = $B[0]
EndIf
Select
Case $B = $DISP_CHANGE_RESTART
$DEVMODE = ""
Return 2
Case $B = $DISP_CHANGE_SUCCESSFUL
DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_UPDATEREGISTRY)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE2, _
"int", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH)
$DEVMODE = ""
Return 1
Case Else
$DEVMODE = ""
Return $B
EndSelect
EndIf
EndFunc

Func DrawOpts()
        GUISetState(@SW_SHOW)
        WinMove("Options","",@DesktopWidth / 2 - 160, @DesktopHeight / 2 - 120)
        DrawMain()
        SoundSetWaveVolume($Vol)
EndFunc

Func DrawMain()
    $size = WinGetClientSize("Main Game")
    If GUICtrlRead($chkFullScrn) = $GUI_CHECKED Then
        $x = 0
        $y = 0
    ElseIf GUICtrlRead($chkFullScrn) = $GUI_UNCHECKED Then
        $x = @DesktopWidth / 2 - $size[0] / 2
        $y = @DesktopHeight / 2 - $size[1] / 2
    EndIf
    WinMove("Main Game","",$x,$y)
EndFunc

It's a straight copy/paste so if anything looks out of place that's why. I'm running at 1280x1024x32 so it looks fine on my system.

Edited by dbzfanatic
Link to comment
Share on other sites

Probably should've mentioned I'm running WinXP SP2. Thanks for telling me it works there but do you have any ideas why it would function on 98SE and not XP?

Edit: I found the problem. I had

$picBgOpt = GUICtrlCreatePic(@ScriptDir & "\Images\bg opt.bmp", 0, 0, 800, 600, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))oÝ÷ Û^Þy×jëh×6$picBgOpt = GUICtrlCreatePic(@ScriptDir & "\Images\bg opt.bmp", 0, 0, 800, 600, BitOR($WS_GROUP,$WS_CLIPSIBLINGS))

I still dont know why that change makes that much of a difference, I set the picture to the very back and the slider to the front but it works now. I could've sworn I tried that already but I guess I didn't.

Edited by dbzfanatic
Link to comment
Share on other sites

Yeah I think that was the problem. I realized it when I accidentally ran the script on a different computer in the network and hadn't copied the files over. I had no background but the slider worked perfectly, I think that's why it worked for Zedna as well. Also speaking of the slider is there a way to color it without drawing a picture or coloring the background? I mean to color the slider itself like have it at 0xB30A00 or something? If so how or could you point me in the right direction? I've searched for that and how to load things like pictures out of a resource DLL but I haven't found anything. I might've been using the wrong keywords but it's late (early technically, it's 3:50 AM here right now) so I'm tired and can't think :D . Thanks for all your help though, really appreciate the feedback, especially from Zedna which is what caused my accidental epiphany.

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