Jump to content

Using a GUIGetMsg() from a label


Blue_Drache
 Share

Recommended Posts

Ok, the posted code works!!! When one clicks on the item. However, if one selects the U]nderlined character, it does NOT work...it selects the first combo-box, $cbox_Who, no matter which one you're trying to focus.

What have I done wrong?

#include <GUIConstants.au3>
Opt("WinTitleMatchMode",4)
#Region ### START Koda GUI section ### Form=c:\documents and settings\u256655\desktop\autoit\user scripts\mailtomarshallcart\mail2marshallcart.kxf
$hwndGUI_Main = GUICreate("Marshall Mail Assistant", 393, 640, 193, 115)
$cbox_Who = GUICtrlCreateCombo("Marshall_Cart", 24, 128, 161, 25)
$cbox_Type = GUICtrlCreateCombo("COCC", 208, 128, 161, 25)
$txt_Date01 = GUICtrlCreateEdit("", 24, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Date02 = GUICtrlCreateEdit("", 208, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Group = GUICtrlCreateEdit("", 24, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_UID = GUICtrlCreateEdit("", 208, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Comments = GUICtrlCreateEdit("", 24, 272, 345, 281, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$btn_Send = GUICtrlCreateButton("&Send", 24, 576, 113, 33, 0)
$btn_Exit = GUICtrlCreateButton("E&xit", 256, 576, 113, 33, 0)
$lbl_txtComments = GUICtrlCreateLabel("Additional &Comments and/or Documentation", 24, 256, 218, 17)
$lbl_txtGroup = GUICtrlCreateLabel("Subscriber's &Group", 24, 200, 99, 17)
$lbl_txtDate01 = GUICtrlCreateLabel("&Date START", 24, 152, 72, 17)
$lbl_txtUID = GUICtrlCreateLabel("Subscriber's &UID", 208, 200, 89, 17)
$lbl_txtDate02 = GUICtrlCreateLabel("Date &END", 208, 152, 59, 17)
$lbl_cboxWho = GUICtrlCreateLabel("&Recipient", 24, 112, 55, 17)
$lbl_cboxType = GUICtrlCreateLabel("&Type of Review", 208, 112, 85, 17)
;~ $img_Logo = GUICtrlCreatePic(@ScriptDir & "\Logo_Large.jpg", 24, 0, 345, 105, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$lbl_Logo = GUICtrlCreateLabel("Mail Assistant", 24, 0, 345, 105)
GUICtrlSetBkColor($lbl_Logo,0xFFFFFF)
GUICtrlSetFont($lbl_Logo,24,400)
$mnu_Main = GUICtrlCreateMenu("&File")
$mnu_MainSend = GUICtrlCreateMenuItem("&Send", $mnu_Main)
GUICtrlCreateMenuItem("", $mnu_Main)
$mnu_MainExit = GUICtrlCreateMenuItem("E&xit", $mnu_Main)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $btn_Exit, $mnu_MainExit
            Exit
        Case $lbl_cboxType, $lbl_cboxWho, $lbl_txtComments, $lbl_txtDate01, $lbl_txtDate02, $lbl_txtGroup, $lbl_txtUID
            _SwitchFocus($nMsg)
    EndSwitch
WEnd

Func _SwitchFocus($sz_Msg)
    Switch $sz_Msg
        Case $lbl_cboxType
            ControlFocus($hwndGUI_Main,"",$cbox_Type)
        Case $lbl_cboxWho
            ControlFocus($hwndGUI_Main,"",$cbox_Who)
        Case $lbl_txtComments
            ControlFocus($hwndGUI_Main,"",$txt_Comments)
        Case $lbl_txtDate01
            ControlFocus($hwndGUI_Main,"",$txt_Date01)
        Case $lbl_txtDate02
            ControlFocus($hwndGUI_Main,"",$txt_Date02)
        Case $lbl_txtGroup
            ControlFocus($hwndGUI_Main,"",$txt_Group)
        Case $lbl_txtUID
            ControlFocus($hwndGUI_Main,"",$txt_UID)
        Case Else
            ; Empty for now
    EndSwitch
EndFunc

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

No, the above code works if you click the label, however, the keyboard shortcut doesn't work.

You'll see from here that keyboard event isn't listed for static control

You could use _IsPressed I suppose, or better yet HotKeySet

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

hide button. now WS_TABSTOP need remove

#include <GUIConstants.au3>

$gui = GUICreate("GUI")
GUICtrlCreateLabel("a &test",0,0,100,20,$SS_RIGHT)
$schmext = GUICtrlCreateInput("",0,100,100,20)
$txt = GUICtrlCreateInput("",100,0,100,20)

$hidebutton = GUICtrlCreateButton("&thide",0,-30,80,20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $hidebutton Then ControlFocus($gui,"",$txt)
WEnd
~Jap

Link to comment
Share on other sites

You'll see from here that keyboard event isn't listed for static control

You could use _IsPressed I suppose, or better yet HotKeySet

Ick. HotKeySet is not an option I like to consider as it causes its own host of problems. If that was the only option, I'd sooner just take the simple route (read lazy) and remove the idea from the project.

hide button. now WS_TABSTOP need remove

Interesting idea. That will work.

Now...after tinkering with the code, how do I remove the $WS_TABSTOP style from the control? Koda won't let me uncheck, and I'm not sure how to remove it by hand. (Yes, I know it's a "forced" style)

EDIT: Control's $WS_TABSTOP is removed when GUICtrlSetState(-1,$GUI_HIDE) is set. And so is the ability to use the ALT+key shortcut.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

replace style

#include <GUIConstants.au3>

$gui = GUICreate("GUI")

GUICtrlCreateLabel("a &test",0,0,100,20,$SS_RIGHT)
$schmext = GUICtrlCreateInput("",0,100,100,20)
$txt = GUICtrlCreateInput("",100,0,100,20)

$hidebutton = GUICtrlCreateButton("&thide",0,-30,80,20)
GUICtrlSetStyle(-1,$BS_FLAT)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $hidebutton Then ControlFocus($gui,"",$txt)
WEnd
crazy dazy ~Jap

Link to comment
Share on other sites

*smacks forehead* UREKA!

Thank you!

Edit: Unureka.... bummer.

After further testing:

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 4)
Dim $imgFile = @ScriptDir & "\BCBSLogo.jpg"
#Region ### START Koda GUI section ### Form=c:\documents and settings\u256655\desktop\autoit\user scripts\mailtomarshallcart\mail2marshallcart.kxf
$hwndGUI_Main = GUICreate("Marshall Mail Assistant", 393, 640, 193, 115)
If Not FileExists($imgFile) Then
    $lbl_Logo = GUICtrlCreateLabel("Marshall Membership" & @CR & "Mail Assistant", 24, 0, 345, 55)
    GUICtrlSetStyle($lbl_Logo, $SS_CENTER)
    GUICtrlSetBkColor($lbl_Logo, 0xFFFFFF)
    GUICtrlSetFont($lbl_Logo, 18, 400)
Else
    $img_Logo = GUICtrlCreatePic($imgFile, 24, 0, 345, 110, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
EndIf
$mnu_Main = GUICtrlCreateMenu("&File")
$mnu_MainSend = GUICtrlCreateMenuItem("&Send", $mnu_Main)
GUICtrlCreateMenuItem("", $mnu_Main)
$mnu_MainExit = GUICtrlCreateMenuItem("E&xit", $mnu_Main)
$cbox_Who = GUICtrlCreateCombo("Marshall Cart", 24, 128, 161, 25)
$cbox_Type = GUICtrlCreateCombo("COCC/Pre-Ex", 208, 128, 161, 25)
GUICtrlSetData(-1,"Reprocess")
$txt_Date01 = GUICtrlCreateEdit("", 24, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Date02 = GUICtrlCreateEdit("", 208, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Group = GUICtrlCreateEdit("", 24, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_UID = GUICtrlCreateEdit("", 208, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Comments = GUICtrlCreateEdit("", 24, 272, 345, 281, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$btn_Send = GUICtrlCreateButton("&Send", 24, 576, 113, 33, 0)
$btn_Exit = GUICtrlCreateButton("E&xit", 256, 576, 113, 33, 0)
$lbl_txtComments = GUICtrlCreateLabel("Additional &Comments and/or Documentation", 24, 256, 218, 17)
$btn_txtComments = GUICtrlCreateButton("&C", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_txtGroup = GUICtrlCreateLabel("Subscriber's &Group", 24, 200, 99, 17)
$btn_txtGroup = GUICtrlCreateButton("&G", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_txtDate01 = GUICtrlCreateLabel("&Date START", 24, 152, 72, 17)
$btn_txtDate01 = GUICtrlCreateButton("&D", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_txtUID = GUICtrlCreateLabel("Subscriber's &UID", 208, 200, 89, 17)
$btn_txtUID = GUICtrlCreateButton("&U", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_txtDate02 = GUICtrlCreateLabel("Date &END", 208, 152, 59, 17)
$btn_txtDate02 = GUICtrlCreateButton("&E", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_cboxWho = GUICtrlCreateLabel("&Recipient", 24, 112, 55, 17)
$btn_cboxWho = GUICtrlCreateButton("&R", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$lbl_cboxType = GUICtrlCreateLabel("&Type of Review", 208, 112, 85, 17)
$btn_cboxType = GUICtrlCreateButton("&T", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $btn_Exit, $mnu_MainExit
            Exit
        Case $btn_cboxType, $btn_cboxWho, $btn_txtComments, $btn_txtDate01, $btn_txtDate02, $btn_txtGroup, $btn_txtUID; $lbl_cboxType, $lbl_cboxWho, $lbl_txtComments, $lbl_txtDate01, $lbl_txtDate02, $lbl_txtGroup, $lbl_txtUID,
            _SwitchFocus($nMsg)
    EndSwitch
WEnd
Func _SwitchFocus($sz_Msg)
    Switch $sz_Msg
        Case $btn_cboxType
            ControlFocus($hwndGUI_Main, "", $cbox_Type)
        Case $btn_cboxWho
            ControlFocus($hwndGUI_Main, "", $cbox_Who)
        Case $btn_txtComments
            ControlFocus($hwndGUI_Main, "", $txt_Comments)
        Case $btn_txtDate01
            ControlFocus($hwndGUI_Main, "", $txt_Date01)
        Case $btn_txtDate02
            ControlFocus($hwndGUI_Main, "", $txt_Date02)
        Case $btn_txtGroup
            ControlFocus($hwndGUI_Main, "", $txt_Group)
        Case $btn_txtUID
            ControlFocus($hwndGUI_Main, "", $txt_UID)
        Case Else
            ; Empty for now
    EndSwitch
EndFunc   ;==>_SwitchFocus

Produces the same result as the original code. ONLY the first tabstopped item (in this case, cboxWho) is selected.

I'm going to consider this dead and just remove the idea of this style of keyboard shortcuts from the project. Thank you all for the help.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

dont give up- order was magic-

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 4)
Dim $imgFile = @ScriptDir & "\BCBSLogo.jpg"
#Region ### START Koda GUI section ### Form=c:\documents and settings\u256655\desktop\autoit\user scripts\mailtomarshallcart\mail2marshallcart.kxf
$hwndGUI_Main = GUICreate("Marshall Mail Assistant", 393, 640, 193, 115)

$btn_txtGroup = GUICtrlCreateButton("&gtest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_txtDate01 = GUICtrlCreateButton("&dtest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_txtUID = GUICtrlCreateButton("&utest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_txtDate02 = GUICtrlCreateButton("&etest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_cboxWho = GUICtrlCreateButton("&rtest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_cboxType = GUICtrlCreateButton("&ttest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)
$btn_txtComments = GUICtrlCreateButton("&ctest", 24, -50, 50, 33, 0)
GUICtrlSetStyle(-1,$BS_FLAT)

$lbl_txtComments = GUICtrlCreateLabel("Additional &Comments and/or Documentation", 24, 256, 218, 17)
$lbl_txtGroup = GUICtrlCreateLabel("Subscriber's &Group", 24, 200, 99, 17)
$lbl_txtDate01 = GUICtrlCreateLabel("&Date START", 24, 152, 72, 17)
$lbl_txtUID = GUICtrlCreateLabel("Subscriber's &UID", 208, 200, 89, 17)
$lbl_txtDate02 = GUICtrlCreateLabel("Date &END", 208, 152, 59, 17)
$lbl_cboxWho = GUICtrlCreateLabel("&Recipient", 24, 112, 55, 17)
$lbl_cboxType = GUICtrlCreateLabel("&Type of Review", 208, 112, 85, 17)

If Not FileExists($imgFile) Then
    $lbl_Logo = GUICtrlCreateLabel("Marshall Membership" & @CR & "Mail Assistant", 24, 0, 345, 55)
    GUICtrlSetStyle($lbl_Logo, $SS_CENTER)
    GUICtrlSetBkColor($lbl_Logo, 0xFFFFFF)
    GUICtrlSetFont($lbl_Logo, 18, 400)
Else
    $img_Logo = GUICtrlCreatePic($imgFile, 24, 0, 345, 110, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
EndIf
$mnu_Main = GUICtrlCreateMenu("&File")
$mnu_MainSend = GUICtrlCreateMenuItem("&Send", $mnu_Main)
GUICtrlCreateMenuItem("", $mnu_Main)
$mnu_MainExit = GUICtrlCreateMenuItem("E&xit", $mnu_Main)
$cbox_Who = GUICtrlCreateCombo("Marshall Cart", 24, 128, 161, 25)
$cbox_Type = GUICtrlCreateCombo("COCC/Pre-Ex", 208, 128, 161, 25)
GUICtrlSetData(-1,"Reprocess")
$txt_Date01 = GUICtrlCreateEdit("", 24, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Date02 = GUICtrlCreateEdit("", 208, 168, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Group = GUICtrlCreateEdit("", 24, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_UID = GUICtrlCreateEdit("", 208, 216, 161, 25, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$txt_Comments = GUICtrlCreateEdit("", 24, 272, 345, 281, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$btn_Send = GUICtrlCreateButton("&Send", 24, 576, 113, 33, 0)
$btn_Exit = GUICtrlCreateButton("E&xit", 256, 576, 113, 33, 0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $btn_Exit, $mnu_MainExit
            Exit
        Case $btn_cboxType, $btn_cboxWho, $btn_txtComments, $btn_txtDate01, $btn_txtDate02, $btn_txtGroup, $btn_txtUID; $lbl_cboxType, $lbl_cboxWho, $lbl_txtComments, $lbl_txtDate01, $lbl_txtDate02, $lbl_txtGroup, $lbl_txtUID,
            _SwitchFocus($nMsg)
    EndSwitch
WEnd
Func _SwitchFocus($sz_Msg)
    Switch $sz_Msg
        Case $btn_cboxType
            ControlFocus($hwndGUI_Main, "", $cbox_Type)
        Case $btn_cboxWho
            ControlFocus($hwndGUI_Main, "", $cbox_Who)
        Case $btn_txtComments
            ControlFocus($hwndGUI_Main, "", $txt_Comments)
        Case $btn_txtDate01
            ControlFocus($hwndGUI_Main, "", $txt_Date01)
        Case $btn_txtDate02
            ControlFocus($hwndGUI_Main, "", $txt_Date02)
        Case $btn_txtGroup
            ControlFocus($hwndGUI_Main, "", $txt_Group)
        Case $btn_txtUID
            ControlFocus($hwndGUI_Main, "", $txt_UID)
        Case Else
            ; Empty for now
    EndSwitch
EndFunc   ;==>_SwitchFocus
fool around and find some rule- ~Jap

edit; lef debug tooltip

Edited by JBeef
Link to comment
Share on other sites

dont give up- order was magic-

<snip>
fool around and find some rule- ~Jap

edit; lef debug tooltip

Thank you, I'll try swaping the order it draws it then. My other solution was to turn the labels into flat buttons with the $BS_FLAT style ... but the border looked horrid, and I couldn't puzzle out how to change the colour of that.

And I think I discovered a bug in the GUI functions...

$button = GUICtrlCreateButton(x,y,w,h,BitOR($BS_FLAT,$BS_TOP))

GUICtrlSetBackground($button,0x808080)

The $BS_TOP winds up getting ignored and the text gets centered again...in fact, it appears to have all custom styling removed after setting the background colour.

*shrug* Anyway....could be just me.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Still getting odd behaviour from the button/label combinations with the same shortcut character defined with an "&". I suppose it's to be expected since I'm probably confusing the GUI. Either way, I suppose now, the only way to get what I want to display correctly is to create a bunch of lables and line them up *crosses eyes*

I'm lazy....

*scraps the idea again*

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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