Sign in to follow this  
Followers 0
TheOrignl

GUIGetMsg() not giving a return or am I missing something?

3 posts in this topic

#1 ·  Posted (edited)

In the while loop at after the GUI $msg never gets a non-zero value. The implementation in Autoit is too simple. The problem has to be mine. Anyone see a glaring mistake?

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Array.au3>

Const $NULL = "", _
      $ANNC_LEFT = 10, $ANNC_TOP = 5, _
      $MSG_LEFT = 10, $MSG_TOP = 77, _
      $MOV_LEFT = 10, $MOV_TOP = 134, _
      $PATH_OFFSET = 24
Global $chk_annc = 0, $chk_msg = 0, $chk_mov = 0, $lbl_annc = 0, $lbl_msg = 0, $lbl_mov = 0, $btn_exec = 0, _ 
       $btn_annc = 0, $btn_msg = 0, $btn_mov = 0, $btn_exec = 0, $rootdir = "C:\", $attrib = "", _
       $infile = "", $msg = 0

Opt("GUIOnEventMode", 1)

$frm_get = GUICreate("What media do we need?",400 , 196, 291, 120)
;282
GUISetOnEvent($GUI_EVENT_CLOSE, "frm_getClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "frm_getMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "frm_getMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "frm_getRestore")

GUICtrlCreateGroup ( "Announcements", $ANNC_LEFT, $ANNC_TOP, 307 ,$ANNC_TOP+55)
$lbl_annc_stat = GUICtrlCreateLabel("Yes", $ANNC_LEFT+5,$ANNC_TOP+14 , 25, 17)
GUICtrlSetOnEvent($lbl_annc_stat, "lbl_annc_statClick")
$chk_annc = GUICtrlCreateCheckbox(" ", $ANNC_LEFT+42, $ANNC_TOP+14, 105, 19)
GUICtrlSetOnEvent($chk_annc, "chk_anncClick")
$btn_annc = GUICtrlCreateButton("Browse", $ANNC_LEFT+245, $ANNC_TOP+14, 57, 17, 0)
GUICtrlSetOnEvent($btn_annc, "btn_browse")
$lbl_annc_path = GUICtrlCreateLabel("", $ANNC_LEFT+5, $ANNC_TOP+14+$PATH_OFFSET, 298, 17, $SS_SUNKEN)
;GUICtrlSetOnEvent($lbl_annc_stat, "lbl_annc_pathClick")

$lbl_msg_stat = GUICtrlCreateLabel("Yes", $MSG_LEFT+5, $MSG_TOP, 25, 17)
GUICtrlSetOnEvent($lbl_msg_stat, "lbl_msg_statClick")
$chk_msg = GUICtrlCreateCheckbox("Message", $MSG_LEFT+42, $MSG_TOP, 73, 12)
GUICtrlSetOnEvent($chk_msg, "chk_msgClick")
$btn_msg = GUICtrlCreateButton("Browse", $MSG_LEFT+245, $MSG_TOP, 57, 17, 0)
GUICtrlSetOnEvent($btn_msg, "btn_browse")
$lbl_msg_path = GUICtrlCreateLabel("", $MSG_LEFT+5, $MSG_TOP+$PATH_OFFSET, 298, 17, $SS_SUNKEN)
;GUICtrlSetOnEvent($lbl_msg_stat, "lbl_msg_pathClick")

$lbl_mov_stat = GUICtrlCreateLabel("Yes", $MOV_LEFT+5, $MOV_TOP, 25, 17)
GUICtrlSetOnEvent($lbl_mov_stat, "lbl_mov_statClick")
$chk_mov = GUICtrlCreateCheckbox("Movie Clip", $MOV_LEFT+42, $MOV_TOP, 73, 10)
GUICtrlSetOnEvent($chk_mov, "chk_movClick")
$btn_mov = GUICtrlCreateButton("Browse", $MOV_LEFT+245, $MOV_TOP, 57, 17, 0)
GUICtrlSetOnEvent($btn_mov, "btn_browse")
$lbl_mov_path = GUICtrlCreateLabel("", $MOV_LEFT+5, $MOV_TOP+$PATH_OFFSET, 298, 17, $SS_SUNKEN)
;GUICtrlSetOnEvent($lbl_mov_stat, "lbl_mov_pathClick")

$btn_exec = GUICtrlCreateButton("Get", 336, 150, 49, 25, 0)
GUICtrlSetFont($btn_exec, 8, 800, 0, "MS Sans Serif")
GUICtrlSetOnEvent($btn_exec, "btn_execClick")
GUISetState(@SW_SHOW)

Call("frm_getInit")
;*****
While 1
;Sleep(100)
    $msg = GUIGetMsg()
    If ($msg <> 0) Then
    GUICtrlSetData($lbl_mov_path, $btn_annc & " "   &   $btn_msg & " " & $btn_mov & ": " & $msg)
  EndIf
WEnd
;*****
Func frm_getInit()
    GUICtrlSetState($chk_annc, $GUI_CHECKED)
    GUICtrlSetFont($lbl_annc_stat, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($lbl_annc_stat, $COLOR_GREEN)
    GUICtrlSetState($chk_msg, $GUI_CHECKED)
    GUICtrlSetFont($lbl_msg_stat, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($lbl_msg_stat, $COLOR_GREEN)
    GUICtrlSetState($chk_mov, $GUI_CHECKED)
    GUICtrlSetFont($lbl_mov_stat, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($lbl_mov_stat, $COLOR_GREEN)
EndFunc ;==>frm_getInit

Func frm_getClose()
    Exit
EndFunc ;==>frm_getClose

Func frm_getMaximize()
    
EndFunc ;==>frm_getMaximize

Func frm_getMinimize()
    
EndFunc ;==>frm_getMinimize

Func frm_getRestore()
    
EndFunc ;==>frm_getRestore

Func chk_anncClick()
    If (GUICtrlRead($chk_annc) = $GUI_UNCHECKED) Then
        GUICtrlSetData($lbl_annc_stat, "No")
        GUICtrlSetFont($lbl_annc_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_annc_stat, $COLOR_RED)
    Else
        GUICtrlSetData($lbl_annc_stat, "Yes")

        GUICtrlSetFont($lbl_annc_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_annc_stat, $COLOR_GREEN)
    EndIf
EndFunc ;==>chk_anncClick

Func chk_movClick()
    If (GUICtrlRead($chk_mov) = $GUI_UNCHECKED) Then
        GUICtrlSetData($lbl_mov_stat, "No")
        GUICtrlSetFont($lbl_mov_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_mov_stat, $COLOR_RED)
    Else
        GUICtrlSetData($lbl_mov_stat, "Yes")
        GUICtrlSetFont($lbl_mov_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_mov_stat, $COLOR_GREEN)
    EndIf
EndFunc ;==>chk_movClick

Func chk_msgClick()
    If (GUICtrlRead($chk_msg) = $GUI_UNCHECKED) Then
        GUICtrlSetData($lbl_msg_stat, "No")
        GUICtrlSetFont($lbl_msg_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_msg_stat, $COLOR_RED)
    Else
        GUICtrlSetData($lbl_msg_stat, "Yes")
        GUICtrlSetFont($lbl_msg_stat, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetColor($lbl_msg_stat, $COLOR_GREEN)
    EndIf
EndFunc ;==>chk_msgClick

Func lbl_annc_statClick()
    If (GUICtrlRead($chk_annc) = $GUI_UNCHECKED) Then
        GUICtrlSetState($chk_annc, $GUI_CHECKED)
    Else
        GUICtrlSetState($chk_annc, $GUI_UNCHECKED)
    EndIf
    Call("chk_anncClick")
EndFunc ;==>lbl_annc_statClick

Func lbl_mov_statClick()
    If (GUICtrlRead($chk_mov) = $GUI_UNCHECKED) Then
        GUICtrlSetState($chk_mov, $GUI_CHECKED)
    Else
        GUICtrlSetState($chk_mov, $GUI_UNCHECKED)
    EndIf
    Call("chk_movClick")
EndFunc ;==>lbl_mov_statClick

Func lbl_msg_statClick()
    If (GUICtrlRead($chk_msg) = $GUI_UNCHECKED) Then
        GUICtrlSetState($chk_msg, $GUI_CHECKED)
    Else
        GUICtrlSetState($chk_msg, $GUI_UNCHECKED)
    EndIf
    Call("chk_msgClick")
EndFunc ;==>lbl_msg_statClick

Func btn_execClick()
EndFunc ;==>btn_execClick

Func btn_browse()
    GUICtrlSetState($chk_annc, $GUI_DISABLE)
    GUICtrlSetState($chk_msg, $GUI_DISABLE)
    GUICtrlSetState($chk_mov, $GUI_DISABLE)
    GUICtrlSetState($lbl_annc_stat, $GUI_DISABLE)
    GUICtrlSetState($lbl_msg_stat, $GUI_DISABLE)
    GUICtrlSetState($lbl_mov_stat, $GUI_DISABLE)
    GUICtrlSetState($btn_annc, $GUI_DISABLE)
    GUICtrlSetState($btn_msg, $GUI_DISABLE)
    GUICtrlSetState($btn_mov, $GUI_DISABLE)
    GUICtrlSetState($btn_exec, $GUI_DISABLE)
    While ($infile = $NULL And @error = 0)
        $infile = FileOpenDialog("Locate Announcements", "Z:\Announcement_Slides", _
                                 "Announcement Presentations (*.dat)", 1, @YEAR & "*.ppt", $frm_get)
    WEnd
  GUICtrlSetData($lbl_annc_path, $infile)
    GUICtrlSetState($chk_annc, $GUI_ENABLE)
    GUICtrlSetState($chk_msg, $GUI_ENABLE)
    GUICtrlSetState($chk_mov, $GUI_ENABLE)
    GUICtrlSetState($lbl_annc_stat, $GUI_ENABLE)
    GUICtrlSetState($lbl_msg_stat, $GUI_ENABLE)
    GUICtrlSetState($lbl_mov_stat, $GUI_ENABLE)
    GUICtrlSetState($btn_annc, $GUI_ENABLE)
    GUICtrlSetState($btn_msg, $GUI_ENABLE)
    GUICtrlSetState($btn_mov, $GUI_ENABLE)
    GUICtrlSetState($btn_exec, $GUI_ENABLE)
EndFunc ;==>btn_browse

Thanks for the extra eyes. :mellow:

TheO

Edited by TheOrignl

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

Share this post


Link to post
Share on other sites



Your using Opt("GUIOnEventMode", 1) near the top of your script which makes GuiGetMsg() redundant.

You can only use one method or the other , but you can't use both methods at the same time.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Your using Opt("GUIOnEventMode", 1) near the top of your script which makes GuiGetMsg() redundant.

You can only use one method or the other , but you can't use both methods at the same time.

Thanks smashly. Rusty C programmer here missing some of the intricate details of Autoit. :mellow: Edited by TheOrignl

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

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