newb_powa' Posted April 11, 2007 Share Posted April 11, 2007 Hey guys, I'm trying do delete a control using a function. Theses controls are made during a loop and the number of control is a variable. I've looked in the helpfile and I don't see anyway to get all of the control ID, if there is, please tell me. If not, this is my code, lets see together what we can do that might do the job. This is where I do have problem in the code. If you want to try it, there is the complete code and everything that is needed to run it properly in the .zip file. expandcollapse popupFunc _WinPutList() If IsArray($Number) Then ;If the code run more than one time, it will remember the number of control to delete For $x = 0 To $Number $Name = "" ;This is the problem, how to get the name of every control ?? GUICtrlDelete($Name) Next EndIf $Number = IniRead("Win.ini", "Number", "Active", 0) ;This will get the good number of control to create $Rx = 272 ; coord X $Ry = 34 ; coord Y For $x = 1 to $Number $WinName = IniReadSection("Win.ini", "Name") $more20 = StringSplit($WinName[$x][1], "") If $more20[0] > 20 Then $y = " ..." Else $y = "" EndIf $PutName = StringLeft($WinName[$x][1], 20) $PutNamez = String($PutName & $y) $NameBK = GUICtrlCreatePic("Bouton.bmp", $Rx, $Ry, 70, 25, $BS_BITMAP) ;Create the backgroud for the ctrl $Name = GUICtrlCreateLabel($PutNamez, $Rx+1, $Ry+1, 68, 23, $SS_CENTER ) ;Create label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1 ,7, 400) $Rx = $Rx + 72 Next EndFunc ; === WinPutList === ; === WinList === Func _ListWin() ;It is getting every needed info to create the control as I wish $var = WinList() $active = 0 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then $active = $active + 1 EndIf Next If IniRead("Win.ini", "Number", "Active", 0) = $active Then ;;; Else If FileExists("Win.ini") Then FileDelete("Win.ini") EndIf $activewin = 0 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then IniWrite("Win.ini", "Name", "Name #"&$i , $var[$i][0]) IniWrite("Win.ini", "Handle", "Handle #"&$i , $var[$i][1]) $activewin = $activewin + 1 EndIf Next IniWrite("Win.ini", "Number", "Active" , $activewin) FileSetAttrib("Win.ini", "+H") _WinPutList() EndIf EndFunc ; === WinList === Func IsVisible($wdfds) If BitAnd(WinGetState($wdfds),2) Then Return 1 Else Return 0 EndIf EndFunc Oh, and if it help you to understand, this project is to make my own taskbar Thanks for help !!TaskBar.zip Link to comment Share on other sites More sharing options...
martin Posted April 12, 2007 Share Posted April 12, 2007 (edited) Hey guys, I'm trying do delete a control using a function. Theses controls are made during a loop and the number of control is a variable. I've looked in the helpfile and I don't see anyway to get all of the control ID, if there is, please tell me. If not, this is my code, lets see together what we can do that might do the job. This is where I do have problem in the code. If you want to try it, there is the complete code and everything that is needed to run it properly in the .zip file. expandcollapse popupFunc _WinPutList() If IsArray($Number) Then ;If the code run more than one time, it will remember the number of control to delete For $x = 0 To $Number $Name = "" ;This is the problem, how to get the name of every control ?? GUICtrlDelete($Name) Next EndIf $Number = IniRead("Win.ini", "Number", "Active", 0) ;This will get the good number of control to create $Rx = 272 ; coord X $Ry = 34 ; coord Y For $x = 1 to $Number $WinName = IniReadSection("Win.ini", "Name") $more20 = StringSplit($WinName[$x][1], "") If $more20[0] > 20 Then $y = " ..." Else $y = "" EndIf $PutName = StringLeft($WinName[$x][1], 20) $PutNamez = String($PutName & $y) $NameBK = GUICtrlCreatePic("Bouton.bmp", $Rx, $Ry, 70, 25, $BS_BITMAP) ;Create the backgroud for the ctrl $Name = GUICtrlCreateLabel($PutNamez, $Rx+1, $Ry+1, 68, 23, $SS_CENTER ) ;Create label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1 ,7, 400) $Rx = $Rx + 72 Next EndFunc ; === WinPutList === ; === WinList === Func _ListWin() ;It is getting every needed info to create the control as I wish $var = WinList() $active = 0 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then $active = $active + 1 EndIf Next If IniRead("Win.ini", "Number", "Active", 0) = $active Then ;;; Else If FileExists("Win.ini") Then FileDelete("Win.ini") EndIf $activewin = 0 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then IniWrite("Win.ini", "Name", "Name #"&$i , $var[$i][0]) IniWrite("Win.ini", "Handle", "Handle #"&$i , $var[$i][1]) $activewin = $activewin + 1 EndIf Next IniWrite("Win.ini", "Number", "Active" , $activewin) FileSetAttrib("Win.ini", "+H") _WinPutList() EndIf EndFunc ; === WinList === Func IsVisible($wdfds) If BitAnd(WinGetState($wdfds),2) Then Return 1 Else Return 0 EndIf EndFunc Oh, and if it help you to understand, this project is to make my own taskbar Thanks for help !! I think all you need to do is this, but I might not have spent enough time looking at your code so tell me if I have got it wrong. Dim $Name[10], $NameBK[10];no of elements doesn't really matter Func _WinPutList() If IsArray($Number) Then For $x = 0 To $Number - 1 GUICtrlDelete($Name[$x]) GuiCtrlDelete($NameBK[$x])<---was this omitted on purpose? Next EndIf $Number = IniRead("Win.ini", "Number", "Active", 0) Redim $Name[$Number] Redim $NameBK[$Number] $Rx = 272;+120 if icones $Ry = 34 For $x = 0 to $Number - 1;<--- change here $WinName = IniReadSection("Win.ini", "Name") $more20 = StringSplit($WinName[$x][1], "") If $more20[0] > 20 Then $y = " ..." Else $y = "" EndIf $PutName = StringLeft($WinName[$x][1], 20) $PutNamez = String($PutName & $y) $NameBK[$x] = GUICtrlCreatePic("Bouton.bmp", $Rx, $Ry, 70, 25, $BS_BITMAP) $Name[$x] = GUICtrlCreateLabel($PutNamez, $Rx+1, $Ry+1, 68, 23, $SS_CENTER ) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1 ,7, 400) $Rx = $Rx + 72 Next EndFunc Edited April 12, 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...
smashly Posted April 13, 2007 Share Posted April 13, 2007 (edited) Updated: 17-4-07 (9th edit) I've been playing around with your script newb_powa' and having fun.. Added forgotten ctrl delete ...doh..lmao Added your labels with colour example on click label button Fixed the tooltips context menu loosing it setting when switching between mini, main, complete mode. Attached to post Good luck & Cheers Edit: changed what I originally posted to suit changed script... Edited April 17, 2007 by smashly Link to comment Share on other sites More sharing options...
newb_powa' Posted April 15, 2007 Author Share Posted April 15, 2007 Hum, I test it, it's a really good work you've done perhaps, there is a lot more of variable work than waht I thought it would take (hum i'm not surse how to say that, ry for bah english lol) this was i think the hardest part, now i could focus on other part of the project, and I will update it there as much as possible P.S. I like the way you put the icon but simetime they are not the right one Link to comment Share on other sites More sharing options...
smashly Posted April 16, 2007 Share Posted April 16, 2007 Yep there's many variables needed for your script and your english is fine. What's your native language? Icons are taken from the Process ID path exe that the open window belongs to. I have no idea yet how to get the actual icon the window is using so I tell it to use the first icon. So for example if you open Windows Explorer then you get the same icon as My Computer because both the windows process is explorer.exe . I gather I could query the window and get the icon info it uses and then use that as a variable to use in the toolbar. But I was only trying to show an example being able to identify the ID of a control generated from a from a loop. Got some more things updated in your script, I've added some examples of context menus and tool tips. Will update my post above with the changes a bit later as I'm still working out some quirks. Cheers Link to comment Share on other sites More sharing options...
smashly Posted April 16, 2007 Share Posted April 16, 2007 Updated my post Above with new code. I've made it so your toolbar doesn't show it itself. (It's was tricky because it broke the tooltips I added. I managed a work around to get it working) Added Tooltips that display when you point at the labels on the toolbar. Tooltip displays the Window Title and Process Path. Added context menu's to labels that show and to to the main toolbar itself. Context Menu on label offers: Restore Window, Minimize Window, Maximize Window, Close Window Context Menu on Toolbar offers: Restore All Windows, Minimize All Windows, Maximize All Windows, Close All Windows, Disabel/Enable Tooltips, Exit Toolbar Added some comments to try and help you see what I did. (but it probly makes it more confusing though instead ) More to come soon... Link to comment Share on other sites More sharing options...
smashly Posted April 16, 2007 Share Posted April 16, 2007 Edited Code post above again, Fixed the context menu not working properly on mini mode... Control hover I was try it out.. but removed it for the moment.. I Forgot to remove the include was all.. just grab the edited post above again.. Cheers Link to comment Share on other sites More sharing options...
newb_powa' Posted April 16, 2007 Author Share Posted April 16, 2007 (edited) So, for what I understand, with that in the loop For $l = 1 To $hm[0] ; <-- Start: Added this just so we can see the controls do something. Select Case $msg = $Labels[$l][0] ; Label Control id If 16 > WinGetState($Labels[$l][1]) >= 32 Then WinSetState($Labels[$l][1], "", @SW_MINIMIZE) ToolTipCheck() ElseIf Not BitAnd(WinGetState($Labels[$l][1]), 8) Then WinActivate($Labels[$l][1]) ToolTipCheck() EndIf Case $msg = $Labels[$l][3] ; Icon Control id If 16 > WinGetState($Labels[$l][1]) >= 32 Then WinSetState($Labels[$l][1], "", @SW_MINIMIZE) ToolTipCheck() ElseIf Not BitAnd(WinGetState($Labels[$l][1]), 8) Then WinActivate($Labels[$l][1]) ToolTipCheck() EndIf [...] EndSelect Next When the control is clicked, it will active the window, but what if I want to reduce it by clicking again ?? It not work ^^ Edit : I only changed the first line with the second because it seem that when you drag a file, you move a window ^^ If $var[$i][0] <> "" AND IsVisible($var[$i][1]) And $var[$i][0] <> 'Program Manager' And $var[$i][0] <> $NTB1 And $var[$i][0] <> $NTB2 Then If $var[$i][0] <> "" AND IsVisible($var[$i][1]) And $var[$i][0] <> 'Program Manager' And $var[$i][0] <> $NTB1 And $var[$i][0] <> $NTB2 And $var[$i][0] <> 'Drag' Then There is the Script I have ^^ Edited April 17, 2007 by newb_powa' Link to comment Share on other sites More sharing options...
smashly Posted April 17, 2007 Share Posted April 17, 2007 Updated my post above with your changes and added a small sample of using your labels with colours when a label is clicked. The thread is getting long with code quotes.. Do me some favours please.. When you add a full script in your thread , just edit your first post, I'll do the same and edit my first post if I add a full script change, when I do a change I then add a new post to get your attention. Can you edit/remove the old quote post of code please, scrolling to the bottom of the thread takes forever...lol It'll make it much easier to navigate the thread. Cheers Link to comment Share on other sites More sharing options...
newb_powa' Posted April 17, 2007 Author Share Posted April 17, 2007 (edited) Updated my post above with your changes and added a small sample of using your labels with colours when a label is clicked. The thread is getting long with code quotes.. Do me some favours please.. When you add a full script in your thread , just edit your first post, I'll do the same and edit my first post if I add a full script change, when I do a change I then add a new post to get your attention. Can you edit/remove the old quote post of code please, scrolling to the bottom of the thread takes forever...lol It'll make it much easier to navigate the thread. Cheers I understand what u mean by easier navigate I deleted my unecessary post It is still big Edit : U forgot to add these line in the ListWin Func (line 360) GUICtrlDelete($Labels[$d][20]) GUICtrlDelete($Labels[$d][21]) GUICtrlDelete($Labels[$d][22]) GUICtrlDelete($Labels[$d][23]) Edited April 17, 2007 by newb_powa' 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