You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

1

Thursday, June 4th 2009, 5:31pm

New MonthCalendar Control for the Jabaco framework

Hi there,


by experimenting with Usercontrols in Jabaco I have created a small Control what you call in VB a MonthCalendar.
It simply shows a sort of a Calendar that has a line for every week and the week day names in columns, where the user can select a special date. It's underlying working class is the GregorianCalendar from the namespace java#util.

if you drag an object of it onto a form you could use it on a form like this:

Jabaco Source

1
2
3
4
5
6
7
Public Sub MonthCalendar1_Selected() 
   MonthCalendar1.Visible = False 
   Command1.Caption = MonthCalendar1.Calendar.getTime.toLocaleString 
End Sub 
Public Sub Command1_Click() 
   MonthCalendar1.Visible = True 
End Sub

this is the first version so it is already working but it is in beta status.

i also left some room for extensions some ideas:
* let the user/programmer select the first week day (sunday or monday)
* adding an additional column on the left that shows the number of the week
* adding functionality that let the user perform addition/subtraction of timespans to the selected date
* coloring sunday, public holiday or all other special dates, e.g. birthdays
* let the user/programmer define his own user colors


greetings

OlimilO
OlimilO has attached the following image:
  • MonthCalendar.png
OlimilO has attached the following file:
  • Calendar_09.zip (8.49 kB - 646 times downloaded - latest: Jun 23rd 2018, 9:32pm)

JonnyC

Beginner

  • "JonnyC" is male

Posts: 2

Date of registration: Oct 7th 2009

Location: Germany

  • Send private message

2

Wednesday, October 7th 2009, 3:57pm

Looks and works great, thanx.

How about a little 'today' button?

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

3

Thursday, October 8th 2009, 9:01am

good suggestion, how would you design and code it?

JonnyC

Beginner

  • "JonnyC" is male

Posts: 2

Date of registration: Oct 7th 2009

Location: Germany

  • Send private message

4

Monday, October 26th 2009, 8:38pm

Quick and Clean <hopefully> :-)

Jabaco Source

1
2
3
4
5
Public Sub cmd_set_today_Click()
   MyCal = New GregorianCalendar     
   Call InitDate(MyCal.getTime)
   bInitEnd = True
End Sub


JonnyC has attached the following file:

Giasone70

Beginner

Posts: 8

Date of registration: May 7th 2011

  • Send private message

5

Saturday, December 21st 2013, 11:51am

Something seems to be buggy. Here the initial date is one mont forward. Today the control says it is january 21 2014!
I tried digging the code but didtnt foud the mistake...
Would someone check it?
TIA

Giasone70

Beginner

Posts: 8

Date of registration: May 7th 2011

  • Send private message

6

Saturday, December 21st 2013, 12:05pm

Probably I have found the problem: the init sub must be changed as below:

Jabaco Source

1
2
3
4
5
6
7
8
Public Sub InitDate(thisDate As Date)
Dim Cal As GregorianCalendar = Cast(MyCal.clone, java#util#GregorianCalendar)
 Cal.set(Calendar.YEAR, Year(thisDate))
 Cal.set(Calendar.MONTH, Month(thisDate)-1)
 Cal.set(Calendar.DAY_OF_MONTH, Day(thisDate))
 InitCalendar(Cal)
 bInitEnd = True
 End Sub


I hope it can be useful.

Theera

Beginner

  • "Theera" is male

Posts: 21

Date of registration: Feb 27th 2014

Location: Supanburi ,Thailand

Occupation: Agric Chemical Seller

Hobbies: learning programming and English

  • Send private message

7

Monday, March 10th 2014, 3:10am

Hi all,
This will not cause problems at the border. It would be great if there was a solution to the program Jabaco. (The prevent is better than the solved)
P.S. I'm not good at English and programming,Please understand me.
Best Regards,

Theera

Theera

Beginner

  • "Theera" is male

Posts: 21

Date of registration: Feb 27th 2014

Location: Supanburi ,Thailand

Occupation: Agric Chemical Seller

Hobbies: learning programming and English

  • Send private message

8

Monday, March 10th 2014, 4:56am

1.)After I 've tested, It still has a bug ,although we 've fixed in post #6 already. My test is, whenever I click the date of next month,it will shown the wrong month.
2.) I 've not clicked any date yet,the calendar is always lost.
3.) I have the log file .
Theera has attached the following file:
P.S. I'm not good at English and programming,Please understand me.
Best Regards,

