Calendar Control

Started by SeaVipe, January 29, 2022, 08:12:39 PM

Previous topic - Next topic

SeaVipe


Hi Paul, something to ponder while watching football tomorrow!

I have an app with a MonthCalendar control on the main form and another on a child form. The child form also has 2 DateTimePicker controls and a ListBox control and 2 TextBoxes. I call the child form from a mouse click or a keyboard keypress on a main form ListView row. When the form opens, 1 of the 2 TextBoxes and neither of the DateTimePicker controls can get focus or be edited and the main form Calendar control gets hidden.
Mouse over the child form's ListBox control (or click the MonthCalendar control) and the main form Calendar control appears/shows and the TextBox and the 2 DateTimePicker controls all function normally.
I experimented with the TabIndex but that made no difference.
Here is my workaround:


    ' Do a check to ensure that this is actually a window handle (FF)
    Dim hw as HWND = frmJedit.mcMoveJournalEntry.hWindow
   
    If IsWindow(hw) Then 
       
        frmJedit.mcMoveJournalEntry.SelectedDate = Format( js( jdb.RecPtr).Dai, "yyyyMMdd")
        ' Set the focus to frmJedit.mcMoveJournalEntry ' the child form's  MonthCalendar control
        SetFocus hw
        ' Virtually hit the Enter key to enable the 2 datepicker controls and the...
        keybd_event VK_RETURN, 0, 0, 0
        keybd_event VK_RETURN, 0, KEYEVENTF_KEYUP, 0    ' Release the ENTER key
       
    End If
Clive Richey

Paul Squires

Hi Clive,

When you say the second form is a "child" form, is it indeed a true child of the main form, or is it an owned window popup form? How do you show that second form? What method do you use. If I can understand the type of forms that you are using then hopefully I can help with the focus and non responding controls. Kind of sounds like a message pump issue where the child form is not getting the messages.

.....and, yes, I will be watching the football games tomorrow.  :-)
Paul Squires
PlanetSquires Software

SeaVipe

Hi Paul,
frmMainJ is the projects main form and lvJournal is a main form ListView control.

frmMainJ_lvJournal_RightClick Event:


frmJedit.ShowDialog(frmMainj.hWindow)

Where frmMainJ is the project's main form and frmJedit is a sub form containing the unresponsive DateTimePicker and TextBox controls.
Clive Richey

Paul Squires

Hi Clive,

I am starting to try to put together some sort of rough sample program to try to emulate your problem. Please see attachment. Nothing strange happening with the code when I run it on my machine but obviously you probably have a whole lot more going on than my simple skeleton program.
Paul Squires
PlanetSquires Software