Sign in to follow this  
Followers 0
StoneCut

Help with Koda please

9 posts in this topic

Hi,

I'm having some issues with the code that Koda 1.6 generates. I've created a GUI with a background image. On top of this I place some more images which are supposed to become buttons at some point. However, the images I place on top of the background image either do not show up, or if they do show up then the events are not triggered. Here's an example:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=f:\my_gui_work\remotejoy4irs.kxf
$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
$GUI_Background_Image = GUICtrlCreatePic("F:\MY_GUI_work\images\Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Window_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_Button.JPG", 33, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Window_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_FPS_Button.JPG", 79, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Fullscreen_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_Button.JPG", 33, 81, 41, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Fullscreen_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_FPS_Button.JPG", 79, 81, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Defaults_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Defaults_Button.JPG", 33, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Keyboard_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Keyboard_Button.JPG", 79, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_2nd_Joypad_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_2nd_Pad_Button.JPG", 33, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Cygdrive_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Cygdrive_Button.JPG", 79, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Exit_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Exit_Button.JPG", 62, 231, 30, 30, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Window_Button
            MsgBox (0, "Test", "I'd like to see this message box but it never happens ...")
        Case $Window_FPS_Button
        Case $Fullscreen_Button
        Case $Fullscreen_FPS_Button
        Case $USB_Defaults_Button
        Case $USB_Keyboard_Button
        Case $USB_2nd_Joypad_Button
        Case $USB_Cygdrive_Button
        Case $Exit_Button
    EndSwitch
WEnd

I've messed with the code and noticed that if I remove the "BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)" references from the code and then move the background image (Menu.jpg) to be loaded last then it actually displays my other images layered over it. BUT then the messagebox doesn't work.

Can anyone help a newbie figure out what's wrong, please ?

Share this post


Link to post
Share on other sites



Hi,

I'm having some issues with the code that Koda 1.6 generates. I've created a GUI with a background image. On top of this I place some more images which are supposed to become buttons at some point. However, the images I place on top of the background image either do not show up, or if they do show up then the events are not triggered. Here's an example:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=f:\my_gui_work\remotejoy4irs.kxf
$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
$GUI_Background_Image = GUICtrlCreatePic("F:\MY_GUI_work\images\Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Window_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_Button.JPG", 33, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Window_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_FPS_Button.JPG", 79, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Fullscreen_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_Button.JPG", 33, 81, 41, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Fullscreen_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_FPS_Button.JPG", 79, 81, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Defaults_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Defaults_Button.JPG", 33, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Keyboard_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Keyboard_Button.JPG", 79, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_2nd_Joypad_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_2nd_Pad_Button.JPG", 33, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$USB_Cygdrive_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Cygdrive_Button.JPG", 79, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Exit_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Exit_Button.JPG", 62, 231, 30, 30, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Window_Button
            MsgBox (0, "Test", "I'd like to see this message box but it never happens ...")
        Case $Window_FPS_Button
        Case $Fullscreen_Button
        Case $Fullscreen_FPS_Button
        Case $USB_Defaults_Button
        Case $USB_Keyboard_Button
        Case $USB_2nd_Joypad_Button
        Case $USB_Cygdrive_Button
        Case $Exit_Button
    EndSwitch
WEnd

I've messed with the code and noticed that if I remove the "BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)" references from the code and then move the background image (Menu.jpg) to be loaded last then it actually displays my other images layered over it. BUT then the messagebox doesn't work.

Can anyone help a newbie figure out what's wrong, please ?

Try adding code manually to disable the background image and see if that helps.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Try adding code manually to disable the background image and see if that helps.

First off, many thanks for your reply.

If I disable the background image then the GUI never gets shown and I end up in a loop with my MsgBox :)

I also tried the event code from Koda and there I get other results. If I turn off background image it works fine. If I leave it on I have the same behaviour.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here's the event-based code which works as long as I leave the background image disabled:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=f:\my_gui_work\remotejoy4irs.kxf
$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
GUISetOnEvent($GUI_EVENT_CLOSE, "RemoteJoy4iRSClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "RemoteJoy4iRSMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "RemoteJoy4iRSMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "RemoteJoy4iRSRestore")
;
; If I enable this background image then my GUI becomes unusable since the other "buttons" don't work anymore.
; $GUI_Background_Image = GUICtrlCreatePic("F:\MY_GUI_work\images\Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
;
$Window_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_Button.JPG", 33, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "Window_Buttonclick")
$Window_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Window_FPS_Button.JPG", 79, 39, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "Window_FPS_Buttonclick")
$Fullscreen_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_Button.JPG", 33, 81, 41, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "Fullscreen_Buttonclick")
$Fullscreen_FPS_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Fullscreen_FPS_Button.JPG", 79, 81, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "Fullscreen_FPS_Buttonclick")
$USB_Defaults_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Defaults_Button.JPG", 33, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "USB_Defaults_Buttonclick")
$USB_Keyboard_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Keyboard_Button.JPG", 79, 137, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "USB_Keyboard_Buttonclick")
$USB_2nd_Joypad_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_2nd_Pad_Button.JPG", 33, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "USB_2nd_Joypad_Buttonclick")
$USB_Cygdrive_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\USB_Cygdrive_Button.JPG", 79, 179, 41, 41, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "USB_Cygdrive_Buttonclick")
$Exit_Button = GUICtrlCreatePic("F:\MY_GUI_work\images\Exit_Button.JPG", 62, 231, 30, 30, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "Exit_Buttonclick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Exit_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
    Exit
EndFunc

Func RemoteJoy4iRSClose()
    MsgBox (0, "Yeah", "that worked")
    Exit
EndFunc

Func RemoteJoy4iRSMaximize()
;
EndFunc

Func RemoteJoy4iRSMinimize()
;
EndFunc

Func RemoteJoy4iRSRestore()
;
EndFunc

Func Fullscreen_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func Fullscreen_FPS_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func USB_2nd_Joypad_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func USB_Cygdrive_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func USB_Defaults_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func USB_Keyboard_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func Window_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

Func Window_FPS_Buttonclick()
    MsgBox (0, "Yeah", "that worked")
EndFunc

I have no idea why it's not working. It must have something to do with foreground/background but I tried messing with that property in Koda but it didn't help at all.

Edited by StoneCut

Share this post


Link to post
Share on other sites

First version with picture as button

#include <GUIConstants.au3>

$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
$GUI_Background_Image = GUICtrlCreatePic("Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GuiCtrlSetState(-1,$GUI_DISABLE)
$Window_Button = GUICtrlCreatePic("b1.jpg", 33, 39, 41, 41)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Window_Button
            MsgBox (0, "Test", "I'd like to see this message box but it never happens ...")
    EndSwitch
WEnd

Second version with real button with bitmap surface

#include <GUIConstants.au3>

$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
$GUI_Background_Image = GUICtrlCreatePic("Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GuiCtrlSetState(-1,$GUI_DISABLE)
$Window_Button = GUICtrlCreateButton("", 33, 39, 41, 41, $BS_BITMAP)
GUICtrlSetImage(-1,"b2.bmp")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Window_Button
            MsgBox (0, "Test", "I'd like to see this message box but it never happens ...")
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Wow, both solutions are absolutely awesome. You rock !! Many thanks.

I have a question about the second version: Is it possible to make a borderless button ?

EDIT

Hhhm, I want these buttons to be toggles so that they show a different image after they are pressed by using variables as flags. However, how I would now load a different image ?

#include <GUIConstants.au3>

$RemoteJoy4iRS = GUICreate("RemoteJoy4iRS", 155, 273, 194, 117)
$GUI_Background_Image = GUICtrlCreatePic("Menu.jpg", 0, 0, 154, 272, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GuiCtrlSetState(-1,$GUI_DISABLE)
$Window_Button = GUICtrlCreatePic("b1.jpg", 33, 39, 41, 41)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Window_Button
            MsgBox (0, "Test", "Ok, let's change the bitmap to indicate we toggled our function")
            $Window_Button = GUICtrlCreatePic("b1_ON.jpg", 33, 39, 41, 41)
    EndSwitch
WEnd
Edited by StoneCut

Share this post


Link to post
Share on other sites

Wow, both solutions are absolutely awesome. You rock !! Many thanks.

I have a question about the second version: Is it possible to make a borderless button ?

Try $BS_FLAT style for button if it's for you. Or another styles/ext. styles. Try experimenting...

BitOr($BS_FLAT, $BS_BITMAP)

Share this post


Link to post
Share on other sites

EDIT

Hhhm, I want these buttons to be toggles so that they show a different image after they are pressed by using variables as flags. However, how I would now load a different image ?

GUICtrlSetImage()

Share this post


Link to post
Share on other sites

Thank you, you are very helpful. The GUICtrlSetImage ($Window_Button, "b1_ON.jpg") stuff works very well. I will just have to transfer my logic from the old "ugly" GUI over now, hehe.

I will definitely experiment with the button styles, too, though since I sort of like that idea. It would also make the code transfer even easier, lol :)

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