Jump to content
Sign in to follow this  
layer

GUICtrlCreateMenuItem

Recommended Posts

layer

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

Share this post


Link to post
Share on other sites
Doxie

Any chance we can see how you solved it?


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
SlimShady

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

Share this post


Link to post
Share on other sites
Doxie

Thanks, but there was a small error in the script.

GUICtrlRead shoud be GUIRead

Right? :idiot:


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
MHz

GUIRead changed to GUICtrlRead in v1.0.103.133. Released 24th Dec. Time to update. :idiot:

Share this post


Link to post
Share on other sites
Doxie

I thought i was updated, hmm this starts to look more and more like Microsoft Vulnerability update :idiot:

Everytime you reboot, you need to update your computer.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Nova

Everytime you reboot, you need to update your computer.

I know its graet isnt it ?, all those new functions and santax :idiot:

Share this post


Link to post
Share on other sites
layer

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.