VB icon

32-bit Floating Toolbar (NT & 95)

Email
Submitted on: 1/1/2015 7:06:00 PM
By: Mike Jones (from psc cd)  
Level: Not Given
User Rating: By 41 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 2100
 
     This code gives you the ability to create a 'floating toolbar' within your application. The old SetWindowWord function is only good for 16-bit applications, so it won't run under a 32-bit OS (like NT4). The API call you should use if you are programming a 32-bit application is SetWindowLong. It works the same way as SetWindowWord, only uses DWORD(Long) values instead of WORD values for the 32-bit OS.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :32-bit Floating Toolbar (NT & 95)
'**************************************
' Place this code into a module
Public Const GWL_HWNDPARENT = (-8)
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: 32-bit Floating Toolbar (NT & 95)
' Description:This code gives you the ability to create a 'floating toolbar' within your application. The old SetWindowWord function is only good for 16-bit applications, so it won't run under a 32-bit OS (like NT4). The API call you should use if you are programming a 32-bit application is SetWindowLong. It works the same way as SetWindowWord, only uses DWORD(Long) values instead of WORD values for the 32-bit OS.
' By: Mike Jones (from psc cd)
'
' Inputs:You will need to create 2 forms (Form1 & Form2).
On Form1, place a Command button (Command1)
On Form2, set the Window Style to 4-FixedToolWindow (not nessesary)
'
' Returns:Sets Form2 to be a child of Form1 (giving it a 'floating toolbar' effect)
'
' Assumes:This function will make a form a 'child window' of any form you specify.
'
' Side Effects:Won't work with 16-bit OS's. Use SetWindowWord for 16-bit.
'**************************************

' Place this code in the General Declarations section of Form1.
Private Sub Command1_Click()
'Open the toolbar window
Form2.Show
'Move the toolbar to the right
'of Form1.
'(gives it a docking effect)
Form2.Height = Form1.Height - 330
'Subtract the titlebar height -^
Form2.Left = Form1.Left + Form1.Width - Form2.Width
Form2.Top = Form1.Top + Form1.Height - Form2.Height
End Sub
Private Sub Form_Load()
'Set the button properties
Command1.Caption = "Show Toolbar"
Command1.Width = 2055
Command1.Height = 375
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'If Form2 is opened when you close
'Form1, it will not end your app, so
'you have to manually unload Form2.
Unload Form2
End Sub
' Place this code in the Form_Load event of Form2
Private Sub Form_Load()
SetWindowLong Me.hwnd, GWL_HWNDPARENT, Form1.hwnd
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.