 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 21st, 2004, 09:47 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Mouse Overs with cmdButtons
I see that the properties for hyperlinks used in form for Access 2000 change the cursor from a pointer to a pointing hand, is there a way to cause enabled command buttons to do the same, or at least change in some way when they ar moused over to indicate they are live?
Mel Cape
|
|

July 21st, 2004, 09:52 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I exactly don't understand your question.
And where is the Cmd button located. VB or Javascript/html?
I'll did all I could, I am doing all I can and I will do all I can. Now, you better do all you can.
|
|

July 21st, 2004, 11:34 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry for the confusion - I'm referring to the Command Button objects that are placed on Access forms that provide for navigation or actions within the Access database. Currently, unless the Command Button object is a hyperlink, there is no indication to the user that the button is active. I'd like to be able to use VBA code or whatever is necessary to have either the button properties or the cursor change to indicate the button is live.
Mel Cape
|
|

July 21st, 2004, 02:13 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Mel,
The MousePointer property (accessed with Screen.MousePointer) accesses only four system cursor types: hourglass, I-beam, arrow, and sizing arrows. To get at the system Hand cursor, you need to use a Win32 API call. The code below toggleâs the default Pointer cursor and the Hand cursor on four events needed to make the command button mouse-over work.
In a standard module:
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Option Compare Database
'Win32 API calls and wrapper functions.
Dim hHand As Long
Dim HandCheck As Boolean
Declare Function SetSystemCursor Lib "user32" _
(ByVal hCursor As Long, ByVal id As Long) As Long
Declare Function LoadCursorA Lib "user32" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Function ChangeCursorHand()
Dim RetVal As Long
' Check to see if hand is currently set
If HandCheck = False Then
RetVal = SetSystemCursor(hHand, 32512)
HandCheck = True
End If
End Function
Function ChangeCursorDefault()
Dim RetVal As Long
' Check to see if hand is currently set
If HandCheck = True Then
RetVal = SetSystemCursor(hHand, 32512)
HandCheck = False
End If
End Function
Function GetDefaultCursor()
' Get handle to Hand cursor
hHand = LoadCursorA(0, 32649)
End Function
~~~~~~EndCode~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
In your Form module:
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Private Sub Command0_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ChangeCursorHand
End Sub
Private Sub Detail_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ChangeCursorDefault
End Sub
Private Sub Form_Activate()
GetDefaultCursor
End Sub
Private Sub Form_Deactivate()
ChangeCursorDefault
End Sub
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Hth,
Bob
|
|

July 21st, 2004, 06:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Just a quick note to say that whilst certainly possible to do this, it is not a standard way of indicating a live button.
For a standard VB style program, the way to indicate that a button is live, is to use the enabled property. When set to false the command button goes all greyed out and is fairly obviously unusable.
Web browsers use the same visual method to indicate a disabled control, although they do have another trick where they change the buttons shape (IE) or background (Opera) when the mouse hovers, to indicate which button will be activated if the mouse is clicked now. Bob's code could very easily be modified to give this behaviour:
Set the special effect of all the command buttons on the form to flat.
Define these constants at the beginning of your form module, as they don't seem to be intrinsic constants.
Code:
Const AC_FLAT=0
Const AC_RAISED=1
Put this code behind each button on the form.
Code:
Private Sub Command0_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Command0.SpecialEffedt=AC_RAISED
End Sub
Put this code behind the Detail section.
Code:
Private Sub Detail_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Command0.SpecialEffedt=AC_FLAT
Command1.SpecialEffedt=AC_FLAT
'etc.
End Sub
All I'm trying to say is, don't confuse your users by introducing non-standard behaviour. If I see a hand pointer my expectation is that I'm hovering over a hyperlink and if I click the mouse then a web browser will open up. Your users will expect the same.
Brian Skelton
Braxis Computer Services Ltd.
|
|

