Jump to content

GUICtrlCreateMenuItem


layer
 Share

Recommended Posts

hey guys... im trying to be able to "toggle" a menu_item... is there a way to put a check next to a menu item?? heres part of my editor that has the non working toggling...

Func WordWrapOn ()
   Local $edit_styles= BitOR ($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)
$edit= GUICtrlCreateEdit ("", -1, -1, 300, 400, $edit_styles)
EndFunc

Func WordWrapOff ()
   GUICtrlDelete ($edit)
   $edit= GUICtrlCreateEdit ("", -1, -1, 300, 400, $ES_WANTRETURN)
EndFunc

Func ToggleWordWrap ()
   if $menu_item5= $GUI_CHECKED Then
      WordWrapOn ()
      EndIf
   If $menu_item5= $GUI_UNCHECKED Then
      WordWrapOff ()
      EndIf
EndFunc

While 1
$get= GUIGetMsg ()
Select 
Case $get = $menu_item5
ToggleWordWrap ()
Wend

now, is it possible to put a check next to a menu_item? i have no clue, so could someone help me with that... i think that would solve it...

EDIT: the help file is a charm... nevermind.... but i don't think the toggle works though.. any help? :idiot:

EDIT2: actually i think the help file covers it all... i will ask if i need help! thanks! :D also had some wrong code i think in the above script...

Edited by layer
FootbaG
Link to comment
Share on other sites

Here's an example:

#include <GUIConstants.au3>
AutoItSetOption("TrayIconDebug", 1)

;Initialize variables
Global $style1
Global $IniFile
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 250
$GUIHeight = 250

GUICreate("New GUI", $GUIWidth, $GUIHeight)

$Main_menu = GUICtrlCreateMenu("View")
   $Menu_Item = GUICtrlCreateMenuItem("Test", $Main_menu)

GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
   
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit

      Case $msg = $Menu_Item
         If BitAND(GUICtrlRead($Menu_Item), $GUI_CHECKED) Then
            GUICtrlSetState($Menu_Item, $GUI_UNCHECKED)
         Else
            GUICtrlSetState($Menu_Item, $GUI_CHECKED)
         EndIf
         
   EndSelect

WEnd
Link to comment
Share on other sites

slim's probably works best but heres mine...

btw: im not very good with toggling anyway so :idiot:

Func WordWrapOn ()
   Local $edit_styles= BitOR ($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)
$edit= GUICtrlCreateEdit ("", -1, -1, 300, 400, $edit_styles)
GUICtrlSetState ($menu_item5, $GUI_CHECKED)
EndFunc

Func WordWrapOff ()
***TRYING TO FIND SOMETHING FOR HERE*** GUICtrlSetState? I dont know! ALSO TRYING TO FIND WAY TO MAKE IT SO YOU DON'T HAVE TO DELETE IT AND SET STYLES AGAIN..
EndFunc

    Case $get = $menu_item5
        If BitAnd(GUICtrlRead($menu_item5),$GUI_CHECKED) = $GUI_CHECKED then
            GUICtrlSetState($menu_item5, $GUI_UNCHECKED)
            WordWrapOff ()
        Else
            GUICtrlSetState($menu_item5, $GUI_CHECKED)
            WordWrapOn ()
        EndIf

pretend all the variables are declared though...although it still seems a bit buggy but im going to fix it..

EDIT: fixed something in script..

Edited by layer
FootbaG
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...