ParMesSoins Posted November 23, 2007 Share Posted November 23, 2007 (edited) Bonjour,i have a little code who list different windows (GUI) with different IDi've got a GUICtrlCreateContextMenu on each windows with an Edit fuctionbut i can't find the ID of $id_postit = GUICtrlCreateLabel ($id, 0, 0 )it's always the last a sample of my code... While 1 $id = $Line_data_Array[1] ... ;affichage du E-Post-It GUICreate("E-Post-It", $largeur_fenetre, $hauteur_fenetre, $taille_W_ecran-$largeur_fenetre-5, $top, $WS_POPUP + $WS_BORDER,$WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $id_postit = GUICtrlCreateLabel ($id, 0, 0 ) ;menu sur clic droit $contextmenu = GUICtrlCreateContextMenu ($text_postit) $edititem = GUICtrlCreateMenuitem ("Editer", $contextmenu) GUICtrlSetOnEvent($edititem, "Edition") GUISetState (@SW_SHOW); will display an empty dialog box Wend Func Edition() $edit_largeur = 320 GUICreate(" Edition", $edit_largeur,120, @DesktopWidth/2-160, @DesktopHeight/2-45, "", $WS_EX_TOPMOST) $text = GUICtrlCreateInput ("", 10, 35, 300, 20) GUICtrlRead($titre_postit) GUICtrlSetData ( $text, GUICtrlRead($titre_postit)) $OK = GUICtrlCreateButton ("Valider", 40, 75, 60, 20) $QUITTER = GUICtrlCreateButton ("Abandoner", $edit_largeur - (40+75), 75, 60, 20) GUICtrlSetOnEvent($QUITTER, "Quit") GUISetState (@SW_SHOW) EndFunc Func Quit() Exit EndFuncThe $text label always return the last ID ???i can't make GUICtrlSetOnEvent($edititem, "Edition($id)") !?!Could you help me ? Please !Sorry for my French-School english Merci. Edited November 23, 2007 by ParMesSoins Link to comment Share on other sites More sharing options...
martin Posted November 23, 2007 Share Posted November 23, 2007 (edited) Bonjour, i have a little code who list different windows (GUI) with different ID i've got a GUICtrlCreateContextMenu on each windows with an Edit fuction but i can't find the ID of $id_postit = GUICtrlCreateLabel ($id, 0, 0 ) it's always the last a sample of my code ... While 1 $id = $Line_data_Array[1] ... ;affichage du E-Post-It GUICreate("E-Post-It", $largeur_fenetre, $hauteur_fenetre, $taille_W_ecran-$largeur_fenetre-5, $top, $WS_POPUP + $WS_BORDER,$WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $id_postit = GUICtrlCreateLabel ($id, 0, 0 ) ;menu sur clic droit $contextmenu = GUICtrlCreateContextMenu ($text_postit) $edititem = GUICtrlCreateMenuitem ("Editer", $contextmenu) GUICtrlSetOnEvent($edititem, "Edition") GUISetState (@SW_SHOW); will display an empty dialog box Wend Func Edition() $edit_largeur = 320 GUICreate(" Edition", $edit_largeur,120, @DesktopWidth/2-160, @DesktopHeight/2-45, "", $WS_EX_TOPMOST) $text = GUICtrlCreateInput ("", 10, 35, 300, 20) GUICtrlRead($titre_postit) GUICtrlSetData ( $text, GUICtrlRead($titre_postit)) $OK = GUICtrlCreateButton ("Valider", 40, 75, 60, 20) $QUITTER = GUICtrlCreateButton ("Abandoner", $edit_largeur - (40+75), 75, 60, 20) GUICtrlSetOnEvent($QUITTER, "Quit") GUISetState (@SW_SHOW) EndFunc Func Quit() Exit EndFunc The $text label always return the last ID ??? i can't make GUICtrlSetOnEvent($edititem, "Edition($id)") !?! Could you help me ? Please ! Sorry for my French-School english Merci. When you create something like this $id_postit = GUICtrlCreateLabel ($id, 0, 0 ) then $id_postit will have some value. Lets say for example that the value is 8207. The next time a gui is created and a new label is created the new label will have a different id say 8310, so $id_postit is now 8310. The first label still exists of course but you were using $id_postit for it's id but that has now been lost. The solution is to have a unique variable for each and every control. To do this you need to use arrays. Assuming you will have no more than 50 guis do something like this DIm GuiSet[50],$buttonA[50], $labels[50,....etc Global $numero; $numero = 0 while 1 guicreate(...... . . . $labels[$numero] = guictrlcreate(.......... . . . $numero += 1 wend Now you can refer to the first label because it is $labels[0], and the last one so far is $label[$numero] Welcome to the forums. Vous n'êtes pas seul ici Edited November 23, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now