home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmEX5A
- Caption = "Chapter 5 Examples A"
- ClientHeight = 4755
- ClientLeft = 1110
- ClientTop = 1620
- ClientWidth = 6630
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 317
- ScaleMode = 3 'Pixel
- ScaleWidth = 442
- Begin VB.CommandButton cmdSetParent
- Caption = "SetParent"
- Height = 375
- Left = 480
- TabIndex = 11
- Top = 3840
- Width = 2175
- End
- Begin VB.PictureBox picContainer
- Height = 1335
- Left = 3240
- ScaleHeight = 1305
- ScaleWidth = 3165
- TabIndex = 10
- Top = 660
- Width = 3195
- End
- Begin VB.CommandButton cmdRTMain
- Caption = "Find ThunderRT5Main"
- Height = 375
- Left = 480
- TabIndex = 9
- Top = 3420
- Width = 2175
- End
- Begin VB.Timer Timer1
- Enabled = 0 'False
- Interval = 3000
- Left = 180
- Top = 4140
- End
- Begin VB.CommandButton cmdBringToTop
- Caption = "Bring MDI Child1 to top"
- Height = 375
- Left = 480
- TabIndex = 8
- Top = 3000
- Width = 2175
- End
- Begin VB.CommandButton cmdTile
- Caption = "Tile Windows"
- Height = 375
- Left = 480
- TabIndex = 7
- Top = 1680
- Width = 2175
- End
- Begin VB.CommandButton cmdCascade
- Caption = "CascadeWindows"
- Height = 375
- Left = 480
- TabIndex = 6
- Top = 1200
- Width = 2175
- End
- Begin VB.CheckBox chkTopmost
- Caption = "TopMost"
- Height = 255
- Left = 480
- TabIndex = 5
- Top = 2640
- Width = 1515
- End
- Begin VB.CommandButton cmdMove2
- Caption = "Move defered"
- Height = 375
- Left = 1440
- TabIndex = 4
- Top = 2160
- Width = 1215
- End
- Begin VB.CommandButton cmdMove1
- Caption = "Move"
- Height = 375
- Left = 480
- TabIndex = 3
- Top = 2160
- Width = 855
- End
- Begin VB.TextBox txtWindows
- Height = 285
- Index = 0
- Left = 3240
- TabIndex = 2
- Text = "Test Windows"
- Top = 180
- Width = 1395
- End
- Begin VB.CommandButton cmdArrange
- Caption = "ArrangeIconicWindows"
- Height = 435
- Left = 480
- TabIndex = 1
- Top = 660
- Width = 2175
- End
- Begin VB.CommandButton cmdAdjust
- Caption = "AdjustWindowRect"
- Height = 435
- Left = 480
- TabIndex = 0
- Top = 180
- Width = 2175
- End
- Attribute VB_Name = "frmEX5A"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- ' Copyright
- 1997 by Desaware Inc. All Rights Reserved.
- ' For experimental purposes - does not work reliably
- Private Sub chkTopmost_Click()
- Dim dl&, position&
- If chkTopmost.Value = 1 Then position = HWND_TOPMOST Else position = HWND_NOTOPMOST
- dl& = SetWindowPos&(hwnd, position, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
- End Sub
- Private Sub cmdAdjust_Click()
- Dim dl&
- Dim lpRect As RECT
- Dim dwStyle&
- dwStyle& = GetWindowLong(hwnd, GWL_STYLE)
- ' This is our target location and size for the client area
- dl& = SetRect(lpRect, 50, 50, 150, 150)
- ' Find out how big the window needs to be
- dl& = AdjustWindowRect(lpRect, dwStyle, False)
- ' Look at the new sizes
- Debug.Print "Window size: " & lpRect.Right - lpRect.Left & " by " & lpRect.Bottom - lpRect.Top
- ' Do the move - note the width and height calculations
- dl& = MoveWindow(hwnd, lpRect.Left, lpRect.Top, lpRect.Right - lpRect.Left, lpRect.Bottom - lpRect.Top, True)
- DoEvents
- ' Verify the window size
- dl& = GetWindowRect(hwnd, lpRect)
- Debug.Print "GetWindowRect size: " & lpRect.Right - lpRect.Left & " by " & lpRect.Bottom - lpRect.Top
- ' Verify the client area size
- dl& = GetClientRect(hwnd, lpRect)
- ' Compare results of GetClientRect with Scalewidth and Scaleheight when ScaleMode for form is pixels
- Debug.Print "GetClientRect size: " & lpRect.Right - lpRect.Left & " by " & lpRect.Bottom - lpRect.Top
- Debug.Print "Actual client size: " & ScaleWidth & " by " & ScaleHeight
- End Sub
- Private Sub cmdArrange_Click()
- Dim dl&
- ' Arranges the icons on the desktop
- dl& = ArrangeIconicWindows(GetDesktopWindow())
- End Sub
- Private Sub cmdBringToTop_Click()
- Timer1.Enabled = True
- End Sub
- Private Sub cmdCascade_Click()
- ' Arranges the forms in the MDI form.
- ' Replace the "GetParent(Form1.hwnd)" term with GetDesktopWindow() to cascade
- ' all top level windows on the desktop
- Dim dl&
- dl& = CascadeWindowsByNum(GetParent(frmEX5A2.hwnd), 0, 0, 0, 0)
- End Sub
- Private Sub cmdMove1_Click()
- Dim x%, newtop&
- Dim dl&
- For x% = 0 To 10
- dl& = MoveWindow(txtWindows(x%).hwnd, 250, newtop&, 40, 20, True)
- newtop = newtop + 21
- Next x%
- End Sub
- Private Sub cmdMove2_Click()
- Dim posres&
- Dim x%, dl&
- Dim newtop&
- posres& = BeginDeferWindowPos(11)
- For x% = 0 To 10
- ' Note that posres might change
- posres& = DeferWindowPos(posres, txtWindows(x%).hwnd, HWND_TOP, 300, newtop&, 40, 20, SWP_SHOWWINDOW)
- newtop = newtop + 21
- Next x%
- dl& = EndDeferWindowPos(posres)
- End Sub
- Private Sub cmdRTMain_Click()
- Dim hw&, cnt&
- Dim rttitle As String * 256
- hw& = FindWindow("ThunderRT5Main", vbNullString)
- cnt = GetWindowText(hw&, rttitle, 255)
- MsgBox Left$(rttitle, cnt), 0, "RTMain title"
- End Sub
- Private Sub cmdSetParent_Click()
- Dim dl&
- dl& = SetParent(cmdSetParent.hwnd, picContainer.hwnd)
- ' Be sure to reposition the button
- cmdSetParent.Move 0, 0
- End Sub
- Private Sub cmdTile_Click()
- ' Arranges the forms in the MDI form.
- ' Replace the "GetParent(Form1.hwnd)" term with GetDesktopWindow() to tile
- ' all top level windows on the desktop
- Dim dl&
- dl& = TileWindowsBynum(GetParent(frmEX5A2.hwnd), 0, 0, 0, 0)
- End Sub
- Private Sub Form_Load()
- Dim x%
- For x% = 1 To 10
- Load txtWindows(x%)
- txtWindows(x%).Visible = True
- Next x%
- frmEX5AMDI.Visible = True
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Unload frmEX5AMDI
- End Sub
- Private Sub Timer1_Timer()
- Dim dl&
- dl& = BringWindowToTop(frmEX5A2.hwnd)
- Timer1.Enabled = False
- End Sub
-