[SOLVED] Vanishing CalendarGadget... Why?

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

[SOLVED] Vanishing CalendarGadget... Why?

Post by Randy Walker »

This is driving me crazy. I create the invisible window at my main program launch and later use hideWindow to show the window when needed, but the calendar is always missing. This is the extracted code that works fine by itself. Why does the calendar vanish when I unhide the window in my main app? Any ideas?

Code: Select all

#Window_19 = 1
#RemindEdit = 2
#RemindCalendar = 3

LoadFont(1, "Segoe UI", 13)
HWND19 = OpenWindow(#Window_19,440,113,355,380,"Edit event & DblClick Date",#PB_Window_SystemMenu | #PB_Window_Invisible)
If HWND19
  EditorGadget(#RemindEdit, 9, 10, 195, 20)
  GdHdl.i = CalendarGadget(#RemindCalendar,9,35,336,330,Date())
  SetWindowTheme_(GadgetID(#RemindCalendar), @"", @"")
  SetGadgetFont(#RemindCalendar, FontID(1))
EndIf
HideWindow(#Window_19,0)
Repeat
  ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow
I'm running PB v5.40 64bit on Windows 11
Last edited by Randy Walker on Sat Oct 04, 2025 7:42 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4973
Joined: Sun Apr 12, 2009 6:27 am

Re: Vanishing CalendarGadget... Why?

Post by RASHAD »

Hi Randy :)
How can we help you without the problematic code
At least make your window visible and see if the calendar shown at start or not
Egypt my love
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

RASHAD wrote: Fri Oct 03, 2025 2:32 am Hi Randy :)
How can we help you without the problematic code
At least make your window visible and see if the calendar shown at start or not
Hi RASHAD... I tried putting this code in immediately after creating the window and the calendar did appear but I can't have the window show before actually needed by the user, so I had to remove it:

Code: Select all

HideWindow(#Window_19,0)
Repeat
  ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow
I understand the need to see the full code but as explained in previous issues, the code is highly proprietary and would reveal too much sensitive customer data. My attempts to trim it down in the past have failed, so at this point all I can do is ask for ideas.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
Michael Vogel
Addict
Addict
Posts: 2818
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Vanishing CalendarGadget... Why?

Post by Michael Vogel »

First idea, post a code - if you don't want to show private information: remove it, it may help you to create a working code (or at least a readable one).
Otherwise everyone must speculate what you really want, maybe something like that...

Code: Select all

OpenWindow(0, 100, 100, 250, 200, "Calendar Gadget", #PB_Window_SystemMenu | #PB_Window_Invisible)
CalendarGadget(0, 10, 10, 230, 180)

OpenWindow(1, 350, 100, 250, 200, "Randy", #PB_Window_SystemMenu)
ButtonGadget(1, 10, 10, 230, 180,"Toggle Calendar Window",#PB_Button_Default)
AddKeyboardShortcut(1,#PB_Shortcut_Return,1)

Repeat
	Select WaitWindowEvent()
	Case #PB_Event_Gadget,#PB_Event_Menu
		Select EventGadget()
		Case 1
			HideWindow(0,walker)
			SetActiveWindow(1)
			walker!1
		EndSelect
	Case #PB_Event_CloseWindow
		Break
	EndSelect
ForEver
infratec
Always Here
Always Here
Posts: 7658
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Vanishing CalendarGadget... Why?

Post by infratec »

Gadget number :?: (double)

Try #PB_Any if it is a fixed number.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4973
Joined: Sun Apr 12, 2009 6:27 am

Re: Vanishing CalendarGadget... Why?

Post by RASHAD »

Hi Randy
1- Run your Window visible
2- Disable the first created gadget
Run the code again and see if the calendar visible or not
If it is not visible
Enable the disabled and disable the next gadget
Repeat until you find which gadget is causing the problem and why
Double no as infratec mentioned or covered by wrong dimensions

Wish you good luck
Egypt my love
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

Michael Vogel wrote: Fri Oct 03, 2025 7:01 pm First idea, post a code - if you don't want to show private information: remove it, it may help you to create a working code (or at least a readable one).
Thanks Michael... Removing private information would break the program.

Its almost like the CalendarGadget got destroyed or something. If I try ResizeGadget to move the calendar into view, I still see no calendar. If I IsGadget() to make sure it exists, it is there. This is so perplexing. I thought maybe something about PBv5.40 was tripping so I tried to run it in PBv6.21 but code won't run there at all, which is another major frustration. Afraid I'm going to be stuck in 5.40 forever.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
infratec
Always Here
Always Here
Posts: 7658
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Vanishing CalendarGadget... Why?

Post by infratec »

So you are still running Windows XP :?: :mrgreen: :mrgreen: :mrgreen:
Because some things from Windows XP are not running in Win 10 x64.

You have to fix the things which are not working.
It is not so difficult.

Have you tried what I have written?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4973
Joined: Sun Apr 12, 2009 6:27 am

Re: Vanishing CalendarGadget... Why?

Post by RASHAD »

Hi Randy
Are the calendar space is there but empty ?
Are you using Windows CallBack ?
Egypt my love
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

infratec wrote: Fri Oct 03, 2025 8:54 pm So you are still running Windows XP :?: :mrgreen: :mrgreen: :mrgreen:
I wrote in my OP that "I'm running PB v5.40 64bit on Windows 11"
Have you tried what I have written?
Gadget number???
#RemindCalendar = 3
GdHdl.i = CalendarGadget(#RemindCalendar,9,35,336,330,Date())
I don't think #RemindCalendar is double. Could be I guess.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

RASHAD wrote: Fri Oct 03, 2025 9:02 pm Hi Randy
Are the calendar space is there but empty ?
I don't even get a frame where the calendar should be. The window just stays blank below the editor box.
Are you using Windows CallBack ?
Yes I am using Callback. Looks like this:

Code: Select all

Procedure WinCallback(hWnd,uMsg,wParam.l,lParam.l)
  Static priorWin.i, prevGadget
  Protected frickit.i
  _wParam.w=wParam:_lParam.l=lParam
  Result.i = #PB_ProcessPureBasicEvents
  If AdminFlag.B
    Debug "callback aborted"
    ProcedureReturn Result
  EndIf
  ;/////////
  If uMsg = $16 ; End Session Message
    If wParam 
      ; the Session is ending
      If lParam
        ;user is logging off.
        ;Probably do nothing.
      Else
        ;user is shutting down the system.
        ;NEED TO SAVE DATA and close.
        safeExit = #True ;forgo updste to server
        preserveLog()
        Vacate()
      EndIf
    EndIf
  EndIf
  ;/////////
  If GetAsyncKeyState_(#VK_MENU)
    If GetAsyncKeyState_(#VK_TAB)
      AltTab = #True
      Delay(10)
    EndIf
  EndIf
  If fullInit.i = #True
    If uMsg = 13 ; Watch for Alt+Tab combo
      If wParam = 510
        AltTab = #True
      EndIf
    EndIf
    If WindowID1.i = GdHdl.i
      Select uMsg
        Case #WM_ENDSESSION,#WM_QUERYENDSESSION
          ; whatcha going to do?
        Case #WM_LBUTTONDBLCLK
          mcht.MCHITTESTINFO\cbSize = SizeOf(MCHITTESTINFO)
          mcht\pt\x = DesktopMouseX()
          mcht\pt\y = DesktopMouseY()
          ScreenToClient_(GadgetID(#RemindCalendar), @mcht\pt)
          SendMessage_(GadgetID(#RemindCalendar),#MCM_HITTEST,0,mcht)
          If mcht\uHIt = #MCHT_CALENDARDATE
            ;Debug "Date selected through double-click : " + FormatDate("%mm/%dd/%yyyy",GetGadgetState(#RemindCalendar))
            ModEntry()
            HideWindow(#Window_19,1)
            SetActiveGadget(#RemindList)
            DisableGadget(#RemindTrashAll,0)
          EndIf
      EndSelect
      ProcedureReturn CallWindowProc_(lpPrevFunc,WindowID1.i,Message,wParam,lParam)
    EndIf
    Select TOPwh
      Case HWND0
        ;Debug "Callback 'Message' value is: $" + Hex(Message,#PB_Long)
        Select uMsg
          Case #WM_NOTIFY                   ; Clipboard copy column on highlited lines
            If GetAsyncKeyState_(#VK_SHIFT) ; Must use shift and click on header.
              *nmh.NMHEADER = lParam
              If GetParent_(*nmh\hdr\hwndFrom) = CustList0.i
                If *nmh\hdr\code = #HDN_ITEMCLICK
                  ;Debug "Column " + Str(*nmh\iitem)+ " clicked"
                  If *nmh\iItem > 2
                    If CountGadgetItems(#CustList_0) > 0
                      FselCount.i = SendMessage_(CustList0,#LVM_GETSELECTEDCOUNT,0,0)
                      If FselCount.i > 0
                        a1.i = -1
                        Repeat 
                          a1.i = SendMessage_(CustList0, #LVM_GETNEXTITEM, a1.i, #LVNI_SELECTED) 
                          If a1.i <> -1 
                            s$ = s$ + GetGadgetItemText(#CustList_0,a1.i,2)
                            If Len(GetGadgetItemText(#CustList_0,a1.i,3)) > 1
                              s$ = s$ + "  (" + GetGadgetItemText(#CustList_0,a1.i,*nmh\iItem) + ")"
                            EndIf
                            s$ = s$ + CRLF$
                          EndIf 
                        Until a1.i = -1 
                        SetClipboardText(s$)
                        Copied()
                      EndIf
                    EndIf
                  EndIf
                EndIf
              EndIf
            EndIf
          Case #WM_COMMAND
            frickit.i = wParam >>16
            Select frickit.i
              Case #EN_CHANGE ; Need this to cue CypherListing() search in main window
                Select lParam
                  Case CallBox0
                    oLnewInp = #True ; << Trigger flag
                    usrDelay.i = GetTickCount_()
                  Case GadgetID(#Date_To_3)
                EndSelect
              Case #CBN_EDITCHANGE
            EndSelect
          Case #WM_LBUTTONDBLCLK
            If IsZoomed_(HWND0) = 0
              Select wW0
                Case 830
                  ;wW0 = 598
                  SetWindowPos_(HWND0, 0, wpx, wpy, 598, wH0+1, #SWP_SHOWWINDOW)
                  ShowWindow_(HWND0,#SW_SHOWNA)
                  SetGadgetAttribute(#Width_0,#PB_Button_Image, ImageID(#ButtonRight))
                Case 609
                  ;wW0 = 814
                  SetWindowPos_(HWND0, 0, wpx, wpy, 814, wH0+1, #SWP_SHOWWINDOW)
                  ShowWindow_(HWND0,#SW_SHOWNA)
                  SetGadgetAttribute(#Width_0,#PB_Button_Image, ImageID(#ButtonLeft))
              EndSelect
              WindowSized = 1
            EndIf
            ;Debug "doubleclick"
          Case #PB_Event_CloseWindow, #WM_CLOSE
            damnCallbackSaysClose.i = #PB_Event_CloseWindow
          Case #WM_WINDOWPOSCHANGED
            ;Debug "moved"
            GetWindowRect_(TOPwh,rw)
            If rw\top > -10 ; Conditional added here to help align 'Reminder' window
              wpy = rw\top
            EndIf
            ;Debug rw\bottom - rw\top
            GetClientRect_(TOPwh,rc)
            cpy = rc\top
            WindowSized = 1
          Case #WM_SIZE ;, #WM_WINDOWPOSCHANGED
            GetWindowRect_(TOPwh,rw)
            If rw\top > -10 ; Conditional added here to help align 'Reminder' window
              wpx = rw\left
              wpy = rw\top
            EndIf
            wW0 = rw\right - wpx - 1
            wH0 = rw\bottom - wpy - 1
            GetClientRect_(TOPwh,rc)
            cpx = rc\left
            cpy = rc\top
            chx = rc\right - cpx - 1
            chy = rc\bottom - cpy - 6
            WindowSized = 2
            If wParam = SIZE_RESTORED
              SetFocus_(prevGadget)
              Debug "oneLook Restored"
            ElseIf wParam = 1  ; Minimized just now
              prevGadget = Focus
              Debug "oneLook SHRUNKEN"
            EndIf
        EndSelect
      Case HWND2
        Select uMsg
          Case #PB_Event_CloseWindow, #WM_CLOSE
            _mess = #PB_Event_CloseWindow
        EndSelect
      Case HWND4, HWND5
        Select uMsg
          Case #WM_WINDOWPOSCHANGED
            WindowSized = 3
          Case #WM_SIZE ;, #WM_WINDOWPOSCHANGED
            WindowSized = 3
          Case  #WM_NOTIFY 
            WindowSized = 3
        EndSelect
      Case HWND11
        Result.i = 0
        ProcedureReturn
      Case HWND20
        Select uMsg
          Case #WM_SIZE
            Select wParam
              Case #SIZE_MINIMIZED 
                Debug "Window was minimized"
                DoMinimizedSave = #True
            EndSelect 
        EndSelect 
    EndSelect
    Select uMsg ; used to catch remnant Window messages before proceding with new window
      Case AttachSkype
        ;Debug "Attach_SkypeID Value: " + Str(AttachSkype)
        ;Debug "Status Return Value: " + Str(lParam)
        SkypeLink.i = lParam
        Select lParam
          Case #Success             ; 0
            SkypeHandle = wParam
            ;Debug "oneLook Attached to Skype"
            ; SetGadgetText(3, "Disconnect")
          Case #PendingAuthorizaion ; 1
            ;Debug "oneLook to Skype Authorization Pending"
          Case #Refused             ; 2
            ;Debug "Refused, so goto: Tools > Options > Advanced > Manage other programs' access to Skype"
          Case #NotAvailable        ; 3
            ;Debug "oneLook cannot launch Skype, so go start Skype."
          Case #Available           ; $8001
        EndSelect
      Case #WM_COPYDATA
        If wParam = SkypeHandle
          *cds.COPYDATASTRUCT = lParam
          If *cds\lpData
            ;Debug PeekS(*cds\lpData)
          EndIf
          ProcedureReturn 1
        EndIf
      Case #WM_WINDOWPOSCHANGED
        WindowChange.i = #True ; see GlobalTasking()
      Case #WM_COMMAND
        frickit.i = wParam >>16
        Select frickit.i
          Case #EN_SETFOCUS
            activeGad.i = GetDlgCtrlID_(lParam) ;EventGadget()
            Select activeGad.i
              Case 0 To 16
                If IsWindow(TOPwh.i)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Return, #KB_Return)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_PageUp, #KB_Prior)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_PageDown, #KB_Next)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_End, #KB_End)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Home, #KB_Home)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Up, #KB_Up)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Down, #KB_Down)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Alt | #PB_Shortcut_Up, #KB_Alt_Up)
                  AddKeyboardShortcut(TOPwh.i, #PB_Shortcut_Alt | #PB_Shortcut_Down , #KB_Alt_Down)
                EndIf
                PrevFocus.i = activeGad.i
                activeW.i = TOPwh
                priorWin.i = TOPwh ; << Tracking "top window" in this application only.
              Default
                PrevFocus.i = activeGad.i
                activeW.i = TOPwh
            EndSelect
          Case #EN_KILLFOCUS
            If IsWindow(priorWin.i)  ;DON'T KNOW HOW BUT THIS GYRATION GOT BROKEN
                ; and commenting line below seems to have fixed the new problem. 
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Return)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_PageUp)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_PageDown)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_End)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Home)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Up)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Down)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Alt | #PB_Shortcut_Up)
;               RemoveKeyboardShortcut(priorWin.i, #PB_Shortcut_Alt | #PB_Shortcut_Down)
            EndIf
        EndSelect
    EndSelect
  EndIf
  ProcedureReturn Result
EndProcedure
I know there is some very goofy stuff in there but it was doing what I needed it to do. Mind you I absolutely HATE callbacks. Required to catch some #WM_ messages so i am forced to use it.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4973
Joined: Sun Apr 12, 2009 6:27 am

Re: Vanishing CalendarGadget... Why?

Post by RASHAD »

Stop the callback and see if the calendar is visible or not
Egypt my love
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

RASHAD wrote: Sat Oct 04, 2025 4:44 am Stop the callback and see if the calendar is visible or not
Great call RASHAD! THANKS!!! ⭐⭐⭐⭐⭐
Didn't exactly pinpoint the cause but at least it's a starting point. Calendar came back with SetWindowCallback line commented out.
And you did that without seeing the full code. :D Genius!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1097
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Vanishing CalendarGadget... Why?

Post by Randy Walker »

RASHAD wrote: Fri Oct 03, 2025 2:32 am Hi Randy :)
How can we help you without the problematic code
OK RASHAD... I went back and tested my standalone reminder app and it has the exact same problem.
Copy the code from this page for full code.
viewtopic.php?p=372626#p372626
Run the code, add a new event and get the blank cakladar window.
Comment line 288 and try again -- the calandar is there.

I don't know where that line 288 and 289 came from but I recall someone here helped me to catch doubleclick on a calendar date and that is broken now too.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
Michael Vogel
Addict
Addict
Posts: 2818
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Vanishing CalendarGadget... Why?

Post by Michael Vogel »

You'd better check all variable types in your code (long vs. integer) - the following code works fine here...

Code: Select all

Procedure WinCallback(WindowID1,message,wParam,lParam)
	Result = #PB_ProcessPureBasicEvents
	If WindowID1 = WnHdl
		Select message
		Case #WM_LBUTTONDBLCLK
			mcht.MCHITTESTINFO\cbSize = SizeOf(MCHITTESTINFO)
			mcht\pt\x = DesktopMouseX()
			mcht\pt\y = DesktopMouseY()
			ScreenToClient_(GadgetID(0), @mcht\pt)
			SendMessage_(GadgetID(0),#MCM_HITTEST,0,mcht)
			If mcht\uHIt = #MCHT_CALENDARDATE
				Debug "Date selected through double-click : " + FormatDate("%mm/%dd/%yyyy",GetGadgetState(0))
				ModEntry()
				HideWindow(0,1)
				SetActiveGadget(2)
				SaveEvents()
			EndIf
		EndSelect
		;CallDebugger
		Debug "."+lpPrevFunc
		ProcedureReturn CallWindowProc_(lpPrevFunc,WindowID1,message,wParam,lParam)
	EndIf
	Debug "0"
	ProcedureReturn Result
EndProcedure
Post Reply