[RESOLVED] Is there a way to dock a form to the right side of the users screen regardless of res
Hi there everyone. I am working on a prog that has lots of features for classroom management. The project has more features, but I would like to add a toolbar on the right side of the screen for whatever their resolution is that would have their most used features of the program ready to use. Some teachers use some parts of the management software more than others, and that part is taken care of, but I am not sure how to "dock" a toolbar to the side of the screen. I can get it in the middle, but would anyone know to how do it regardless of the user resolution. I was thinking in the middle of the right side somehow.
Re: Is there a way to dock a form to the right side of the users screen regardless of
That is a good idea. I can set it to no border, as we won't need it. What about locking it so it can't be moved. I'll add features to hide it, but yea lets keep it always on top.
What I really like is the sort of disappearing sidebar Windows 8 has where it only shows when you move over to the edge of the screen. Can I add that, or would I get sued? lol
Call SetWindowPos(DockBar.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
What I would like to try to do now is get a mouse hover over event going, so when my toolbar is hidden, a small piece of it is shown, so if the user puts their mouse over the form, it would call a sub. My question is, is there a mouse hover over event where if the mouse is just over the form anywhere (not clicking on anything), just hovering, can it call a sub?
Call SetWindowPos(DockBar.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
What I would like to try to do now is get a mouse hover over event going, so when my toolbar is hidden, a small piece of it is shown, so if the user puts their mouse over the form, it would call a sub. My question is, is there a mouse hover over event where if the mouse is just over the form anywhere (not clicking on anything), just hovering, can it call a sub?
Thanks.
Ok it turns out mousemove will help with this!
Example.
VB Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, _
Re: Is there a way to dock a form to the right side of the users screen regardless of
Make the Form invisible and when you mouse move over it make it visible and when the mouse moves off the Form make it invisible
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Is there a way to dock a form to the right side of the users screen regardless of
Ok Justin I made you a small example also using getcursorpos to be more precise in its activation (popping in and out). I have included a slow popping in and out function and also the setwindowpos.
Code:
Option Explicit
Const All_Flags = &H10 Or &H40 Or &H2 Or &H1
Private Type POINTAPI
X As Long
Y As Long
End Type
Enum TopMostEnum
TopMost = -1
NoTopMost = -2
End Enum
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub SetWindowPosition(Set_TopMost As TopMostEnum)
SetWindowPos Me.hWnd, Set_TopMost, 0, 0, 0, 0, All_Flags
End Sub
Private Sub chkTopMost_Click()
If chkTopMost.Value = vbChecked Then
SetWindowPosition TopMost
Else
SetWindowPosition NoTopMost
End If
End Sub
Private Sub Form_Load()
Me.Move Screen.Width - 15, (Screen.Height / 2) - (Me.Height / 2)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Timer1.Enabled = False Then Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim Mouse As POINTAPI
GetCursorPos Mouse
If ScaleX(Mouse.X, vbPixels, vbTwips) < Screen.Width And _
ScaleX(Mouse.X, vbPixels, vbTwips) > Screen.Width - Me.Width And _
ScaleY(Mouse.Y, vbPixels, vbTwips) < (Screen.Height / 2) + (Me.Height / 2) And _
ScaleY(Mouse.Y, vbPixels, vbTwips) > Me.Top Then
If chkPopUp.Value = vbChecked Then
If Not Me.Left = Screen.Width - Me.Width Then Me.Left = Me.Left - 15
Else
Me.Left = Screen.Width - Me.Width
End If
Else
If chkPopUp.Value = vbChecked Then
Me.Left = Me.Left + 15
Else
Me.Left = Screen.Width - 1
End If
End If
If Me.Left = Screen.Width - 15 Then Timer1.Enabled = False
End Sub
Re: Is there a way to dock a form to the right side of the users screen regardless of
Originally Posted by Max187Boucher
Ok Justin I made you a small example also using getcursorpos to be more precise in its activation (popping in and out). I have included a slow popping in and out function and also the setwindowpos.
Code:
Option Explicit
Const All_Flags = &H10 Or &H40 Or &H2 Or &H1
Private Type POINTAPI
X As Long
Y As Long
End Type
Enum TopMostEnum
TopMost = -1
NoTopMost = -2
End Enum
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub SetWindowPosition(Set_TopMost As TopMostEnum)
SetWindowPos Me.hWnd, Set_TopMost, 0, 0, 0, 0, All_Flags
End Sub
Private Sub chkTopMost_Click()
If chkTopMost.Value = vbChecked Then
SetWindowPosition TopMost
Else
SetWindowPosition NoTopMost
End If
End Sub
Private Sub Form_Load()
Me.Move Screen.Width - 15, (Screen.Height / 2) - (Me.Height / 2)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Timer1.Enabled = False Then Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim Mouse As POINTAPI
GetCursorPos Mouse
If ScaleX(Mouse.X, vbPixels, vbTwips) < Screen.Width And _
ScaleX(Mouse.X, vbPixels, vbTwips) > Screen.Width - Me.Width And _
ScaleY(Mouse.Y, vbPixels, vbTwips) < (Screen.Height / 2) + (Me.Height / 2) And _
ScaleY(Mouse.Y, vbPixels, vbTwips) > Me.Top Then
If chkPopUp.Value = vbChecked Then
If Not Me.Left = Screen.Width - Me.Width Then Me.Left = Me.Left - 15
Else
Me.Left = Screen.Width - Me.Width
End If
Else
If chkPopUp.Value = vbChecked Then
Me.Left = Me.Left + 15
Else
Me.Left = Screen.Width - 1
End If
End If
If Me.Left = Screen.Width - 15 Then Timer1.Enabled = False
End Sub
Re: [RESOLVED] Is there a way to dock a form to the right side of the users screen re
Here would be the modification.
Code:
Option Explicit
Const All_Flags = &H10 Or &H40 Or &H2 Or &H1
Private Type POINTAPI
X As Long
Y As Long
End Type
Enum TopMostEnum
TopMost = -1
NoTopMost = -2
End Enum
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private HiddenBorder As Integer
Private Sub SetWindowPosition(Set_TopMost As TopMostEnum)
SetWindowPos Me.hWnd, Set_TopMost, 0, 0, 0, 0, All_Flags
End Sub
Private Sub chkTopMost_Click()
If chkTopMost.Value = vbChecked Then
SetWindowPosition TopMost
Else
SetWindowPosition NoTopMost
End If
End Sub
Private Sub Form_Load()
HiddenBorder = 210
Me.Move Screen.Width - HiddenBorder, (Screen.Height / 2) - (Me.Height / 2)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Timer1.Enabled = False Then Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim Mouse As POINTAPI
GetCursorPos Mouse
If ScaleX(Mouse.X, vbPixels, vbTwips) < Screen.Width And _
ScaleX(Mouse.X, vbPixels, vbTwips) > Screen.Width - Me.Width And _
ScaleY(Mouse.Y, vbPixels, vbTwips) < (Screen.Height / 2) + (Me.Height / 2) And _
ScaleY(Mouse.Y, vbPixels, vbTwips) > Me.Top Then
If chkPopUp.Value = vbChecked Then
If Not Me.Left = Screen.Width - Me.Width Then Me.Left = Me.Left - 15
Else
Me.Left = Screen.Width - Me.Width
End If
Else
If chkPopUp.Value = vbChecked Then
Me.Left = Me.Left + 15
Else
Me.Left = Screen.Width - HiddenBorder
End If
End If
If Me.Left = Screen.Width - HiddenBorder Then Timer1.Enabled = False
End Sub
Re: [RESOLVED] Is there a way to dock a form to the right side of the users screen re
Oh this is great! One last question I had for you was I really like the slow retract, so I would always like to have that. Is there a way to have the timer do that without needing the checkbox?
Re: [RESOLVED] Is there a way to dock a form to the right side of the users screen re
Yes i originally programmed it without checkbox, it was a last minute addition, i will remove it tonight if you didnt figure it out
Or if i got time i'll modify from my phone.
Re: [RESOLVED] Is there a way to dock a form to the right side of the users screen re
Originally Posted by Max187Boucher
Yes i originally programmed it without checkbox, it was a last minute addition, i will remove it tonight if you didnt figure it out
Or if i got time i'll modify from my phone.
Oh that's ok Max. I played around and got it.
I was however, wondering if there was a way when the program first runs, to keep the toolbar from retracting when it first loads? Then after the user moves the mouse away from the toolbar, then it can retract like it does now?