Theera

This post has been edited 1 times, last edit by "Theera" (Mar 10th 2014, 5:06am)


theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

9

Thursday, July 17th 2014, 6:47pm

Last month I played a little bit around with that program.

Uploading it, before I don't find it again on my computer.
The difference is now, that the calendar is a dropdown menu. So the Window don't need a special size. It only needs to be big enough for the button.

Greatings
theuserbl
theuserbl has attached the following image:
  • Calendar10.PNG
theuserbl has attached the following file:

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

10

Thursday, July 17th 2014, 6:50pm

Oh, and it shows again, that there is a bug in the framework with the date.
Have to fix it in the future.

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

11

Friday, July 18th 2014, 9:57am

Hey there,

I like the dropdown button.

I am not sure if we realy got a Date problem here though. To me it looks like it is a problem with the MouseListener!
In MonthCalendar:

Jabaco Source

1
2
'###########################    MouseListener
Public Sub mousePressed(arg2 As MouseEvent)


...gets triggered twice. So we got a recursion here. The day lables get drawn twice and therefore all values change!!

My guess is that the Calendar Usercontrolls' MouseListener interferes with the Jabaco Frameworks' Usercontrol, Superclass is PictureBox, MouseListener.


Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

12

Friday, July 18th 2014, 6:06pm

Hey there,

I just looked at the code again and found the bug in:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'###########################    CreateControls
Private Function CreateControls(ParentForm As UserControl, _
                                MListener As java#awt#Event#MouseListener, _
                                Count As Integer, _
                                Width As Integer, _
                                Height As Integer, _
                                pos0X As Integer, _
                                pos0Y As Integer, _
                                cxy As Integer, _
                                flip As Boolean) As Label()
  
   'Creates an array of controls
   Dim Control As Label
   Dim List()  As Label: ReDim List(0 To Count - 1)
   Dim i As Integer, L As Integer, T As Integer
   For i = 0 To Count - 1
      Control = New Label
      ParentForm.add(Control)
      List(i) = Control
      Control.Parent.addMouseListener(MListener)
      Control.TextAlign = fmTextAlignCenter
      
      If Width > 0  Then Control.Width  = Width
      If Height > 0 Then Control.Height = Height
      
      L = pos0x + (i Mod cxy) * Width
      T = pos0y + (i \ cxy) * Height
      
      If flip Then 
         Dim tmp As Integer 
         tmp = L: L = T: T = tmp
      End If
      
      Control.Left = L
      Control.Top = T
      
      Control.Parent.addMouseListener(MListener)
   Next
   CreateControls = List
End Function


As I suspected it was a problem with the MouseListener:

Jabaco Source

1
Control.Parent.addMouseListener(MListener)

is assigned two times! So simply remove one of those and everything works fine...



Dani

This post has been edited 1 times, last edit by "Dani" (Jul 18th 2014, 9:04pm)


Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

13

Saturday, July 19th 2014, 12:01am

A working JBCalendar!

Hey there,

Calendar.MONTH is zero based!!!!!!!!!!!!

So here is a working Calendar Control:

AworkingCalendar.zip

Dani

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

14

Saturday, July 19th 2014, 9:37am

Hey there,

Calendar.MONTH is zero based!!!!!!!!!!!!

So here is a working Calendar Control:

Nice. But there are two point of criticism:

1. Now after your change in the Monthcalendar dropdown is the time showing, too. But with the Monthcalendar is only changed the year, month and date. And the time is only updated, if the "Today"-button was clickt. So it would be better, to show no time.

2. I think, with this program was worked around Jabaco-Framework bugs.

Here an example:

Jabaco Source

1
2
3
4
5
6
7
8
Private Sub Command1_Click()
   Dim d As Date
   d = Now()
   MsgBox d & vbNewLine & _
   Day(d) & "  " & _
   Month(d) & "  " & _
   Year(d)
End Sub

On VB6 it shows currently on an german Windows XP (needed to say it, because of localization of the date-format):

Source code

1
2
19.07.2014 09:23:47
19  7  2014

On Jabaco it shows:

Source code

1
2
06.07.0024 09:26:17
6  7  24

And I don't know if
[ http://code.google.com/p/jabacoframework…=svn146&r=81#40 ]
with the "+1" for month, was a bad hack.
For year and day is not such change.

What I want to say is: You have nicely fixed the Monthcalendar for the current Framework. But at first the Framework have to be fixed. Because after the Framework-fix the Monthcalendar again, don't work correct.

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

15

Saturday, July 19th 2014, 12:22pm

Hey there,

well, mainly I fixed all the MouseListener related bugs!
That was what messed up the overall functionality.
The DoubleClick sortout was not placed right.

The return date (lables) does not jump randomly anymore when you select a diferent month than the initial one.

The base for the date is java#util#GregorianCalendar not the Jabaco Date function.
The difference to Jabaco Month() function is that java#util#GregorianCalendar .MONTH is zero based and in the Jabaco framework it starts with 1
So all I did was to compensate this.

Jabaco Source

1
2
3
4
5
6
7
8
9
Public Sub InitDate(thisDate As Date) 
   Dim Cal As GregorianCalendar = Cast(MyCal.clone, java#util#GregorianCalendar)
   Cal.set(Calendar.YEAR, Year(thisDate))
   '############# ERROR!
   Cal.set(Calendar.MONTH, Month(thisDate)-1)
   Cal.set(Calendar.DAY_OF_MONTH, Day(thisDate))
   InitCalendar(Cal)
   bInitEnd = True   
End Sub


I think the Date() bug of the Jabaco Framework is a different matter.
But, I have to admitt I did not even look at the time issue!!!

Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

16

Saturday, July 19th 2014, 4:57pm

by the way, the problem seems to be the Now() function:

Time() ...

Jabaco Source

1
2
3
4
5
6
7
8
Private Sub Command1_Click()
   Dim d As Date
   d = Time()
   MsgBox d & vbNewLine & _
   Day(d) & "  " & _
   Month(d) & "  " & _
   Year(d)
End Sub


returns

Source code

1
2
19.07.2014 09:23:47
19  7  2014


Dani

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

17

Sunday, July 20th 2014, 9:40am

by the way, the problem seems to be the Now() function:
You are right. Thanks to find the buggy function.

Quoted

Time() ...

returns
:)
What you don't know is, that the Time()-function in Jabaco don't exist. You can write "Times()", "Honolulu()" or something other instead and it doing exactly the same. :D

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

18

Sunday, July 20th 2014, 3:14pm

Verrückt!

I wonder how come?

It is on the todo list of DateTime.java though:

Quoted

/*
Function Weekday(Date, [FirstDayOfWeek As VbDayOfWeek = vbSunday])
Function TimeValue(Time As String)
Function TimeSerial(Hour As Integer, Minute As Integer, Second As Integer)
Calendar
Date
Date$
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Time
Time$
TimeSerial
*/



So we just delete the Now() function in the framework and then use our 'generic' Now() function !!! ;)
Just kidding...

OlimilO has changed the Now() function a couple times! I guess it never did work right.


Dani

Rate this thread
WoltLab Burning Board