1. Control Visibility
- Posted by euman at bellsouth.net Jun 12, 2002
- 443 views
Hello all, Even though Im unable to recieve any of the forum messages, Im sending this code snippet. I use this code in my Win32lib programs to emulate grouping of controls so I can set the visibility of controls when I need them. e.g when control2 needs to be shown, show it but hide control1 first. This could possibly be spedup an may even have some minor issues but for my programs this works fine. There are many uses for this code and can even shave some time off of your programming if used properly. I dont agree with the way Win32lib handles, control/window handles. there is alot of code just to set the visibility so, I wouldnt suggest using this on super-huge 300+ control programs. If you can get away with it, use group boxs or create popup windows to place controls on instead. -- Set control/s visibility --------------------------------------------- global sequence Controls Controls = {control1, control2, {control3, control32, control33}, control4, {control5,control52}} -- you get the picture... global procedure SetVisibility(atom nowVisible) integer len, handle, excode object junk excode = 0 len = length(Controls) for x = 1 to len do if sequence(Controls[x]) then for y = 1 to length(Controls[x]) do handle = getHandle(Controls[x][y]) if Controls[x][y] = nowVisible then if w32Func( xIsWindowVisible, {handle}) then exit else for z = 1 to length(Controls[x]) do setVisible(Controls[x][z], 1) end for exit end if else for z = 1 to length(Controls[x]) do setVisible(Controls[x][z], 0) excode = 0 end for exit end if if x = len then excode = 1 exit end if end for if excode = 1 then exit end if elsif integer(Controls[x]) then handle = getHandle(Controls[x]) if w32Func( xIsWindowVisible, {handle}) then if Controls[x] = nowVisible then exit else setVisible(Controls[x], 0) end if end if if x = len then setVisible(nowVisible, 1) end if end if end for handle = getHandle(nowVisible) if not w32Func( xIsWindowVisible, {handle}) then setVisible(nowVisible, 1) end if end procedure