Page 1 of 2

Posted: Mon Aug 26, 2002 9:07 pm
by BackupUser
Restored from previous forum. Originally posted by TerryHough.

Does anybody have an example of using the commond control's Calendar.

I realy need to use it, but I am so new to PureBasic that I haven't a clue as how to access and use it.

Thanks in advance,
Terry

Posted: Tue Aug 27, 2002 1:26 am
by BackupUser
Restored from previous forum. Originally posted by freak.

Well, i don't have one, but just started writing one .

It looks like a lot of work, but it's fun.
I'll post the results, if i succeed...

Timo

--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.

...So far, the universe is winning.

Posted: Tue Aug 27, 2002 4:32 am
by BackupUser
Restored from previous forum. Originally posted by Franco.

Hope this is somewhat useful...

Code: Select all

; (c) 2002 - Franco's template - absolutely freeware
; Win-API Calendar
; coded under WinXP
; (hope it works also on other M$-OS, but you never know...)
 
OpenWindow(0,150,150,200,200,#PB_Window_SystemMenu,"API-Calendar")
CreateWindowEx_(0,"SysMonthCal32",0,#WS_CHILD|#WS_VISIBLE|#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS,0,0,200,200, WindowID(),0,GetModuleHandle_(0),0)
 
Repeat
  EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
 
End
Have fun :)

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Tue Aug 27, 2002 5:42 am
by BackupUser
Restored from previous forum. Originally posted by Paul.

Sorry, doesn't work under Win2K.
Just an empty window :(

Posted: Tue Aug 27, 2002 6:55 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> Sorry, doesn't work under Win2K.
> Just an empty window :(

Same... Franco, which versions of these files do you have on XP:

User32.dll (I have 5.0.2195.2821).
Comctl32.dll (I have 5.81.4704.1100).

Because according to http://tinyurl.com/16cr the SysMonthCal32 item
is part of Comctl32.dll v4.70 (or perhaps User32.dll).


PB - Registered PureBasic Coder

Posted: Tue Aug 27, 2002 7:06 am
by BackupUser
Restored from previous forum. Originally posted by H.Brill.


Hi,

It not works on WIN 98. It is a mistake by the API-functions or
styles. i have a demo program in IBasic and it works, but i have
not any experience with API calls and API styles. if you want, i
can send you the demo for looking the sourcecode.
perhaps you can need it to translate to PB.

[url]mailto:H.Brill@t-online.de[/url]

Posted: Tue Aug 27, 2002 7:19 am
by BackupUser
Restored from previous forum. Originally posted by H.Brill.


or download it :
http://www.pyxia.com
- forums
- Software Projects
- Date Dialog Component

Posted: Tue Aug 27, 2002 1:10 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Franco always forgets to initialize the ShellCC :)

Code: Select all

; (c) 2002 - Franco's template - absolutely freeware
; Win-API Calendar
; coded under WinXP
; (hope it works also on other M$-OS, but you never know...)
 
Structure INITCOMMONCONTROLSEX
 dwSize.l
 dwICC.l
EndStructure
 
my.INITCOMMONCONTROLSEX
my\dwSize = 8
my\dwICC  = $100
InitCommonControlsEx_(@my)
 
OpenWindow(0,150,150,200,250,#PB_Window_SystemMenu,"API-Calendar")
 
CreateWindowEx_(0,"SysDateTimePick32","DateTime",#WS_CHILD|#WS_VISIBLE|4,0,0,200,25, WindowID(),0,GetModuleHandle_(0),0)
CreateWindowEx_(0,"SysMonthCal32","DateTime",#WS_CHILD|#WS_VISIBLE|#WS_BORDER,0,50,200,200, WindowID(),0,GetModuleHandle_(0),0)
 
Repeat
  EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
 
End
cya,
...Danilo

(registered PureBasic user)

Posted: Tue Aug 27, 2002 3:52 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.

Good morning :)
@home I have a normal WinXP installation, nothing fancy.
I purchased my SONY Notebook Nov/Dec 2001 and AFAIK there are no different versions of User32.dll and Comctl32.dll - well not that I know of (the Service Pack 1 should come in fall).

I read once that the DLL's coming with WinXP are different than all the other OS before.
All previous versions of DLL's are combined in ONE DLL - this way M$ wanted to get out of the DLL hell.

Now @work I have Win2k-Sp3 and my code doesn't work either :cry:
Originally posted by Danilo

Franco always forgets to initialize the ShellCC :)
Sorry folks :)

I found C code and I converted the CreateWindowEx call to PureBasic, tested it, and it worked.
Was really surprised that it worked without initializing InitCommonControlsEx so I didn't add it to the code - couldn't test the difference, it always worked. (I was not able to tell if the initialization failed or not...)

Danilo thanks for your help.

My conclusion now is that WinXP is a miserable programming environment - or is there a WinXP user that was not able to run my initial code :)

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Tue Aug 27, 2002 5:43 pm
by BackupUser
Restored from previous forum. Originally posted by TerryHough.
Originally posted by Danilo

Franco always forgets to initialize the ShellCC :)
Thanks to both of you, Franco and Danilo.

