Date Requester?

Just starting out? Need help? Post your questions and find answers here.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Date Requester?

Post by Karbon »

Didn't someone write a userlib that had a date requester? I know about the calendar and date picker API gadgets but I need something that pops open to prompt for a date and provides and easy way to retrieve it..

On a side note, does anyone have any information on trapping selections from a calendar gadget (so as to make a requester like the one I just described)?

Thanks!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

dont you have PureVision? It has a date picker. Try the examples, that is one that retries the data.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Sure I do, and I know about the date picker and cal gadgets. What I need is a *requester*..

I could swear that someone wrote one back in the summer but I can't find any mention of it now..
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

ah ok im very sorry. must have readden too fast... :oops:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I recently started working on Datepicker lib, but I don't think it's going to suit your needs. If time permits, I'll see if I can come up with a requester type Datepicker as well. :)
On a side note, does anyone have any information on trapping selections from a calendar gadget (so as to make a requester like the one I just described)?
You may find some useful info in this related thread.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> What I need is a *requester*

What exactly do you mean by this? I've got a date picker example that seems
to do what you want... ie. it's like a string gadget with an arrow on the end that
you click... if you click this arrow, a small month view comes up and you can
select a date. If you put this date picker in its own pop-up window, then isn't
that what you'd want? Just trying to understand what you need. :) Can you
draw a pic or something to help me visualize your need?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

I need a date or calendar picker to be on a panel, but that isn't possible without some hacks (though there is hope for a native date gadget!). My intention is to take it by having a read-only string gadget with a image button beside that, when clicked, displays a calendar and puts what ever date they select into the string gadget..
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Here's where I'm at with my lib thus far. I've taken the key parts of the lib and put it into this small example. You select a date then Ctrl + Left click into a readonly string gadget.

Code: Select all

#GDT_VALID = 0
#GDT_NONE = 1
#DTM_FIRST = $1000
#DTM_GETSYSTEMTIME = #DTM_FIRST + 1
#DTM_SETSYSTEMTIME = #DTM_FIRST + 2
#DTN_DATETIMECHANGE = #DTN_FIRST + 1 
#DTN_DROPDOWN = #DTN_FIRST + 6 
#DTN_CLOSEUP = #DTN_FIRST + 7 
#MCM_FIRST = $1000
#MCM_GETCURSEL = #MCM_FIRST + 1 
#MCN_FIRST = -750
#MCN_SELCHANGE = #MCN_FIRST + 1
#MCN_SELECT = #MCN_FIRST + 4
#MCN_GETDAYSTATE = #MCN_FIRST + 3

Global inputCallback, hSDPdatePicker, myDate$

Structure INITCOMMONCONTROLSEX 
  dwSize.l 
  dwICC.l 
EndStructure 

InitICC.INITCOMMONCONTROLSEX 
InitICC\dwSize = SizeOf(INITCOMMONCONTROLSEX)  
InitICC\dwICC = #ICC_DATE_CLASSES 
InitCommonControlsEx_(InitICC) 

