gcue Posted May 18, 2008 Posted May 18, 2008 (edited) im trying to create buttons from an ini file but i dont know how to accomodate for the space changes (currently the icons are stacking of course bc i dont know how to tell it where to place each new button) also, how do i specify how many buttons per row and if theres more buttons that are created that fall out of range of the window size, how do i create the scrollbar? INI: [LOCATIONS] CRMC=CRMC_ASSETS GIG=GIG_ASSETS [CRMC_ASSETS] ANDS_ETP=D0090774 [GIG_ASSETS] ANDS_ESRV=D0090775oÝ÷ Ù«¢+ÙÕ¹ ÉÑ%½¹Ì ¤(ÀÌØí1= Lô%¹¥IMÑ¥½¸ ÀÌØí%¹¤°ÅÕ½Ðí1= Q%=9LÅÕ½Ðì¤(½ÈÀÌØí¤ôÄQ¼ÀÌØí1= MlÁulÁt(ÀÌØíA } ѹÌô%¹¥IMÑ¥½¸ ÀÌØí%¹¤°ÀÌØí1= MlÀÌØí¥ulÅt¤(½ÈÀÌØíàôÄQ¼ÀÌØíA } ѹÍlÁulÁt(ÀÌØíA } ѸôU% Ñɱ ÉÑ ÕÑѽ¸ ÀÌØíA } ѹÍlÀÌØíáulÁt°ÈÀ°ÐÀ°ÐÀ°ÐÀ°ÀÌØí M}% =8¤(U% ÑɱMÑ%µ ´Ä°ÅÕ½ÐíÍ¡±°Ìȹ±°ÅÕ½Ðì°Äؤ(U% Ñɱ ÉÑ1° ÀÌØíA } ѹÍlÀÌØíáulÁt°Ô°àÀ¤(U% ÑɱMÑ=¹Ù¹Ð ÀÌØíA } Ѹ°ÀÌØíA } ѹÍlÀÌØíáulÁt¤(9áÐ(9áÐ)¹Õ¹ Edited May 18, 2008 by gcue
evilertoaster Posted May 18, 2008 Posted May 18, 2008 well if $PC_Btns[$x][0] holds your X offset, can't you just test that to see if it's larger than the window range and if it is, increase your Y offset for the button creation?
martin Posted May 18, 2008 Posted May 18, 2008 (The AutoIt tags are messing up the code when you reply. I recommend that everyone uses code tags instead of AutoIt tags which cause too many problems.) Yopu have to decide how big the buttons and labels should be and how you want them spaced. Here is an approach as an example $ButHeight = 22 $ButWid = 100 $horPitch = $ButWid + 130 $VertPItch = $ButHeight + 70 $maxX = 300;depends on your window size or whatever $maxY = 300;ditto $startX = 20 $StartY = 40 $ButCount = 0;no buttons yet $ButHor = 0 $ButVert = 0 Func CreateIcons() $LOCS = IniReadSection($ini, "LOCATIONS") For $i = 1 To $LOCS[0][0] $PC_Btns = IniReadSection($ini, $LOCS[$i][1]) For $x = 1 To $PC_Btns[0][0] $ButCount += 1 $ButHor += 1 If $ButHor * $horPitch + $ButWid + $startX > $maxX Then $ButHor = 0 $ButVert += 1 If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more EndIf GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 16) GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + 4$ButHeight + 6) GUICtrlSetOnEvent($PC_Btn, $PC_Btns[$x][0]) Next Next EndFunc Look up scrollbars in the help. 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.
gcue Posted May 19, 2008 Author Posted May 19, 2008 this works to a point. i get an error when i add more PCs to the INI file. cant see why (The AutoIt tags are messing up the code when you reply. I recommend that everyone uses code tags instead of AutoIt tags which cause too many problems.) Yopu have to decide how big the buttons and labels should be and how you want them spaced. Here is an approach as an example $ButHeight = 22 $ButWid = 100 $horPitch = $ButWid + 130 $VertPItch = $ButHeight + 70 $maxX = 300;depends on your window size or whatever $maxY = 300;ditto $startX = 20 $StartY = 40 $ButCount = 0;no buttons yet $ButHor = 0 $ButVert = 0 Func CreateIcons() $LOCS = IniReadSection($ini, "LOCATIONS") For $i = 1 To $LOCS[0][0] $PC_Btns = IniReadSection($ini, $LOCS[$i][1]) For $x = 1 To $PC_Btns[0][0] $ButCount += 1 $ButHor += 1 If $ButHor * $horPitch + $ButWid + $startX > $maxX Then $ButHor = 0 $ButVert += 1 If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more EndIf GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 16) GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + 4$ButHeight + 6) GUICtrlSetOnEvent($PC_Btn, $PC_Btns[$x][0]) Next Next EndFunc Look up scrollbars in the help.
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