Sign in to follow this  
Followers 0
NELyon

Buttons won't work on GUI

9 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstants.au3>
HotKeySet("^q", "end")
$gui = GUICreate("SimpleEditor",504,648,-1,-1,$WS_POPUP)
GUICtrlCreatePic("skin.bmp",0,0,504,648, @SW_LOCK)
$Edit1 = GUICtrlCreateEdit("", 30, 110, 440, 410)
GUICtrlSetBkColor($Edit1, 0x555ff)
$Button1 = GUICtrlCreateButton("Save", 34, 529, 100, 50)
$Button2 = GUICtrlCreateButton("open", 191, 528, 100, 50)
$Button3 = GUICtrlCreateButton("New", 340, 528, 100, 50)
$a = DLLCall(".\BMP2RGN.dll","int","BMP2RGN", _
            "str",".\larry.bmp", _
            "int",0, _
            "int",0, _
            "int",0)

SetWindowRgn($gui, $a[0])

GUISetState()
While 1
    $Msg = GUIGetMsg()
If $Msg = $Button1 then
    FileWrite(FilesaveDialog("Select a file to save",@ScriptDir, "All Files (*.*)"),GUICtrlRead($Edit1))
    ElseIf $Msg = $Button2 Then
    GUICtrlSetData($Edit1,Fileread(FileOpenDialog("Select a file to open",@ScriptDir, "All Files (*.*)"))) 
    ElseIf $Msg = $Button2 then
    GUICtrlSetData($Edit1, "")
EndIf
sleep(2000)
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func end()
    Exit
EndFunc

Does anyone know why the buttons won't work? I can click them, and they will get focus, and if i click the edit it will take focus, but the button's functions are ignored.

I will attatch the picture in JPG form, but the image won't work unless converted back to bitmap.

PS: Thanks larry for the great dll!

Edited by codemyster

Share this post


Link to post
Share on other sites



I have it set up, all of the controls appear, and i can click on them all to give them ficus. When i click my buttons, they press down, but the function just isn't called. None of the buttons get called.

Share this post


Link to post
Share on other sites

yes the picture is taking the focus away and everything you must disable it or else your controls will not work

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I $GUI_DISABLE'd it and it did the same thing. I can click the buttons, and change the focus between the controls 100% Fine, it is just the funtions are not being called when i click the buttons.

Edited by codemyster

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

HGAAHHA scratch that error, forgot to put the dll on my desktop i dont see what your trying to do ive seen larrys thing b4 but your creating a picture as a background but then setting larrys picture as the background , and the shape of the gui why?

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

So there is no title bar at all, so it looks like the top of the image is a forged title bar

Share this post


Link to post
Share on other sites

to my stupidty i didnt notice you had the sleep(2000) in the loop

#include <GUIConstants.au3>
HotKeySet("^q", "end")
$gui = GUICreate("SimpleEditor",504,648,-1,-1,$WS_POPUP)
GUICtrlCreatePic("skin.bmp",0,0,504,648, @SW_LOCK)
$Edit1 = GUICtrlCreateEdit("", 30, 110, 440, 410)
GUICtrlSetBkColor($Edit1, 0x555ff)
$Button1 = GUICtrlCreateButton("Save", 34, 529, 100, 50)
$Button2 = GUICtrlCreateButton("open", 191, 528, 100, 50)
$Button3 = GUICtrlCreateButton("New", 340, 528, 100, 50)
$a = DLLCall(".\BMP2RGN.dll","int","BMP2RGN", _
            "str",".\skin.bmp", _
            "int",0, _
            "int",0, _
            "int",0)

SetWindowRgn($gui, $a[0])

GUISetState()
While 1
    $Msg = GUIGetMsg($gui)
If $Msg = $Button1 then
    FileWrite(FilesaveDialog("Select a file to save",@ScriptDir, "All Files (*.*)"),GUICtrlRead($Edit1))
    ElseIf $Msg = $Button2 Then
    GUICtrlSetData($Edit1,Fileread(FileOpenDialog("Select a file to open",@ScriptDir, "All Files (*.*)")))
    ElseIf $Msg = $Button2 then
    GUICtrlSetData($Edit1, "")
EndIf
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func end()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Yes! Thank you very much!

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  
Followers 0