Home All Groups Group Topic Archive Search About
Author
6 Jul 2005 6:58 PM
Alastair MacFarlane
Dear All,

I have a five column datagrid with fields, controls and data types as
follows:

ID - Primary Key (Hidden) - Long
Date - Date Time Picker (Col 1) - Date
Job No - Nothing added - Long
Exp Type - Combo Box - Text
Total - Nothing Added.

Ideally what I would like to happen is to limit the amount of user mouse
movement and hopefully allow the user to enter values straight from the
keyboard.

The user will enter the Date Column and on focus the Date Time will drop
down (this works thanks to Saga). The user will then select a date from the
control and move to the third column (Me.grdDataGrid.Col = 3) will receive
the focus. The user will then enter an appropriate value (long data type
into this column, press tab and this will go to the Exp Type Combo which
will drop down with the following code:

Call SendMessage(cmboMisc.hwnd, CB_SHOWDROPDOWN, True, 0&)

The user will then select an item from this list and when the combo retracts
I want it to move to the final column. The way I have tried to attempt this
was to detect when the user selects an item from the ComboBox by return or
mouse mouse selection and then detect when the ComboBox retracts with a
timer as below:

Private Sub tmrCmboDropStatus_Timer()
Dim status As Long
status = SendMessage(cmboMisc.hwnd, CB_GETDROPPEDSTATE, 0, 0&)
If status <> 1 Then
SendKeys "{TAB}"
tmrCmboDropStatus.Enabled = False
End If
End Sub

The problem is that I have tried using SendKeys "{TAB}" which misses the
next column and goes onto the first visible column or I have tried selecting
the fifth column with:

Me.grdDataGrid.Col = 5

Instead of using sendkeys. My question after this exceedingly long preamble
is, how can detect when the combo detracts and set the focus on the next
column (column 5)?

Thanks again for staying with me on this one and thanks for all the comments
following on from last night's similarish post.

Slainthe mhath from Scotland.

Alastair MacFarlane

Author
6 Jul 2005 7:24 PM
Jeff Johnson [MVP: VB]
"Alastair MacFarlane" <anonym***@microsoft.com> wrote in message
news:edG6DzlgFHA.3852@TK2MSFTNGP10.phx.gbl...

> Instead of using sendkeys. My question after this exceedingly long
> preamble is, how can detect when the combo detracts and set the focus on
> the next column (column 5)?

You can subclass your main window and look for the WM_COMMAND message. When
the lParam parameter contains the hWnd of the combo box, the high word of
the wParam parameter contains the CBN_CLOSEUP notification message if the
list is closing.
Author
6 Jul 2005 8:54 PM
Alastair MacFarlane
Jeff,

Thanks for the response. It is now late in the UK. I will try your
suggestion tomorrow. I presume that once the lParam and wParam parameters
are what I want to catch, I use sendkeys or setting the .col value of the
datagrid to 5 to setfocus on column 5 of the datagrid?

Thanks again.

Alastair MacFarlane

Show quoteHide quote
"Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message
news:uEsJTBmgFHA.3540@TK2MSFTNGP14.phx.gbl...
>
> "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message
> news:edG6DzlgFHA.3852@TK2MSFTNGP10.phx.gbl...
>
>> Instead of using sendkeys. My question after this exceedingly long
>> preamble is, how can detect when the combo detracts and set the focus on
>> the next column (column 5)?
>
> You can subclass your main window and look for the WM_COMMAND message.
> When the lParam parameter contains the hWnd of the combo box, the high
> word of the wParam parameter contains the CBN_CLOSEUP notification message
> if the list is closing.
>