|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Date Time Picker QuestionI have added a Date Time Picker date control to a project (in fact it is displayed when I select a specific column in a datagrid) and I would like it to expand when it receives the focus. The code below works for a ComboBox (substituting the hWnd value) but it does not work work with the Date Time Picker control. Does anyone have any ideas? Private Sub DTPicker1_GotFocus() Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) End Sub The event gets fired as expected but the code does not have the desired effect. Thanks again. Alastair MacFarlane p.s The code that positions the DTPicker is as follows: Dim gridCol As MSDataGridLib.Column Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width DTPicker1.ZOrder DTPicker1.Visible = True DTPicker1.SetFocus DTPicker1.Value = gridCol.Text
Show quote
Hide quote
> I have added a Date Time Picker date control to a project (in fact it You can always use the SendKeys kludge until someone who knows posts theis > displayed when I select a specific column in a datagrid) and I would like it > to expand when it receives the focus. The code below works for a ComboBox > (substituting the hWnd value) but it does not work work with the Date Time > Picker control. Does anyone have any ideas? > > Private Sub DTPicker1_GotFocus() > Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) > End Sub > > The event gets fired as expected but the code does not have the desired > effect. API solution for you... Private Sub DTPicker1_GotFocus() SendKeys "%{DOWN}" End Sub Rick Try this (or equivalent):
Private Sub DTPicker1_GotFocus() SendKeys "{F4}" End Sub Saga Show quoteHide quote "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message news:%23xXRWNZgFHA.3512@TK2MSFTNGP10.phx.gbl... > Dear All, > > I have added a Date Time Picker date control to a project (in fact it > is displayed when I select a specific column in a datagrid) and I > would like it to expand when it receives the focus. The code below > works for a ComboBox (substituting the hWnd value) but it does not > work work with the Date Time Picker control. Does anyone have any > ideas? > > Private Sub DTPicker1_GotFocus() > Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) > End Sub > > The event gets fired as expected but the code does not have the > desired effect. > > Thanks again. > > Alastair MacFarlane > > p.s The code that positions the DTPicker is as follows: > > Dim gridCol As MSDataGridLib.Column > Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) > DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + > grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width > DTPicker1.ZOrder > DTPicker1.Visible = True > DTPicker1.SetFocus > DTPicker1.Value = gridCol.Text > > > Another way...
'If placed in BAS module, remove "Private" Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Const WM_KEYDOWN As Long = &H100 Const VK_TAB As Long = &H9 Private Sub DTPicker1_GotFocus() dim RetVal as long RetVal = PostMessage(DTPicker1.hwnd, WM_KEYDOWN, vbKeyF4, 0) End Sub Show quoteHide quote "Saga" <antiSpam@somewhere.com> wrote in message news:OYI4BeZgFHA.3692@TK2MSFTNGP09.phx.gbl... > > Try this (or equivalent): > > > Private Sub DTPicker1_GotFocus() > > SendKeys "{F4}" > > End Sub > > > Saga > > > "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message > news:%23xXRWNZgFHA.3512@TK2MSFTNGP10.phx.gbl... >> Dear All, >> >> I have added a Date Time Picker date control to a project (in fact it >> is displayed when I select a specific column in a datagrid) and I >> would like it to expand when it receives the focus. The code below >> works for a ComboBox (substituting the hWnd value) but it does not >> work work with the Date Time Picker control. Does anyone have any >> ideas? >> >> Private Sub DTPicker1_GotFocus() >> Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) >> End Sub >> >> The event gets fired as expected but the code does not have the >> desired effect. >> >> Thanks again. >> >> Alastair MacFarlane >> >> p.s The code that positions the DTPicker is as follows: >> >> Dim gridCol As MSDataGridLib.Column >> Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) >> DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + >> grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width >> DTPicker1.ZOrder >> DTPicker1.Visible = True >> DTPicker1.SetFocus >> DTPicker1.Value = gridCol.Text >> >> >> > > Saga,
Thanks again. This worked! Excellent. Thank you but can you explain why posting a message would work whereas sending a message wouldn't? Alastair MacFarlane Show quoteHide quote "Saga" <antiSpam@somewhere.com> wrote in message news:ebqmBjZgFHA.1412@TK2MSFTNGP09.phx.gbl... > Another way... > > 'If placed in BAS module, remove "Private" > Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" > (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal > lParam As Long) As Long > > Const WM_KEYDOWN As Long = &H100 > Const VK_TAB As Long = &H9 > > > Private Sub DTPicker1_GotFocus() > > dim RetVal as long > > RetVal = PostMessage(DTPicker1.hwnd, WM_KEYDOWN, vbKeyF4, 0) > > End Sub > > > > "Saga" <antiSpam@somewhere.com> wrote in message > news:OYI4BeZgFHA.3692@TK2MSFTNGP09.phx.gbl... >> >> Try this (or equivalent): >> >> >> Private Sub DTPicker1_GotFocus() >> >> SendKeys "{F4}" >> >> End Sub >> >> >> Saga >> >> >> "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message >> news:%23xXRWNZgFHA.3512@TK2MSFTNGP10.phx.gbl... >>> Dear All, >>> >>> I have added a Date Time Picker date control to a project (in fact it is >>> displayed when I select a specific column in a datagrid) and I would >>> like it to expand when it receives the focus. The code below works for a >>> ComboBox (substituting the hWnd value) but it does not work work with >>> the Date Time Picker control. Does anyone have any ideas? >>> >>> Private Sub DTPicker1_GotFocus() >>> Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) >>> End Sub >>> >>> The event gets fired as expected but the code does not have the desired >>> effect. >>> >>> Thanks again. >>> >>> Alastair MacFarlane >>> >>> p.s The code that positions the DTPicker is as follows: >>> >>> Dim gridCol As MSDataGridLib.Column >>> Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) >>> DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + >>> grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width >>> DTPicker1.ZOrder >>> DTPicker1.Visible = True >>> DTPicker1.SetFocus >>> DTPicker1.Value = gridCol.Text >>> >>> >>> >> >> > > There is a subtle difference between the two <g>:
The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message. The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately. (From http://www.mentalis.org/apilist/apilist.php) Saga Show quoteHide quote "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message news:%23Azw2pZgFHA.3124@TK2MSFTNGP12.phx.gbl... > Saga, > > Thanks again. This worked! Excellent. Thank you but can you explain > why posting a message would work whereas sending a message wouldn't? > > Alastair MacFarlane > > "Saga" <antiSpam@somewhere.com> wrote in message > news:ebqmBjZgFHA.1412@TK2MSFTNGP09.phx.gbl... >> Another way... >> >> 'If placed in BAS module, remove "Private" >> Private Declare Function PostMessage Lib "user32" Alias >> "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam >> As Long, ByVal lParam As Long) As Long >> >> Const WM_KEYDOWN As Long = &H100 >> Const VK_TAB As Long = &H9 >> >> >> Private Sub DTPicker1_GotFocus() >> >> dim RetVal as long >> >> RetVal = PostMessage(DTPicker1.hwnd, WM_KEYDOWN, vbKeyF4, 0) >> >> End Sub >> >> >> >> "Saga" <antiSpam@somewhere.com> wrote in message >> news:OYI4BeZgFHA.3692@TK2MSFTNGP09.phx.gbl... >>> >>> Try this (or equivalent): >>> >>> >>> Private Sub DTPicker1_GotFocus() >>> >>> SendKeys "{F4}" >>> >>> End Sub >>> >>> >>> Saga >>> >>> >>> "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message >>> news:%23xXRWNZgFHA.3512@TK2MSFTNGP10.phx.gbl... >>>> Dear All, >>>> >>>> I have added a Date Time Picker date control to a project (in fact >>>> it is displayed when I select a specific column in a datagrid) and >>>> I would like it to expand when it receives the focus. The code >>>> below works for a ComboBox (substituting the hWnd value) but it >>>> does not work work with the Date Time Picker control. Does anyone >>>> have any ideas? >>>> >>>> Private Sub DTPicker1_GotFocus() >>>> Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) >>>> End Sub >>>> >>>> The event gets fired as expected but the code does not have the >>>> desired effect. >>>> >>>> Thanks again. >>>> >>>> Alastair MacFarlane >>>> >>>> p.s The code that positions the DTPicker is as follows: >>>> >>>> Dim gridCol As MSDataGridLib.Column >>>> Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) >>>> DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + >>>> grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width >>>> DTPicker1.ZOrder >>>> DTPicker1.Visible = True >>>> DTPicker1.SetFocus >>>> DTPicker1.Value = gridCol.Text >>>> >>>> >>>> >>> >>> >> >> > > "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message If you're referring to sending the CB_SHOWDROPDOWN message, then the answer news:%23Azw2pZgFHA.3124@TK2MSFTNGP12.phx.gbl... > Thanks again. This worked! Excellent. Thank you but can you explain why > posting a message would work whereas sending a message wouldn't? is because the DateTimePicker isn't a real combo box or it's a subclassed version that doesn't respond to that message. Dear All
Thanks for the replies. I had thought about the option of using SendKeys "%{DOWN}" first but it does not work that is why I thought of the SendMessage API. Any other suggestions? Thanks. Alastair MacFarlane Show quoteHide quote "Alastair MacFarlane" <anonym***@microsoft.com> wrote in message news:%23xXRWNZgFHA.3512@TK2MSFTNGP10.phx.gbl... > Dear All, > > I have added a Date Time Picker date control to a project (in fact it is > displayed when I select a specific column in a datagrid) and I would like > it to expand when it receives the focus. The code below works for a > ComboBox (substituting the hWnd value) but it does not work work with the > Date Time Picker control. Does anyone have any ideas? > > Private Sub DTPicker1_GotFocus() > Call SendMessage(DTPicker1.hWnd, CB_SHOWDROPDOWN, True, 0&) > End Sub > > The event gets fired as expected but the code does not have the desired > effect. > > Thanks again. > > Alastair MacFarlane > > p.s The code that positions the DTPicker is as follows: > > Dim gridCol As MSDataGridLib.Column > Set gridCol = grdDataGrid.Columns(grdDataGrid.Col) > DTPicker1.Move grdDataGrid.Left + gridCol.Left, grdDataGrid.Top + > grdDataGrid.RowTop(grdDataGrid.Row), gridCol.Width > DTPicker1.ZOrder > DTPicker1.Visible = True > DTPicker1.SetFocus > DTPicker1.Value = gridCol.Text > > > > Thanks for the replies. I had thought about the option of using Hmm! That is odd... it works on my system (WinXP Pro SP1, VB6 SP5)SendKeys > "%{DOWN}" first but it does not work that is why I thought of the > SendMessage API. Any other suggestions? Rick Strange indeed. I have XP Home Sevice Pack 2 and Visual Basic with an
unknown earlier service pack. Maybe this is the issue. Thanks for the advice. Alastair Show quoteHide quote "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:uaNigwZgFHA.1432@TK2MSFTNGP10.phx.gbl... >> Thanks for the replies. I had thought about the option of using > SendKeys >> "%{DOWN}" first but it does not work that is why I thought of the >> SendMessage API. Any other suggestions? > > Hmm! That is odd... it works on my system (WinXP Pro SP1, VB6 SP5) > > Rick > >
Functional IDE DLL call compiles to non-functional DLL call
Problem comparing double values Programatically design a form Testing for MAPI , again Verify a person's name? Default Property in VB6 Class VB 6 UCase failing Compile Error: Can't find project or library data structure equality Name of Control under to mouse pointer Help with WMI |
|||||||||||||||||||||||