home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "VB Library Routines"
- ClientHeight = 5475
- ClientLeft = 1455
- ClientTop = 2250
- ClientWidth = 6015
- Height = 6165
- Left = 1395
- LinkTopic = "Form1"
- ScaleHeight = 5475
- ScaleWidth = 6015
- Top = 1620
- Width = 6135
- Begin CommandButton Command1
- Caption = "click to change to lower case"
- Height = 375
- Left = 2940
- TabIndex = 4
- Top = 4980
- Width = 3015
- End
- Begin ListBox List1
- Height = 1200
- Left = 2940
- TabIndex = 3
- Top = 3720
- Width = 3015
- End
- Begin TextBox Text2
- Height = 1575
- Left = 3480
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 2
- Text = "This is a sample text box that contains more than one line of text to be used in the Edit Menu and Highlight samples provided."
- Top = 2100
- Width = 2475
- End
- Begin TextBox Text1
- Height = 1575
- Left = 3480
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 1
- Text = "This is a sample text box that contains more than one line of text to be used in the Make Text Box Read-only sample provided."
- Top = 480
- Width = 2475
- End
- Begin Label Label1
- Caption = "Label1"
- Height = 255
- Left = 3480
- TabIndex = 0
- Top = 120
- Width = 2415
- End
- Begin Menu mnuFileMenu
- Caption = "&File"
- Begin Menu mnuFile
- Caption = "&About"
- Index = 0
- End
- Begin Menu mnuFile
- Caption = "E&xit"
- Index = 1
- End
- End
- Begin Menu mnuEditMenu
- Caption = "&Edit"
- Begin Menu mnuEdit
- Caption = "Undo"
- Index = 0
- End
- Begin Menu mnuEdit
- Caption = "Cu&t"
- Index = 1
- End
- Begin Menu mnuEdit
- Caption = "&Copy"
- Index = 2
- End
- Begin Menu mnuEdit
- Caption = "&Paste"
- Index = 3
- End
- End
- Begin Menu mnuSamplesMenu
- Caption = "Samples (&A-L)"
- Begin Menu mnuSamples
- Caption = "Always on top"
- Index = 0
- End
- Begin Menu mnuSamples
- Caption = "Another Instance (detecting)"
- Index = 1
- End
- Begin Menu mnuSamples
- Caption = "Center Form"
- Index = 2
- End
- Begin Menu mnuSamples
- Caption = "Create Path"
- Index = 3
- End
- Begin Menu mnuSamples
- Caption = "Create Program Manager Group"
- Index = 4
- End
- Begin Menu mnuSamples
- Caption = "Create Program Manager Item"
- Index = 5
- End
- Begin Menu mnuSamples
- Caption = "Floating Window"
- Index = 6
- End
- Begin Menu mnuSamples
- Caption = "FreeDrive"
- Index = 7
- End
- Begin Menu mnuSamples
- Caption = "Get Windows Version"
- Index = 8
- End
- Begin Menu mnuSamples
- Caption = "Get Windows\System Directory"
- Index = 9
- End
- Begin Menu mnuSamples
- Caption = "Get Windows Directory"
- Index = 10
- End
- Begin Menu mnuSamples
- Caption = "Help Click"
- Index = 11
- End
- Begin Menu mnuSamples
- Caption = "Hide MDI Child Form"
- Index = 12
- End
- Begin Menu mnuSamples
- Caption = "Highlight Textbox Text"
- Index = 13
- End
- Begin Menu mnuSamples
- Caption = "If File Exists"
- Index = 14
- End
- Begin Menu mnuSamples
- Caption = "Is Path Valid"
- Index = 15
- End
- Begin Menu mnuSamples
- Caption = "Locate Pointer"
- Index = 16
- End
- End
- Begin Menu mnuSamples2Menu
- Caption = "Samples (&M-Z)"
- Begin Menu mnuSamples2
- Caption = "Make Read-Only (textbox)"
- Index = 0
- End
- Begin Menu mnuSamples2
- Caption = "Menu (Edit) Shortcuts"
- Index = 1
- End
- Begin Menu mnuSamples2
- Caption = "Move Form without a titlebar"
- Index = 2
- End
- Begin Menu mnuSamples2
- Caption = "Paint Form (multi-colored) (no API)"
- Index = 3
- End
- Begin Menu mnuSamples2
- Caption = "Purge Numeric Input"
- Index = 4
- End
- Begin Menu mnuSamples2
- Caption = "Purge String (removing characters)"
- Index = 5
- End
- Begin Menu mnuSamples2
- Caption = "Read File Chunk"
- Index = 6
- End
- Begin Menu mnuSamples2
- Caption = "Reboot Computer"
- Index = 7
- End
- Begin Menu mnuSamples2
- Caption = "Resource Monitor"
- Index = 8
- End
- Begin Menu mnuSamples2
- Caption = "Restart Windows"
- Index = 9
- End
- Begin Menu mnuSamples2
- Caption = "Select Item in a listbox"
- Index = 10
- End
- Begin Menu mnuSamples2
- Caption = "UpEach make 1st letter of each word Cap"
- Index = 11
- End
- Begin Menu mnuSamples2
- Caption = "UpFirst -Capitalize 1st letter in string"
- Index = 12
- End
- End
- Begin Menu mnuHelpMenu
- Caption = "&Help"
- Begin Menu mnuHelp
- Caption = "Contents"
- Index = 0
- End
- Begin Menu mnuHelp
- Caption = "Search"
- Index = 1
- End
- Begin Menu mnuHelp
- Caption = "Help on Help"
- Index = 2
- End
- End
- Option Explicit
- Sub Command1_Click ()
- Command1.Caption = LCase(Command1.Caption)
- End Sub
- Sub Form_Load ()
- Dim x As Integer
- Show
- form2.Show
- For x = 1 To 26
- list1.AddItem String$(10, x + 64)
- Next x
- End Sub
- Sub Form_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
- ' Move Forms Without Title Bars
- ' This example was posted on the internet and shows a way that a form without a title bar can be moved around by the user with a mouse.
- If Button = 1 Then ' Checking for Left Button only
- Dim ReturnVal%
- ReleaseCapture
- ReturnVal% = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
- End If
- End Sub
- Sub mnuEdit_Click (Index As Integer)
- ' This routine is designed for a quick & dirty method for handling
- ' common edit menu functions.
- Select Case Index
- Case 0: SendKeys "%{BACKSPACE}" ' Undo
- Case 1: SendKeys "+{DELETE}" ' Cut
- Case 2: SendKeys "^{INSERT}" ' Copy
- Case 3: SendKeys "+{INSERT}" ' Paste
- End Select
- End Sub
- Sub mnuFile_Click (Index As Integer)
- Dim MsgBoxText As String
- Select Case Index
- Case 0
- MsgBoxText = "VB Library Routines" + Chr(13) + Chr(10)
- MsgBoxText = MsgBoxText + "Uploaded by JSHARGETT" + Chr(13) + Chr(10)
- MsgBoxText = MsgBoxText + "Placed into the public domain" + Chr(13) + Chr(10)
- MsgBoxText = MsgBoxText + "Enjoy!" + Chr(13) + Chr(10)
- MsgBox MsgBoxText
- Case 1
- Unload form2
- End
- End Select
- End Sub
- Sub mnuSamples_Click (Index As Integer)
- Dim x As Integer
- Dim T As String
- Select Case Index
- Case 0: 'Always on top
- x = MsgBox("Do you want to make this Program" & Chr$(13) & Chr$(10) & "Always on Top?", 36, "Always On Top Sample")
- If x = 6 Then
- AlwaysOnTop Me, True
- Else
- AlwaysOnTop Me, False
- End If
- Case 1: 'Another instance (detecting)
- If AnotherInstance() Then End
- Case 2: 'Center Form
- CenterForm Me
- Case 3: 'Create Path
- T = InputBox("Enter the path you would like to create (including Drive)")
- x = CreatePath(T)
- If x Then MsgBox "The path " + T + " was created successfully"
- Case 4: 'Create Program Manager Group
- CreateProgManGroup Me, "VB Library", GetWindowsDir()
- Case 5: 'Create Program Manager Item (icon)
- CreateProgManItem Me, app.Path + "\library", "VB Library"
- Case 6: 'Floating Window
- MsgBox "Minimize this window and watch the small one go with it!"
- FloatingWindow (form2.hWnd), (Me.hWnd)
- Case 7: 'FreeDrive
- MsgBox "Next available drive letter is " + FreeDrive()
- Case 8: 'Get Version
- T = GetWindowsVersion()
- MsgBox T, 48, "Current Windows Version"
- Case 9: 'Get Windows\System directory
- MsgBox GetSystemDir(), 48, "Windows\System Directory"
- Case 10: 'Get Windows directory
- MsgBox GetWindowsDir(), 48, "Windows Directory"
- Case 11: 'Help Click
- Help_Click "Filename.Hlp", Me
- Case 12: 'Hide MDI Child Form
- MDIParent.Show
- MsgBox "This routine will hide Child Window #2", 48, "VB Library"
- HideMDIChild MDIChild2
- Case 13: 'Highlight Textbox Text
- Text2.SetFocus
- HighlightText
- Case 14: 'If File Exists
- T = InputBox("Enter a filename to check the existance of (including Drive & path)")
- x = IfFileExists(T)
- If x Then
- MsgBox "The file exists", 48, "VB Library"
- Else
- MsgBox "The file does not exist or is hidden", 48, "VB Library"
- End If
- Case 15: 'Is Path Valid
- T = InputBox("Enter a pathname to check the validity of (including Drive)")
- x = IsPathValid(T, Left$(T, 2))
- If x Then
- MsgBox "The path is valid", 48, "VB Library"
- Else
- MsgBox "The path is NOT valid", 48, "VB Library"
- End If
- Case 16: 'Locate Pointer
- Dim Pnt As PointAPI
- GetCursorPos Pnt
- MsgBox "Cursor is located at " + Str$(Pnt.x) + "," + Str$(Pnt.Y), 48, "VB Library"
- End Select
- End Sub
- Sub mnuSamples2_Click (Index As Integer)
- Dim x As Integer
- Dim T As String
- Dim T2 As String
- Select Case Index
- Case 0: 'Make Read-Only Textbox
- MakeReadOnly (text1.hWnd)
- Case 1: 'Menu (edit) shortcuts
- MsgBox "See Edit Menu for demonstrations"
- Case 2: 'Move form without a titlebar
- MsgBox "Click on a blank area of this form and drag"
- Case 3: 'Paint Form without API
- PaintForm Me, 1, 100, 0, 255, 1, 0, -1
- Case 4: 'Purge Numeric Input
- T = InputBox("Enter numbers and text here")
- MsgBox PurgeNumericInput(T)
- Case 5: 'Purge String (removing characters)
- T = InputBox("Enter a string of text here")
- T2 = InputBox("Enter a substring of text to remove")
- MsgBox PurgeString(T2, T)
- Case 6: 'Read File Chunk
- MsgBox "This routine will read and display your C:\AUTOEXEC.BAT file", 48, "VB Library"
- Me.Cls
- T = ReadFileChunk("C:\autoexec.bat", 0)
- Do
- Me.Print T '(or whatever you want to do with the file)
- If Len(T) < 1000 Then Exit Do ' Reached EOF yet?
- T = ReadFileChunk("C:\autoexec.bat", 1) ' Continue reading
- Loop
- Case 7: 'Reboot Computer
- If MsgBox("This routine will Reboot your computer." & Chr$(13) & Chr$(10) & "Are you sure you want to do this now?", 36, "Reboot System?") = 6 Then
- x = RebootSystem()
- If Not x Then MsgBox "Some program(s) refused to terminate", 48, "VB Library"
- End If
- Case 8: 'Resource Monitor
- ResourceMonitor
- Case 9: 'Restart Windows
- If MsgBox("This routine will Restart Windows." & Chr$(13) & Chr$(10) & "Are you sure you want to do this now?", 36, "Restart Windows?") = 6 Then
- x = RestartWindows()
- If Not x Then MsgBox "Some program(s) refused to terminate", 48, "VB Library"
- End If
- Case 10: 'Select Item in a listbox
- T = InputBox("Enter a substring of one of the lines in the listbox")
- SelectListItem list1, T
- Case 11: 'UpEach (Capitalizing first letter of each word)
- Command1.Caption = Upeach((Command1.Caption))
- Case 12: 'UpFirst (Capitalizing first letter of string)
- Command1.Caption = UpFirst((Command1.Caption))
- End Select
- End Sub
-