 |
Club Builder Foro de C++Builder en español
|
| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
Publicado: Mie 03 Ago, 2011 12:22 pm Asunto: MessageBox personalizado |
|
|
Buenas a todos. Estoy tratando de crearme una especia de MessageBox personalizado y para ello tengo un formulario que sólo contiene un TImage, un Tlabel, un TActionList y un TImageList.
El código que hay en este formulario es lo imprescindible. Como máximo va a recibir tres botones:
| Código: | //---------------------------------------------------------------------------
#include <vcl>
#pragma hdrstop
#include "Mensaje.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfMensaje *fMensaje;
//---------------------------------------------------------------------------
__fastcall TfMensaje::TfMensaje(TComponent* Owner)
: TForm(Owner)
{
Caption = Application->Title;
}
//---------------------------------------------------------------------------
void __fastcall TfMensaje::Action1Execute(TObject *Sender)
{
fMensaje->Tag = 1;
fMensaje->Close();
return;
}
//---------------------------------------------------------------------------
void __fastcall TfMensaje::Action2Execute(TObject *Sender)
{
fMensaje->Tag = 2;
fMensaje->Close();
return;
}
//---------------------------------------------------------------------------
void __fastcall TfMensaje::Action3Execute(TObject *Sender)
{
fMensaje->Tag = 3;
fMensaje->Close();
return;
}
//---------------------------------------------------------------------------
void __fastcall TfMensaje::FormActivate(TObject *Sender)
{
MessageBeep(MB_ICONEXCLAMATION);
}
//--------------------------------------------------------------------------- |
Y para montar el formulario uso este código:
| Código: | int Mensaje2(int Icono, AnsiString Mensaje, AnsiString Botones)
{
int nButWidth, nWidth;
TStringList *slBoton = new TStringList();
Application->CreateForm(__classid(TfMensaje), &fMensaje);
if (Icono != 0)
fMensaje->ImageList->GetBitmap(Icono, fMensaje->Imagen->Picture->Bitmap);
nButWidth = 15;
slBoton->Clear();
slBoton->Text = Botones;
for (int nItem = 0; nItem < slBoton->Count; nItem ++)
{
fMensaje->Label1->Caption = slBoton->Strings[nItem];
fMensaje->Label1->Refresh();
TButton *Boton = new TButton(fMensaje);
Boton->Parent = fMensaje;
Boton->Action = fMensaje->ActionList->Actions[nItem];
Boton->Caption = slBoton->Strings[nItem];
Boton->Enabled = true;
Boton->Height = 25;
Boton->Left = nButWidth;
Boton->Name = "Button" + FormatFloat("0", nItem + 1);
Boton->Top = max(fMensaje->Label1->Height, fMensaje->Imagen->Height) + 25;
Boton->Visible = true;
Boton->Width = fMensaje->Label1->Width + 15;
nButWidth += Boton->Width + 10;
}
nButWidth += 10;
nWidth = 0;
fMensaje->Label1->Caption = Mensaje;
nWidth = fMensaje->Label1->Left + fMensaje->Label1->Width + 20;
if (nButWidth > nWidth)
nWidth = nButWidth;
fMensaje->Width = nWidth;
fMensaje->Height = max(fMensaje->Label1->Height, fMensaje->Imagen->Height) + 90;
fMensaje->Left = (Screen->Width - fMensaje->Width) / 2;
fMensaje->Top = (Screen->Height - fMensaje->Height) / 2;
fMensaje->Refresh();
fMensaje->ShowModal();
nWidth = fMensaje->Tag;
delete fMensaje;
return nWidth;
}
//--------------------------------------------------------------------------- |
El problema que tengo es que siempre me aparecen los botones deshabilitados.
¿Qué hago mal? _________________ 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: Mie 03 Ago, 2011 5:53 pm Asunto: |
|
|
Algo mas tienes en tu código o en el diseño de los formularios, pues a mi me funciona bien.
Saludos. |
|
| Volver arriba |
|
 |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
Publicado: Jue 04 Ago, 2011 8:00 am Asunto: |
|
|
| escafandra escribió: | Algo mas tienes en tu código o en el diseño de los formularios, pues a mi me funciona bien.
Saludos. |
Tienes razón. He vuelto a poner un formulario nuevo y ahora me funciona bien. Gracias. _________________ Un saludo
Necesitamos tu ayuda: Envía AI al 27595 (Coste 1,20 euros + IVA) |
|
| Volver arriba |
|
 |
|
|
No puedes publicar temas nuevos en este foro No puedes responder a temas en este foro No puedes editar tus mensajes en este foro No puedes borrar tus mensajes en este foro No puedes votar en las encuestas de este foro
|
© 2002–2026 Club Builder · Funciona con phpBB.
|