Private Const WM_LBUTTONDOWN As Int32 = &H201 Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click With KryptonDateTimePicker1 SendMessage(.Handle, WM_LBUTTONDOWN, 1, .Width - 10 + &H50000) End With End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As Long, _ ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long Public Function GetComboBoxEdithWnd(ByVal hwnd As Long) As Long GetComboBoxEdithWnd = FindWindowEx(hwnd, 0, "EDIT", vbNullString) End Function Private Sub Form_Load() MsgBox GetComboBoxEdithWnd(Combo1.hwnd) & " " & Combo1.hwnd End Sub
Mais le problème est que je dois cliquer quand même 2 fois pour pouvoir sélectionner une date. Or le but de cette opération était d'économiser un clic pour une meilleure cohérence de mon interface.
<System.Runtime.InteropServices.DllImportAttribute("user32.dll", SetLastError:=True)> Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer End Function Sub DropBox(ByVal hBoxHandle As IntPtr) 'oBox peut être => ' ComboBox ' DateTimePicker ' KryptonDateTimePicker Const WM_SYSKEYDOWN As Int32 = &H104 SendMessage(hBoxHandle, WM_SYSKEYDOWN, Keys.Down, 0) End Sub Private Sub TextBox1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Validated DropBox(DateTimePicker1.Handle) End Sub