Procedure SDPinputCallback(hwnd, msg, wParam, lParam) 
  
  Select msg
    Case #WM_LBUTTONDOWN
      GetAsyncKeyState_(#VK_CONTROL) ; clear control key
      If GetAsyncKeyState_(#VK_CONTROL)
        myDate$ = Space(256)
        SendMessage_(hSDPdatePicker, #DTM_GETSYSTEMTIME , 0, @CurDateTime.SYSTEMTIME) 
        myDateLen = GetDateFormat_(#LOCALE_USER_DEFAULT, 0, @CurDateTime, 0, @myDate$, 0)
        GetDateFormat_(#LOCALE_USER_DEFAULT, 0, @CurDateTime, 0, @myDate$, myDateLen)
        SetGadgetText(EventGadgetID(), myDate$)
      EndIf
    Case #WM_KEYUP
      GetAsyncKeyState_(#VK_CONTROL) ; clear control key
      If wParam = #VK_HOME And GetAsyncKeyState_(#VK_CONTROL)
        myDate$ = Space(256)
        GetLocalTime_(@CurDateTime.SYSTEMTIME)
        Debug CurDateTime\wday
        SendMessage_(hSDPdatePicker, #DTM_SETSYSTEMTIME , #GDT_VALID, @CurDateTime) 
        myDateLen = GetDateFormat_(#LOCALE_USER_DEFAULT, 0, @CurDateTime, 0, @myDate$, 0)
        GetDateFormat_(#LOCALE_USER_DEFAULT, 0, @CurDateTime, 0, @myDate$, myDateLen)
        SetGadgetText(EventGadgetID(), myDate$)
      EndIf
      
  EndSelect
  ProcedureReturn CallWindowProc_(inputCallback, hwnd, msg, wParam, lParam)
EndProcedure

ProcedureDLL SDP_myDatePicker(GadgetNum, x, y, width, height) ; Gadget#, x, y, width, height
  hSDPdatePicker = CreateWindowEx_(#WS_EX_CLIENTEDGE, "SysDateTimePick32", "Date", #WS_CHILD|#WS_VISIBLE, x, y, width, height, WindowID() ,GadgetNum ,GetModuleHandle_(0), 0) 
  ProcedureReturn hSDPdatePicker
EndProcedure

ProcedureDLL SDP_myDateInput(GadgetNum, x, y, width, height, text$)
  StringGadget(GadgetNum, x, y, width, height, text$, #PB_String_ReadOnly)
  inputCallback = SetWindowLong_(GadgetID(GadgetNum), #GWL_WNDPROC, @SDPinputCallback())
EndProcedure

If OpenWindow(0, 0, 0, 200, 150, #PB_Window_ScreenCentered|#PB_Window_SystemMenu , "Date Picker") 
  
  If CreateGadgetList(WindowID(0))
    SDP_myDatePicker(0, 0, 0, 100, 20)
    TextGadget(1, 20, 50, 80, 20, "Name")
    TextGadget(2, 100, 50, 80, 20, "Date of Birth")
    StringGadget(3, 20, 70, 80, 20, "Fred")
    SDP_myDateInput(4, 100, 70, 80, 20, "Ctrl + Left click")
  EndIf

  Repeat 
    
    Event = WaitWindowEvent() 
    
  Until Event = #PB_Event_CloseWindow
  End
EndIf
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

I don't know if this will help you?

Code: Select all



#MCM_GETCURSEL = $1001 

Global hcal
Global hwnd, hwnd1

Declare datepick()

Structure InitCommon 
  dwSize.l 
  dwICC.l 
EndStructure 

Global my.InitCommon 
my\dwSize = 8 
my\dwICC = $100 

InitCommonControlsEx_(@my) 

hwnd=OpenWindow(0,300,400,300,100.0,#PB_Window_SystemMenu,"Calender THIS!") 
If hwnd=0 Or CreateGadgetList(hwnd)=0:End:EndIf 
ActivateWindow()
ButtonGadget(1,30,10,50,20,"Date Me!") 
ButtonGadget(2,30,50,50,20,"EXIT!") 

Repeat 
  EventID.l = WaitWindowEvent() 
  
  If EventID = #PB_EventGadget 
    Select EventGadgetID() 
      Case 1
         datepick()
      Case 2
        End
    EndSelect 
  EndIf 
Until EventID = #PB_EventCloseWindow 

Procedure Datepick()

  hwnd1=OpenWindow(1,600,400,350,400.0,#PB_Window_SystemMenu,"API-Kalender")
  If hwnd1=0 Or CreateGadgetList(hwnd1)=0:End:EndIf 
  ;ActivateWindow()

  hCal=CreateWindowEx_(0,"SysMonthCal32","Calender",#WS_CHILD|#WS_VISIBLE,10,80,300,300,hwnd1,0,GetModuleHandle_(0),0) 
  ;ein wenig Farbe ins Spiel bringen 
  SendMessage_(hCal,4106,0,$800000);MCM_SC_BACKGROUND 
  SendMessage_(hCal,4106,4,$800000);MCM_SC_MONTHBACK 
  SendMessage_(hCal,4106,2,$0000FF);MCM_SC_TITLE 
  SendMessage_(hCal,4106,1,$00FFFF);MCM_SC_TEXT 
  SendMessage_(hCal,4106,3,$00FFFF);MCM_SC_TITLETEXT 

  ButtonGadget(3,10,10,50,20,"OK")

  Repeat 
    EventID.l = WaitWindowEvent() 
    If EventID = #PB_EventGadget 
      Select EventGadgetID() 
        Case 3
          SendMessage_(hCal,#MCM_GETCURSEL,0,@time.SYSTEMTIME ) 
          year=time\wYear 
          month=time\wMonth 
          day=time\wDay 
          info.s = Str(day)+"."+Str(month)+"."+Str(year) 
          MessageRequester("",info,0)
          t = DestroyWindow_(hcal)
          If t<> 0
            CloseWindow_(hwnd1)
          EndIf
          Break
      EndSelect 
    EndIf 
  Until EventID = #PB_EventCloseWindow 
EndProcedure

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Post Reply