Solved

Mouse down event for Combo box?

Posted on 1997-10-05
6
428 Views
Last Modified: 2008-02-20
When you mouse click on the text part of a Combo box the GotFocus event fires first. Is there any way to sense the mouse down or click first?
0
Comment
Question by:davidb
  • 3
  • 2
6 Comments
 

Expert Comment

by:rhastie
ID: 1436770
There is no easy way to do so, but you could call the event prcedure associated with the click or mousedown event from within the GotFocus event.

0
 

Author Comment

by:davidb
ID: 1436771
I want to scroll the page when someone tabs to the combo box but not when they click on the text box part of the combo box (not talking about the drop down part) Can't find a way to sence the differance between tabing to the combo box and clicking on the text box part of it.
0
 

Expert Comment

by:i007086
ID: 1436772
I have something unclear about your question:
Whether you want to deal  the following two things with diffrent actions:
1.the combo box's GetFocus event
2.when the user click the text part of a combo box
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:davidb
ID: 1436773
Trying to sence whether a user has clicked to get to the text part of a combo box or instead used the tab key to get to the combo box.
0
 

Accepted Solution

by:
i007086 earned 100 total points
ID: 1436774
I use vb version 5 . But my answer may be version_independent.
1.Open a standanrd .exe project;
2.Place a textbox on the form(its name is Text1);
3.Place a combobox on the form, set its style to 2;
  set its text property to blank;
4.place another textbox on the form(its name is Text2),
  let it be the same size as that of the combobox's
  textbox and overlap the combobox's textbox.
  set Text2's text property to blank;
5.Set the TabStop property of Text2 to false.
6.Declare a global boolean variable: ClickIt in the
  general section.
      Dim ClickIt as Boolean
7.Put the following code in the Form_load procedure:
      Combo1.AddItem "First"
      Combo1.AddItem "Second"
      ClickIt=False
      Text2.Text=Combo1.Text
8.Put the following code in the Text2_click procedure:
      ClickIt=True
      Msgbox "Click the text"
9.Put the following code in the combo1_GotFocus procedure:
      if ClickIt=True Then
           ClickIt=False
           Text2.Text=Combo1.text
           Exit sub
      end if
      msgbox "Tab to me"
10.Put the following code in the Combo1_click procedure
   and Combo1_change procedure:
      Text2.text=combo1.text

Now you can run to see the result.
If there is some inconsistency between the combobox's text and
text2's text, I think you  can resolve it.
0
 

Expert Comment

by:i007086
ID: 1436775
There is some modification of my proposed answer:
Replace the step 3 in the answer with the following:
3.Place a combobox on the form, set its style to 1(simple);
  set its text property to blank;

Replace the step 8 in the answer with the following:
8.Put the following code in the Text2_click procedure:
      ClickIt=True
      Text2.visible=False
      Combo1.SetFocus

Replace the step 9 in the answer with the following:
9.Put the following code in the combo1_GotFocus procedure:
      if ClickIt=True Then
           ClickIt=False
           Msgbox "click the text"
           Exit sub
      end if
      msgbox "Tab to me"

Add step 11 to the answer:
11.Put the following code in the Combo1_Lostfocus procedure:
      Text2.visible=True
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Microsoft Access combo box help 2 50
using web browser with BING 40 132
Added a column screws up code 5 63
VB6 - Cannot type when doing an extract from MSHFlexgrid to Excel 6 20
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question