xcyanx
20-02-09, 17:43
unit DateBox;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, IniFiles, JvComponentBase, JvFormMagnet, JvAppHotKey, DateUtils;
type
TForm4 = class(TForm)
Button1: TButton;
MonthCalendar1: TMonthCalendar;
procedure Button1Click(Sender: TObject);
procedure MonthCalendar1GetMonthInfo(Sender: TObject; Month: Cardinal;
var MonthBoldInfo: Cardinal);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
CardArrayLength: integer;
CardArray: array of Cardinal; //This array will hold the number of the days that we want to bold.
implementation
uses Main;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
var
i : integer; //a simple counter for "for" loops.
tempDate: TDate; //Here we will hold the date that we will read from the ini file.
Ini : TIniFile;
index: string; //an indexer that will point out at the selected event inside our ini file.
temp: Cardinal; //Here we will hold the month that we will read from the ini file.
found: boolean;
LABEL OutOfHere;
begin
Ini := TIniFile.Create(Form1.FileName+Form1.PageControl1.ActivePage.Caption+'.ini'); //create our ini file.
index := 'Event'+IntToStr(Form1.ListBox2.ItemIndex+1);
temp := StrToInt(Ini.ReadString(index, 'Month', '')); //read the month from the ini file.
found := false;
for i := 0 to CardArrayLength-1 do
begin
tempDate := StrToDate(IntToStr(temp)+'/'+IntToStr(CardArray[i])+'/'+Ini.ReadString(index, 'Year', ''));
if MonthCalendar1.Date = tempDate then
begin
found := true;
break;
end;
end;
if found = false then
begin
MessageDlg('Select a valid date for the event.', mtWarning, [mbOk], 0);
goto OutOfHere;
end;
Main.SelectedDate := DateToStr(MonthCalendar1.Date);
ShowMessage('Added date '+Main.SelectedDate+' for the event '+Form1.ListBox2.Items[Form1.ListBox2.ItemIndex]+'.');
Ini.Free;
Close;
OutOfHere:
end;
procedure TForm4.MonthCalendar1GetMonthInfo(Sender: TObject;
Month: Cardinal; var MonthBoldInfo: Cardinal);
var
Ini : TIniFile; //our ini file.
index: string; //an indexer tha will point out to the event inside our ini file.
//CardArray: array of Cardinal;
temp: Cardinal; //here we will hold the month that we read from the ini file.
Days: string; //Days will be hold into a string with the number of each day being next to each other. ex: 011315 = 1 13 15;
i: integer; //a simple counter for "for" loops.
//tempDate: TDate;
begin
Ini := TIniFile.Create(Form1.FileName+Form1.PageControl1.ActivePage.Caption+'.ini');
index := 'Event'+IntToStr(Form1.ListBox2.ItemIndex+1);
temp := StrToInt(Ini.ReadString(index, 'Month', ''));
if Month = temp then //if the month of the calendar is the same with the month that we read from the ini file then keep going.
begin
Days := Ini.ReadString(index, 'Days', ''); //Load our string of Days from the ini file.
CardArrayLength := Length(Days) div 2; //Get the length of the array based on the number of the days read from the ini. for each 2 number we will create a new node on the array.
SetLength(CardArray, CardArrayLength); //Now set the length.
for i := 1 to CardArrayLength do
begin
CardArray[i-1] := StrToInt(Days[2*i-1]+Days[2*i]); //Load into to our array the days from the string.
end;
MonthCalendar1.MinDate := Date; //Set the minimum date to the current date.
if YearOf(MonthCalendar1.Date) = StrToInt(ini.ReadString(index, 'Year', '')) then //if the year of the calendar is the same with the one inside in our ini file then go on.
MonthCalendar1.BoldDays(CardArray, MonthBoldInfo); //Bold the selected days.
end;
Ini.Free; //And free our ini file.
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
MonthCalendar1.CalColors.MonthBackColor := clBlack;
MonthCalendar1.CalColors.TextColor := clRed;
MonthCalendar1.CalColors.TitleBackColor := clWhite;
MonthCalendar1.CalColors.TitleTextColor := clBlack;
MonthCalendar1.CalColors.TrailingTextColor := clWhite;
end;
end.
[Count]
Num=2
[Event1]
Name=Football
[Event2]
Name=Basketball
Cost=500
ImagePath=blank.bmp
Days=021113
Month=10
Year=2010
URL=www.google.com
Καλησπέρα καταρχάς. Τα παραπάνω είναι ένα κομμάτι κώδικα που έχω ένα πρόβλημα και το ini file απο όπου θέλω να διαβάζω κάποια πράματα.
Τώρα έχω το εξής πρόβλημα. Ενω στο PC που κάνω compile το πρόγραμμα τρέχει κανονικά σε όλα τα άλλα PC δεν μου κάνει bolding τις ημερομηνίες. Μπορεί να checkarei κανείς λιγο μήπως μπορεί να βοηθήσει λίγο? xD
Βασικά δεν είναι μόνο με το bolding το πρόβλημα αλλά γενικά και όταν επιλέγω μία ημερομηνία που υπάρχει στο ini file μου βγάζει το error message που του έχω βγάλει να εμφανίζει αν κάποιος επιλέξει μια άκυρη ημερομηνία.
Το checkara λίγο και είδα οτι όταν φορτώνεται η φόρμα για κάποιο λόγο αντί να checkarei και τους 12 μήνες το ημεροφλόγιο καθώς φορτώνεται σταματάει στους πρώτους 6 :s.
Sorry αν δεν βοήθησα πολύ αλλά δεν μπορώ να τα εξηγήσω καλύτερα...είμαι σχετικά νέος στον προγραμματισμό οποτε... :s
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, IniFiles, JvComponentBase, JvFormMagnet, JvAppHotKey, DateUtils;
type
TForm4 = class(TForm)
Button1: TButton;
MonthCalendar1: TMonthCalendar;
procedure Button1Click(Sender: TObject);
procedure MonthCalendar1GetMonthInfo(Sender: TObject; Month: Cardinal;
var MonthBoldInfo: Cardinal);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
CardArrayLength: integer;
CardArray: array of Cardinal; //This array will hold the number of the days that we want to bold.
implementation
uses Main;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
var
i : integer; //a simple counter for "for" loops.
tempDate: TDate; //Here we will hold the date that we will read from the ini file.
Ini : TIniFile;
index: string; //an indexer that will point out at the selected event inside our ini file.
temp: Cardinal; //Here we will hold the month that we will read from the ini file.
found: boolean;
LABEL OutOfHere;
begin
Ini := TIniFile.Create(Form1.FileName+Form1.PageControl1.ActivePage.Caption+'.ini'); //create our ini file.
index := 'Event'+IntToStr(Form1.ListBox2.ItemIndex+1);
temp := StrToInt(Ini.ReadString(index, 'Month', '')); //read the month from the ini file.
found := false;
for i := 0 to CardArrayLength-1 do
begin
tempDate := StrToDate(IntToStr(temp)+'/'+IntToStr(CardArray[i])+'/'+Ini.ReadString(index, 'Year', ''));
if MonthCalendar1.Date = tempDate then
begin
found := true;
break;
end;
end;
if found = false then
begin
MessageDlg('Select a valid date for the event.', mtWarning, [mbOk], 0);
goto OutOfHere;
end;
Main.SelectedDate := DateToStr(MonthCalendar1.Date);
ShowMessage('Added date '+Main.SelectedDate+' for the event '+Form1.ListBox2.Items[Form1.ListBox2.ItemIndex]+'.');
Ini.Free;
Close;
OutOfHere:
end;
procedure TForm4.MonthCalendar1GetMonthInfo(Sender: TObject;
Month: Cardinal; var MonthBoldInfo: Cardinal);
var
Ini : TIniFile; //our ini file.
index: string; //an indexer tha will point out to the event inside our ini file.
//CardArray: array of Cardinal;
temp: Cardinal; //here we will hold the month that we read from the ini file.
Days: string; //Days will be hold into a string with the number of each day being next to each other. ex: 011315 = 1 13 15;
i: integer; //a simple counter for "for" loops.
//tempDate: TDate;
begin
Ini := TIniFile.Create(Form1.FileName+Form1.PageControl1.ActivePage.Caption+'.ini');
index := 'Event'+IntToStr(Form1.ListBox2.ItemIndex+1);
temp := StrToInt(Ini.ReadString(index, 'Month', ''));
if Month = temp then //if the month of the calendar is the same with the month that we read from the ini file then keep going.
begin
Days := Ini.ReadString(index, 'Days', ''); //Load our string of Days from the ini file.
CardArrayLength := Length(Days) div 2; //Get the length of the array based on the number of the days read from the ini. for each 2 number we will create a new node on the array.
SetLength(CardArray, CardArrayLength); //Now set the length.
for i := 1 to CardArrayLength do
begin
CardArray[i-1] := StrToInt(Days[2*i-1]+Days[2*i]); //Load into to our array the days from the string.
end;
MonthCalendar1.MinDate := Date; //Set the minimum date to the current date.
if YearOf(MonthCalendar1.Date) = StrToInt(ini.ReadString(index, 'Year', '')) then //if the year of the calendar is the same with the one inside in our ini file then go on.
MonthCalendar1.BoldDays(CardArray, MonthBoldInfo); //Bold the selected days.
end;
Ini.Free; //And free our ini file.
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
MonthCalendar1.CalColors.MonthBackColor := clBlack;
MonthCalendar1.CalColors.TextColor := clRed;
MonthCalendar1.CalColors.TitleBackColor := clWhite;
MonthCalendar1.CalColors.TitleTextColor := clBlack;
MonthCalendar1.CalColors.TrailingTextColor := clWhite;
end;
end.
[Count]
Num=2
[Event1]
Name=Football
[Event2]
Name=Basketball
Cost=500
ImagePath=blank.bmp
Days=021113
Month=10
Year=2010
URL=www.google.com
Καλησπέρα καταρχάς. Τα παραπάνω είναι ένα κομμάτι κώδικα που έχω ένα πρόβλημα και το ini file απο όπου θέλω να διαβάζω κάποια πράματα.
Τώρα έχω το εξής πρόβλημα. Ενω στο PC που κάνω compile το πρόγραμμα τρέχει κανονικά σε όλα τα άλλα PC δεν μου κάνει bolding τις ημερομηνίες. Μπορεί να checkarei κανείς λιγο μήπως μπορεί να βοηθήσει λίγο? xD
Βασικά δεν είναι μόνο με το bolding το πρόβλημα αλλά γενικά και όταν επιλέγω μία ημερομηνία που υπάρχει στο ini file μου βγάζει το error message που του έχω βγάλει να εμφανίζει αν κάποιος επιλέξει μια άκυρη ημερομηνία.
Το checkara λίγο και είδα οτι όταν φορτώνεται η φόρμα για κάποιο λόγο αντί να checkarei και τους 12 μήνες το ημεροφλόγιο καθώς φορτώνεται σταματάει στους πρώτους 6 :s.
Sorry αν δεν βοήθησα πολύ αλλά δεν μπορώ να τα εξηγήσω καλύτερα...είμαι σχετικά νέος στον προγραμματισμό οποτε... :s