CalendarGadget and EventType?

Just starting out? Need help? Post your questions and find answers here.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

CalendarGadget and EventType?

Post by Marco2007 »

Hi,

is there a chance to retrieve the State of a CalendarGadget by LeftDoubleClicking on a date on the CalendarGadget?

Has anyone an idea, please?

Thank you
Marco
PureBasic for Windows
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Is this what you are after ?

Code: Select all

#MCN_SELECT = #MCN_FIRST + 4 

Global gOldProc, gBlnSelected

Procedure calProc(hWnd, uMsg, wParam, lParam)
  Protected result, selDate
  Static dateBeforeClick, dateAfterClick
  Select uMsg
    Case #WM_LBUTTONDBLCLK
      result = CallWindowProc_(gOldProc, hWnd, uMsg, wParam, lParam)
      If gBlnSelected
        selDate = GetGadgetState(0) 
        Debug "New date selected through double-click : " + FormatDate("%dd/%mm/%yyyy", selDate) 
        gBlnSelected = #False
      EndIf
    Default
      result = CallWindowProc_(gOldProc, hWnd, uMsg, wParam, lParam)
  EndSelect
  ProcedureReturn result
EndProcedure

Procedure WinCallback(hwnd, msg, wparam, lparam) 
  Protected result = #PB_ProcessPureBasicEvents
  Select msg 
    Case #WM_NOTIFY 
      *pnmh.NMHDR = lparam 
      If *pnmh\hwndFrom = GadgetID(0) 
        Select *pnmh\code 
          Case #MCN_SELECT 
            gBlnSelected = #True
        EndSelect 
      EndIf 
  EndSelect 
  ProcedureReturn result 
EndProcedure 

If OpenWindow(0, 0, 0, 220, 280, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
  CalendarGadget(0, 10, 10, 200, 180) 
  SetClassLong_(GadgetID(0), #GCL_STYLE, GetClassLong_(GadgetID(0), #GCL_STYLE)!#CS_DBLCLKS)
  gOldProc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @calProc())
  SetWindowCallback(@WinCallback())
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_Event_CloseWindow 
EndIf 
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

You are a fu**ing genius!!! 8)

Thank you very much!!!!!!!!!
PureBasic for Windows
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: CalendarGadget and EventType?

Post by PB »

What's wrong with GetGadgetState?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

It`s like a DateRequester: The Calendargadget pops up in a seperate window (click on '...'), when using #nxPropertyBox_CustomTextDialog from nxProperty...
Image

I did it with GetGadgetState...but then I have to click first on the date and then close the window by extra-clicking on X. A double-click is much better and usual :-)

I didn`t have a better idea, how to do this.
PureBasic for Windows
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post by Shardik »

Fluid Byte already posted a code example in the German forum in September 2008: :wink:
http://www.purebasic.fr/german/viewtopi ... 92&start=4
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

...and why didn`t you tell me on Sat May 30? :evil:

OF course, I´ve searched on the German board, too -> but always "Calendargadget" with the wrong word... I just had to use "klick" instead of "click"... :x

...so Fluid is also a fu**king genius. :lol:
PureBasic for Windows
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Fluid's is a much better solution. Use that one! :wink:
I may look like a mule, but I'm not a complete ass.
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post by Shardik »

Marco2007 wrote:...and why didn`t you tell me on Sat May 30? :evil:
I am a professional programmer who looks into the PB forums only during his working hours (if time allows)
but normally not during weekends... :wink:
Marco2007 wrote:OF course, I´ve searched on the German board, too -> but always "Calendargadget" with the wrong word... I just had to use "klick" instead of "click"... :mad:
A search with only "calendargadget" in the German forum would have shown Fluid Byte's posting as the 4th entry...
But if the forum search doesn't deliver the wanted results it's always worthwhile to try a Google search with the site parameter:
"calendargadget site:http://www.purebasic.fr"
(Thank you PB for this hint in a previous thread :wink:)
Using this approach you are also searching through German and French forums and the Google search is more reliable than the forum search.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Shardik wrote:A search with only "calendargadget" in the German forum would have shown Fluid Byte's posting as the 4th entry....
Yeah, I found out yesterday...I thought, searching only for calendargadget will display too many results...
Shardik wrote: worthwhile to try a Google search with the site parameter:
"calendargadget site:http://www.purebasic.fr"
Good to know and thanx! 8)
Shardik wrote:...who looks into the PB forums only during his working hours (if time allows)
forum sites are banned, where I work :cry:
PureBasic for Windows
Post Reply