| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
Publicado: Vie 17 Jun, 2016 12:12 pm Asunto: Problema con TMonthCalendar |
|
|
Tengo el formulario que se ve en la imagen. Antes de pinchar en el TRadioGroup inferior hay que seleccionar la fecha de cargo.
Tengo este código.
- En el OnCreate del formulario
| Código: | void __fastcall TfGenRec::FormCreate(TObject *Sender)
{
Button1->Enabled = false;
GroupBox1->Visible = false;
RadioGroup1->Enabled = false;
F_cargo->MinDate = Date();
while (F_cargo->MinDate.DayOfWeek() == 1 || F_cargo->MinDate.DayOfWeek() == 7)
F_cargo->MinDate ++;
nItem = 0;
F_cargo->Date = F_cargo->MinDate;
F_cargo->MaxDate = F_cargo->MinDate;
while (nItem < 3)
{
F_cargo->MaxDate ++;
if (F_cargo->MaxDate.DayOfWeek() == 1 || F_cargo->MaxDate.DayOfWeek() == 7)
continue;
nItem ++;
}
}
//--------------------------------------------------------------------------- |
- En el OnPaint del formulario:
| Código: | void __fastcall TfGenRec::FormPaint(TObject *Sender)
{
F_cargo->Enabled = true;
F_cargo->Date = F_cargo->MinDate;
F_cargo->SetFocus();
}
//--------------------------------------------------------------------------- |
- En OnKeyPress del formulario:
| Código: | void __fastcall TfGenRec::FormKeyPress(TObject *Sender, char &Key)
{
if (Key == 27)
{
Key = 0;
Button2Click(NULL);
return;
}
}
//--------------------------------------------------------------------------- |
- En OnClick del Button2:
| Código: | void __fastcall TfGenRec::Button2Click(TObject *Sender)
{
if (!F_cargo->Enabled)
FormCreate(NULL);
else
this->Close();
return;
}
//--------------------------------------------------------------------------- |
- En OnClick del TMonthCalendar:
| Código: | void __fastcall TfGenRec::F_cargoClick(TObject *Sender)
{
if (F_cargo->Date.DayOfWeek() == 1 || F_cargo->Date.DayOfWeek() == 7)
{
Mensaje(1, "FECHA DE CARGO: " + F_cargo->Date.FormatString("dd/mm/yyyy") + "\n\nNo puede facturarse en días bancarios inhábiles.", "Volver");
F_cargo->Date = Date();
F_cargo->SetFocus();
return;
}
if (Mensaje(2, "Ha seleccionado como fecha de cargo: " + F_cargo->Date.FormatString("dd/mm/yyyy"), "La fecha es correcta\nModificar fecha") == 2)
{
F_cargo->SetFocus();
return;
}
F_cargo->Enabled = false;
RadioGroup1->ItemIndex = -1;
RadioGroup1-Enabled = true;
RadioGroup1->SetFocus();
}
//--------------------------------------------------------------------------- |
El problema es que si ya está habilitado el TRadioGroup y pulso ESC o hago click en el botón Cancelar, pulse donde pulse del calendario no me modifica la fecha y SÓLO me selecciona la fecha mínima, que suele ser la del día del sistema.
Todas las variables que hay por el código (nItem por ejemplo) y funciones (Mensaje(...)) están definidas. _________________ Un saludo
Necesitamos tu ayuda: Envía AI al 27595 (Coste 1,20 euros + IVA) |
|
| Volver arriba |
|
 |
escafandra Master

Registrado: 29 Nov 2007Mensajes: 625Ubicación: Madrid - España
|
Publicado: Mar 21 Jun, 2016 11:51 pm Asunto: |
|
|
No utilices el operador ++ con propiedades, evitarás problemas incomprensibles (las propiedades vienen de delphi)
| Código: |
void __fastcall TForm1::FormCreate(TObject *Sender)
{
F_cargo->Enabled = true;
Button1->Enabled = false;
// GroupBox1->Visible = false;
RadioGroup1->Enabled = false;
F_cargo->MinDate = Date();
F_cargo->MaxDate = F_cargo->MinDate;
while (F_cargo->MinDate.DayOfWeek() == 1 || F_cargo->MinDate.DayOfWeek() == 7)
F_cargo->MinDate = F_cargo->MinDate + 1;
int nItem = 0;
F_cargo->Date = F_cargo->MinDate;
F_cargo->MaxDate = F_cargo->MinDate;
while (nItem < 3)
{
F_cargo->MaxDate = F_cargo->MaxDate + 1;
if (F_cargo->MaxDate.DayOfWeek() == 1 || F_cargo->MaxDate.DayOfWeek() == 7)
continue;
nItem ++;
}
}
|
Saludos. |
|
| Volver arriba |
|
 |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
|
| Volver arriba |
|
 |
|