Jump to content

Recommended Posts

Posted

I'm positive there is a way to do this somewhere but I just have no idea of what to search to find the answer. My question is probably simple for some of the masters here so could someone help me real quick?

#include <WindowsConstants.au3>
$gui = GuiCreate("",640,480,-1,-1)
Opt("GUIOnEventMode",1)
GuiSetOnEvent(-3,"_Exit")
$menu = GUICtrlCreateMenu("File")
$save = GUICtrlCreateMenuItem("Save",$menu)
$options = GUICtrlCreateMenu("Options",$menu)
$font_size = GUICtrlCreateMenu("Font Size",$options)
Local $size[13]
For $i = 1 To 12
    $size[$i] = GUICtrlCreateMenuItem($i*6,$font_size)
    GUICtrlSetOnEvent($size[$i],"_Font_Size")
Next
GuiSetState()

While 1
Sleep(10)
Wend

Func _Exit()
Exit
EndFunc


Func _Font_Size()
    $size_n = @GUI_CtrlId
    MsgBox(0,"",$size_n)
EndFunc

When the user clicks on one of the font (say 72) I want the msgbox to return "72" not 18 like it is now. I thought to maybe times the id by something but then I realized how stupid that was so could someone please help me out with my problem.

Thanks in advance!

Posted

Guictrlgetdata () is what is usually used on input boxes etc, I think you can use it on menu items as well but I'm not at a computer right now. 

Otherwise, use a second array that stores the values you wish to return 

Posted

I'm sure you meant guictrlread() which I tried to do but didn't work it returned 68 on all the fonts. I don't know how I would do the second array to store the values. If by second array you mean something like: $array = ["font","font2",etc...]

Thanks for the quick reply though.

Posted

For things that I have a control, but then want data attached to that control, I create a 2d array... So

 

$x[0] [0] is the control handle

$x[0][1]  is data (like the font name) 

 

Then when the use clicks a control, I loop through my array matching to clicked control to index 0, and return the value of index 1

 

Posted

Thanks for the suggestion on using the 2D array, I need to learn that I guess.

Thanks for the help endlesslove, it works like a charm I guess I just made a little mistake and didn't catch that.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...