home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BorderStyle = 1 'Fixed Single
- ClientHeight = 2040
- ClientLeft = 2130
- ClientTop = 2865
- ClientWidth = 3405
- ControlBox = 0 'False
- Height = 2565
- KeyPreview = -1 'True
- Left = 2070
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2040
- ScaleWidth = 3405
- Top = 2400
- Width = 3525
- Begin Image Image1
- Height = 300
- Index = 2
- Left = 900
- Picture = NOMOVE.FRX:0000
- Tag = "0"
- Top = 540
- Visible = 0 'False
- Width = 300
- End
- Begin Image Image1
- Height = 300
- Index = 1
- Left = 450
- Picture = NOMOVE.FRX:05CA
- Tag = "0"
- Top = 540
- Visible = 0 'False
- Width = 300
- End
- Begin Label Label1
- Caption = "Label1"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 285
- Left = 630
- TabIndex = 0
- Top = 90
- Width = 720
- End
- Begin Image Image1
- Height = 300
- Index = 0
- Left = 0
- Picture = NOMOVE.FRX:0B94
- Tag = "0"
- Top = 0
- Width = 300
- End
- Dim SavedHeight As Integer ' required to re-adjust form height
- ' after caption is added or removed
- Dim SavedTop As Integer ' required to re-adjust form top
- Dim MouseX As Integer, MouseY As Integer
- 'evaluates mouse coordinates to determine if popup should pop up.
- Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
- 'this sub allows the user to access the system menu
- 'by keying Alt+Space, or to close the form by keying Alt+F4.
- Const ALT_MASK = 4
- Const KEY_F4 = 115
- Const KEY_SPACE = 32
- If Shift = ALT_MASK Then
- Select Case KeyCode
- Case KEY_F4: End
- Case KEY_SPACE
- Image1_Click 0
- End Select
- End If
- End Sub
- Sub Form_Load ()
- 'This project is in response to a question posed by another MSBASICS
- 'forum member: "How can I create a nonmovable window which still has
- 'a control box, title bar and minimize button?"
- 'This project demonstrates the creation of a form which cannot
- 'be moved by the user, even though it has a control menu and
- 'title bar. This is achieved by simulating the control menu and
- 'title bar with an image and a label. I didn't address the minimize
- 'button since that can be faked with a bitmap. I simply added the
- 'minimize option to the popup menu.
- 'There are two forms in this project; Form1 is visible with no menu,
- 'while the invisible Form2 contains a menu for popup use by Form1.
- 'Form_Load sets up the visible form, which contains
- 'Image1 to hold the control menu bitmap, and label1, which
- 'simulates the title bar. When the user clicks Image1, a
- 'popup menu is shown using a menu from the hidden Form2.
- 'After Form1 is minimized there is no control menu which appears when
- 'the icon is clicked, but a double-click still restores it.
- 'THIS IS A BIG KLUGE JOB and I don't guarantee that it's the best
- 'solution. I merely got bitten by the 'figure it out if you can' bug.
- 'I hope this is helpful and informative, at the least. If you have any
- 'questions, please feel free to email me!
- ' Barry Seymour
- ' Marquette Computer Consultants
- ' CIS 70413,3405
- Const ACTIVE_TITLE_BAR = &H80000002
- Const TITLE_BAR_TEXT = &H80000009
- 'setup Form1...
- Me.Caption = ""
- Me.KeyPreview = True
- 'position Image1
- Image1(0).Left = Screen.TwipsPerPixelX * -1
- Image1(0).Top = Screen.TwipsPerPixelY * -1
- 'position, setup Label1
- Label1.FontName = "System"
- Label1.FontSize = 9.25
- Label1.ForeColor = TITLE_BAR_TEXT
- Label1.BackColor = ACTIVE_TITLE_BAR
- Label1.Left = Image1(0).Left + Image1(0).Width
- Label1.Top = 0
- Label1.Height = Image1(0).Height - Screen.TwipsPerPixelY
- Label1.Width = ScaleWidth - Image1(0).Width + Screen.TwipsPerPixelX
- Label1.Alignment = 2 'centered
- Label1.Caption = "Unmovable Form Demo"
- SavedHeight = Me.Height ' form-level var
- SavedTop = Me.Top ' form-level var
- Load Form2 ' don't show it.
- End Sub
- Sub Form_Resize ()
- Static resizing As Integer
- If resizing Then Exit Sub Else resizing = True
- If Me.WindowState = 0 And Me.Caption <> "" Then
- 'form was just restored. Clear it's caption and ensure
- 'it's correctly sized and positioned. (Required because
- 'form height & Top change when caption is removed)
- Me.Caption = ""
- Me.Height = Me.Height + Label1.Height
- Me.Top = Me.Top - Label1.Height
- End If
- resizing = False
- End Sub
- Sub Image1_Click (Index As Integer)
- 'Yields the popup menu
- Image1(0).Picture = Image1(1).Picture
- PopupMenu Form2.mnuMain, 0, Image1(0).Left, Image1(0).Top + Image1(0).Height - Screen.TwipsPerPixelY
- Image1(0).Picture = Image1(2).Picture
- End Sub
- Sub Image1_DblClick (Index As Integer)
- 'closes the program
- End
- End Sub
-