July 22nd, 2004, 06:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Brain and Mell,
Please correct me if I don't have this right, but I don't think Access (even 2K3) supports the falt appearance style for command buttons. A quick peek in the Object Browser shows the following controls supporting a SpecialEffect property:
- BoundObjectFrame
- CheckBox
- ComboBox
- CustomControl
- Image
- Label
- Line
- ListBox
- ObjectFrame
- OptionButton
- OptionGroup
- Rectangle
- Section
- SubForm
- TextBox
In Vb6, you can create a flat command button with a call to the Win32 DrawFramControl API:
' In a form modlue.
Private Declare Function DrawFrameControl _
Lib "user32" (ByVal hDC As Long, _
lpRect As RECT, ByVal uType As Long, _
ByVal uState As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
' Constants for the uType parameter
Private Const DFC_BUTTON = 4 ' Button
' Constants for the uState parameter
' These apply to uType 4 - Button
' These are the states to draw in
Private Const DFCS_FLAT = &H4000
Private Sub Form_Load()
Dim RC As RECT
AutoRedraw = True
With RC
.Left = 15
.Right = 30
.Top = 15
.Bottom = 30
End With
DrawFrameControl Form1.hDC, RC, DFC_BUTTON, DFCS_FLAT
End Sub
Access forms, however, con't support the hDC property, which returns a handle provided by Windows to the device context of the form.
Finally, with VB.NET we get a FlatStlye property for Button controls (with Standard, Flat, and Popup effects), but I havn't been able to get Access to behave this way.
On the issue of indicating "unavailable appearance" (disabled state) to the user, Brain is right on target. The Windows Interface Standard recommends achieving this via the Enabled property.
Bob
|
|

July 22nd, 2004, 08:02 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Bob
That'll teach me to post late at night!
You could probably do some Opera style colour changing on the mouse over event - although how this would interact with a user-defined colour scheme would be hard to predict.
What you would want to do is add a certain degree of 'darkness' to the current button background colour on the mouse over event. I can't think of any easy way to do this.
Brian Skelton
Braxis Computer Services Ltd.
|
|

July 22nd, 2004, 10:22 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Brian,
... just one of those wierd Microsoft oversight things, I guess. You'd think when Microsoft revamped Windows XP with the new flat-style look somebody would've thought to give developers the ability to create flat-style controls consistently across all the MS development platforms. Unfortunately only VS.NET got that functionality. Maybe next version of Office ...
Bob
|
|

July 22nd, 2004, 11:06 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanx to all for the great responses and recommendations.
The audience I'm building this application for is not Access literate in some cases and I was looking for a cosmetic method of indicating activeness outside of the typical enable on/off properties.
In the initial welcome menu of the app, the plethora of buttons and hyperlinks are enabled on/off based on the user's accessibility via password. But, again, I was looking for a more dynamic or eye appealing effect.
Thanx all, and I'll keep hacking.
Mel
Mel Cape
|
|

August 3rd, 2004, 02:49 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Bob Bedell
Hi Mel,
The MousePointer property (accessed with Screen.MousePointer) accesses only four system cursor types: hourglass, I-beam, arrow, and sizing arrows. To get at the system Hand cursor, you need to use a Win32 API call. The code below toggleâs the default Pointer cursor and the Hand cursor on four events needed to make the command button mouse-over work.
In a standard module:
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Option Compare Database
'Win32 API calls and wrapper functions.
Dim hHand As Long
Dim HandCheck As Boolean
Declare Function SetSystemCursor Lib "user32" _
(ByVal hCursor As Long, ByVal id As Long) As Long
Declare Function LoadCursorA Lib "user32" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Function ChangeCursorHand()
Dim RetVal As Long
' Check to see if hand is currently set
If HandCheck = False Then
RetVal = SetSystemCursor(hHand, 32512)
HandCheck = True
End If
End Function
Function ChangeCursorDefault()
Dim RetVal As Long
' Check to see if hand is currently set
If HandCheck = True Then
RetVal = SetSystemCursor(hHand, 32512)
HandCheck = False
End If
End Function
Function GetDefaultCursor()
' Get handle to Hand cursor
hHand = LoadCursorA(0, 32649)
End Function
~~~~~~EndCode~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
In your Form module:
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Private Sub Command0_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ChangeCursorHand
End Sub
Private Sub Detail_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ChangeCursorDefault
End Sub
Private Sub Form_Activate()
GetDefaultCursor
End Sub
Private Sub Form_Deactivate()
ChangeCursorDefault
End Sub
~~~~~~Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Hth,
Bob
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Mouse |
Ravikiran |
VB.NET |
1 |
June 8th, 2007 04:57 PM |
| Where's my mouse? |
Giant_robot_sandwich |
Javascript How-To |
2 |
January 9th, 2007 09:22 AM |
| Mouse Wheel |
dartcoach |
VB How-To |
0 |
November 12th, 2006 03:09 PM |
| On Mouse Over |
teresagoh |
Javascript |
1 |
February 13th, 2006 10:11 AM |
| what my mouse is on? |
nerssi |
Javascript |
3 |
August 9th, 2005 01:34 AM |
|
 |