PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Calendar Control  (Read 325 times)

SeaVipe

  • Senior Member
  • ***
  • Posts: 437
  • Windows 10
Calendar Control
« on: January 29, 2022, 07:42:39 PM »


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:
Code: [Select]

    ' 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
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9497
  • Windows 10
    • PlanetSquires Software
Re: Calendar Control
« Reply #1 on: January 29, 2022, 11:55:23 PM »

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.  :-)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 437
  • Windows 10
Re: Calendar Control
« Reply #2 on: January 30, 2022, 01:58:18 AM »

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

frmMainJ_lvJournal_RightClick Event:

Code: [Select]
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.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9497
  • Windows 10
    • PlanetSquires Software
Re: Calendar Control
« Reply #3 on: January 30, 2022, 08:20:39 PM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer