Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help with a appointment calender 2

Status
Not open for further replies.

TonCoronel

Programmer
Dec 1, 2003
37
NL
I have to build a calender where all the appointments of the employees can be seen, for the company I am working for.

Can Someone give me some usefull tips on how to build such a thning? or does someone maybe have a link to some good information ore has ready to go source:D
 
Could you maybe help me out with that? how did you implement it?
 
The schedule control itself is a custom visual object that you add to a Window or Custom Visual UserObject as an olecustomcontrol. To add an olecustomcontrol in PowerBuilder:

1. Choose “OLE Control” from the Insert menu or toolbar button.
2. In the Insert Object dialog select the Insert Control Tab.
3. In the Control Type list select the OLE Control to insert. (GravityBox’s schedule control is named “Scheduler.Schedule”
4. Click the OK button to select the control.
5. Click in the Window or Custom Visual UserObject to place the control.

Each olecustomcontrol has its own unique set of events and functions much like regular PowerBuilder controls. The events and functions available for the schedule control are all defined in the documentation that comes from GravityBox.

We created an extensive set of objects and services to integrate the schedule control with our application framework, but basically we implemented the control using two main objects. The first is a Custom Visual UserObject that contains the schedule control and handles most of the interaction between it and PowerBuilder. This includes functions to:

1. Allow the user to change schedule views and customize it’s appearance.
2. Allow the user to navigate between months. (The schedule control can be set to show as long a time period as you like, but we show one month at a time to restrict the amount of data retrieved and improve performance when populating the schedule.)
3. Pass some of the events from the schedule control to the service object described below.

The second is a non-visual UserObject that handles interfacing the schedule control to a DataStore. This service includes functions to:

1. Take a DataStore (or DataWindow) and use the data in it to populate the schedule control.
2. Take events from the schedule control (mainly the events related to adding, deleting, moving, and resizing items in the schedule control) and update the rows in the DataStore to reflect the changes.

In essence, these two objects create a DataWindow with a “schedule view”.

ONE VERY IMPORTANT NOTE!!!!

If you decide you want to use this control you need to be sure to add the following code to the Destructor (or Close) event of any object or window you place the schedule control in:

Ulong lul_oleptr
// ole_schedule is the olecustomcontrol schedule control.
ole_schedule.GetNativePointer(lul_oleptr)

This is necessary to prevent a GPF from PowerBuilder when your application closes. This is NOT a bug in the GravityBox schedule control. The control is written in Visual Basic 6 and the GPF is caused by a general conflict between PowerBuilder and Visual Basic and the sequence in which they release memory as objects are destroyed.

xsyguy
 
wow tnx alot for your information. I am gonna try to implement it today.
 
Could you help me out a bit?

I want to display only the current week in the calender view how do I do that?
 
Not shure how to edit postst so here is one again.

I solved the above problem. BUT.

I deploy my Powerbuilder application on a server and people have shortcuts to it so they can run the program. But if anyone but me tries to open up the calender the program crashes. I guess this is because they dont have it installed right? I installed it on the server but still it crashes on other computer
 
You are correct. You will have to install the Schedule OCX on any PC that will be using the application. An OCX must be registered with the OS on any PC where it will be used so the OS knows how to manage access to its properties and methods.

xsyguy
 
- Use syncrt.exe to sync source from server to client [so that application runs from client pc & not from server]

- Add code in the open event of your application to register the ocx file.

MM
 
Could you give me a hand with the code to register an OCX?
 
never mind worked it out myself.

the only thing to do now is to get the appointments in the database that will be the tricky part
 
Hmm didnt quite worked the way I wanted it. I regester all the components that are listed in the runtime.txt. But I get an error when someone wants to try to make a new appointment.

this is the error message:
Failed to load control 'ScheduleProperties' from . Your version of may be outdated. make sure you are using the version of the control that was provided with your application.
Index:1

help me!
 
If you want to add a routine to your application to install the schedule OCX I've found it's a little more complicated than just copying the files in the runtime.txt and registering them. First off, you may need more files than are listed in the runtime.txt. Here is the list I came up with:

gbschedule.ocx
gbxmlparse.dll
gbsubclass.ocx
mscomctl.ocx
comdlg32.ocx
msvbvm60.dll
olepro32.dll
oleaut32.dll
asycfilt.dll
Stdole2.tlb
Comcat.dll
Ctl3d32.dll

Other than the GravityBox files, they are all standard Microsoft OCXs or DLLs, but I've found that not all of them are necessarily installed automatically with the OS.

Next, I created Local External Functions in my application for registering all the necessary files:

Function Long RegGbSchedule() Library "GbSchedule.ocx" Alias For "DllRegisterServer"
Function Long RegGbSubclass() Library "GbSubclass.ocx" Alias For "DllRegisterServer"
Function Long RegGbXMLParse() Library "GbXMLParse.dll" Alias For "DllRegisterServer"
Function Long RegMsvbvm60() Library "msvbvm60.dll" Alias For "DllRegisterServer"
Function Long RegMscomct2() Library "mscomct2.ocx" Alias For "DllRegisterServer"

And finally, here is the routine that sets up everything:

Long ll_status
String ls_root, ls_key, ls_value

// Register msvbvm60.dll
IF ll_status = 0 THEN ll_status = RegMsvbvm60()
// Register GbXMLParse.dll
IF ll_status = 0 THEN ll_status = RegGbXMLParse()
// Register GbSubclass.dll
IF ll_status = 0 THEN ll_status = RegGbSubclass()
// Register GbSchedule.ocx
IF ll_status = 0 THEN ll_status = RegGbSchedule()
// Register mscomct2.ocx
IF ll_status = 0 THEN ll_status = RegMscomct2()

// Set licence Registry entries.
ls_root = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\"

ls_key = ls_root + "1B4DDC8D-D289-11D4-A001-00B0D046E802"
ls_value = "mjlqvjkjlqqqrjjjwkpjljrjnkvkkjkjojsk"
IF ll_status = 0 THEN
IF RegistrySet(ls_key, "", RegString!, ls_value) < 0 THEN ll_status = -1
END IF

ls_key = ls_root + "E302D019-5602-11D2-81AA-F42500C10000"
ls_value = "kmifffhfkmimgfofngmfhflmugrlfmffrmug"
IF ll_status = 0 THEN
IF RegistrySet(ls_key, "", RegString!, ls_value) < 0 THEN ll_status = -1
END IF

ls_key = ls_root + "F0520D37-39AD-11D2-81AA-F43500C10000"
ls_value = "mngglgighgngjgngohggtgngpmsmgnggsnvh"
IF ll_status = 0 THEN
IF RegistrySet(ls_key, "", RegString!, ls_value) < 0 THEN ll_status = -1
END IF

RETURN ll_status

GravityBox claims that the licence Registry entries are not necessary for runtime, but for some reason I couldn't get it to work in PowerBuilder without them. Note that you should check the key and licence values on your PC to make sure they are not different for the version you have. Also note that the user must have Administrator privileges for the above code to work.

xsyguy
 
Tnx works great now but still I still could use some help with the database part.

How do you add, change, delete an appointment and put the changes in a datawindow? I dont understand the code they use in the uguide.doc becuase that is VB6 code.
 
To add items to the schedule control you need to do something like this:

DataStore ids_schedule
DateTime ldt_start
Long ll_row, ll_rows, ll_length
String ls_display, ls_key

// ... Retrieve all the schedule items you want to use into the DataStore. Then ...

ll_rows = ids_schedule.RowCount()
FOR ll_row = 1 TO ll_rows
// The key must be a string value, if your IDs are numeric, just convert it to a string.
ls_key = ids_schedule.GetItemString(ll_row, "schedule_id")
ldt_start = ids_schedule.GetItemDateTime(ll_row, "start_dt")
// If you use end dates and times rather than length, you will need to calculate the length
ll_length = <length of appointment in minutes>
ls_display = ids_schedule.GetItemString(ll_row, "description")
// The following are optional depending on whether you want to show resources
// or categories in the schedule.
ls_resource = ""
ls_category = ""
// Add the schedule item.
ole_schedule.Object.ScheduleItems.Add(ls_key, ldt_start, ls_resource, ldt_start, ll_length, ls_display, ls_category)
NEXT

Once the schedule items are added, there are a whole series of events that can be triggered on the schedule control as users move and resize schedule items, such as beforemove, beforeitemresize, beforedelete, aftermove, etc. Each schedule item in the schedule control is an oleobject in PowerBuilder. Some events have an argument that returns a reference to the schedule item itself and some only give an index to a schedule item. To get the schedule OLEObject using the index, do the following:

OLEObject lole_item
lole_item = ole_schedule.Object.ScheduleItems[index]

Once you have the schedule item OLEObject from one of these events, use its properties to add, change, or delete the schedule items in your DataWindow or DataStore. For example:

Long ll_row, ll_length
String ls_key

ls_key = lole_item.Object.Name
ll_row = ids_schedule.Find("schedule_id = ' + ls_key + "'", 1, ids_schedule.RowCount())

// If this is a new item...
IF ll_row = 0 THEN
ll_row = ids_schedule.InsertRow(0)
ids_schedule.SetItem(ll_row, "schedule_id", <new ID>)
// When you create new rows, be sure to update the unique name on the schedule item.
lole_item.Object.Name = ids_schedule.GetItemString(ll_row, "schedule_id")
END IF

// For new or changed items, update the dates and times.
ids_schedule.SetItem(ll_row, "start_dt" = DateTime(lole_item.Object.StartDate)
// Use ll_length set the length in ids_schedule or to calculate the end datetime.
ll_length = Long(lole_item.Object.Length)
// ... etc.

// Or, if the event the schedule item came from was triggered by a delete...
ids_schedule.DeleteRow(ll_row)

Assuming the code above keeps all the rows in the DataStore synchronized with the changes to the schedule items, then all you have to do is update the DataStore to load all the schedule changes into your database:

ids_schedule.Update()
 
How can I het the ID or the index of the scheduleitem that is currently selected? if I use the method .selecteditem it always gives me back the last index and not the one I have selected
 
another question how can I add an apointment with code that is an allday event?
 
As far as I know the SelectedItem property should give you the currently selected item, if one is selected. However we found that there were too many things that can cause an item to become unselected to make it useful as a current item indicator. Instead, we store the schedule item reference argument from the SelectedItemChange event.

As for adding an allday event, use the Add() method to add the schedule item like any other, then set the IsEvent property of the schedule item oleobject returned to TRUE. If you are using allday events you will also need to set the AllowEventHeader property of the schedule olecustomcontrol to TRUE.
 
hmm Now I really have a strange problem. From the one second to another I am getting an error message when I try to load the appointments

it gives me the error message:
incorrect number of parameters to external function add on line 97. I used the excact same code as you do and it worked fine before
 
I solved all of the previuos problems but still have a question. I still cannot select the ID of the appointment I select or add or delete.

I asume I need some kind of code like

OLEObject lole_item
lole_item = ole_schedule.Object.ScheduleItems[index]

But I am not shure what to do with the [index] part
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top