I am not quite sure what all of it means, but I will study and learn.

Regards,
Terry

Posted: Tue Aug 27, 2002 10:24 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> Franco always forgets to initialize the ShellCC :)

Thanks Danilo -- it now works for me (W2K).

Now, if only we knew which date the user clicked on...? :)
Is there a way to determine the day/month/year currently selected?


PB - Registered PureBasic Coder

Posted: Wed Aug 28, 2002 6:04 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

First get the HAndle to the control by putting something like
'hCal.l =' in front of CreateWindowEx_(), then to get the date,
use this:

Code: Select all

#MCM_GETCURSEL = $1001

SendMessage_(hCal, #MCM_GETCURSEL, 0, @time.SYSTEMTIME)
You'll now have the date stored in the time Structure.
Here are it's contents:

wYear
Specifies the current year. The year must be greater than 1601.
Windows XP: The year cannot be greater than 30827.

wMonth
Specifies the current month; January = 1, February = 2, and so on.
wDayOfWeek
Specifies the current day of the week; Sunday = 0, Monday = 1, and so on.
wDay
Specifies the current day of the month.
wHour
Specifies the current hour.
wMinute
Specifies the current minute.
wSecond
Specifies the current second.
wMilliseconds
Specifies the current millisecond.

Posted: Wed Aug 28, 2002 6:09 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Works the same with the #MCM_SETCURSEL Message, to set the
selected date. (#MCM_SETCURSEL = $1002)

Posted: Wed Aug 28, 2002 6:49 pm
by BackupUser
Restored from previous forum. Originally posted by TerryHough.
Now, if only we knew which date the user clicked on...? :)
Is there a way to determine the day/month/year currently selected?

PB - Registered PureBasic Coder
PB, you must have been reading my mind. I was trying to figure out
the same thing.

Freak,
Thanks for the pointers. But I am still confused. I can't get the
date info even with this. But, remember, I am a novice so I don't
even understand all of this.

I want to get the date info, and then be able to manipulate it.
Somehow, I still can't access the SYSTEMTIME information. Maybe
you could expand your explanation to show how to actually access
wYear, etc.

BTW, is there a way to grab the Julian date?

Appreciate your help and advice.

Terry

Posted: Wed Aug 28, 2002 7:29 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.

Does this make a little more sense? ...

Code: Select all

; (c) 2002 - Franco's template - absolutely freeware 
; Win-API Calendar 
; coded under WinXP 
; (hope it works also on other M$-OS, but you never know...) 
 
#MCM_GETCURSEL = $1001
#ok=1
 
Structure INITCOMMONCONTROLSEX 
dwSize.l 
dwICC.l 
EndStructure 
 
my.INITCOMMONCONTROLSEX 
my\dwSize = 8 
my\dwICC = $100 
InitCommonControlsEx_(@my) 
 
hWnd=OpenWindow(0,150,150,200,250,#PB_Window_SystemMenu,"API-Calendar") 
If hWnd=0 Or CreateGadgetList(hWnd)=0:End:EndIf
 
hCal=CreateWindowEx_(0,"SysMonthCal32","DateTime",#WS_CHILD|#WS_VISIBLE|#WS_BORDER,0,0,200,200,hWnd,0,GetModuleHandle_(0),0) 
ButtonGadget(#ok,100,220,50,20,"Get Time")
 
Repeat 
  EventID.l = WaitWindowEvent() 
  If EventID=#PB_EventGadget
    If EventGadgetID()=#ok
      SendMessage_([url]mailto:hCal,#MCM_GETCURSEL,0,@time.SYSTEMTIME[/url])
      year=time\wYear
      month=time\wMonth
      day=time\wDay       
      info.s=Str(month)+"/"+Str(day)+"/"+str(year)
      MessageRequester("",info,0)   
    EndIf  
  EndIf
Until EventID = #PB_EventCloseWindow
End
As far as I know you have to calculate Julian date yourself (but I could be wrong) :)