Older Version
Newer Version
bshipps64
Apr 19, 2006
- "Indented code & changed format"
From libertybasic.conforums.com by Brent Thorn: This little program demonstrates two concepts. **1.** The **CascadePosition** sub gives your program the ability to open multiple windows arranged in the classic cascaded arrangement. CascadePosition must be called before a window is opened. **2.** The **TrapCloseCommon$()** function and **CommonClose** sub provide a simple means of multiple window management by maintaining a count of the number of instances of open windows. To use these procedures, you must place the declaration for **g.WindowCount** near the top of your program and instead of doing a #handle "TrapClose etc" you must use #handle TrapCloseCommon$().[[code]][[code format="vbnet"]] '* Cascading windows and instance counting '* By Brent D. Thorn (http://www.b6sw.com/) '* PUBLIC DOMAIN Global g.WindowCount Call CascadePosition Open "1" For Window As #1 #1 TrapCloseCommon$() Call CascadePosition Open "2" For Window As #2 #2 TrapCloseCommon$() Call CascadePosition Open "3" For Window As #3 #3 TrapCloseCommon$() Wait Sub CommonClose handle$CloseClose #handle$g.WindowCountg.WindowCount = g.WindowCount - 1IfIf g.WindowCount = 0 ThenEnd EndEnd End If End Sub Function TrapCloseCommon$()TrapCloseCommon$TrapCloseCommon$ = "TrapClose CommonClose"g.WindowCount =g.WindowCount = g.WindowCount + 1 End Function Sub CascadePositionoffsetoffset = 0 CallDLL #user32, "GetSystemMetrics", _ _SM_CYCAPTION As ULong, _ cy As Long offset = offset + cyCallDLLCallDLL #user32, "GetSystemMetrics", __SM_CYCAPTION_SM_CYSIZEFRAME As ULong, _cy Ascy As Longoffset = offset + cyCallDLL #user32, "GetSystemMetrics", _ _SM_CYSIZEFRAME As ULong, _ cy As Long offsetoffset = offset + cyUpperLeftXUpperLeftX = UpperLeftX + offsetUpperLeftYUpperLeftY = UpperLeftY + offsetIf UpperLeftXIf (UpperLeftX + WindowWidth >DisplayWidthDisplayWidth) _Or UpperLeftYOr (UpperLeftY + WindowHeight >DisplayHeightDisplayHeight) ThenUpperLeftXUpperLeftX = 1UpperLeftYUpperLeftY = 1EndEnd If End Sub [[code]]