 |
Club Builder Foro de C++Builder en español
|
| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
gizmo Lt JG

Registrado: 07 Feb 2003Mensajes: 54
|
Publicado: Jue 20 Feb, 2003 11:54 am Asunto: "Cannot create form...." |
|
|
Hola!Me da un error tal que "Cannot create form. No MDI forms are currently active" y se queda colgado. Se trata de un botón ampliar imagen que al pulsarlo(CreateMDIChild(Archivos->FileName) llama a la función Create MDIChild que abre un nuevo formulario que consiste en la imagen ampliada con posibilidad de hacer zoom...
¿Alguien sabe donde puede estar el error? |
|
| Volver arriba |
|
 |
novatilla Invitado
|
Publicado: Jue 20 Feb, 2003 2:03 pm Asunto: Intenta esto |
|
|
A mi me dió una vez uno igual. La cosilla era eliminar en OnClose de el formulario MDIChild creado dinámicamente (el que hace lo del zoom), todos los componentes que crea ese formulario dimámicamente e igualar Action a caFree.
Espero que sirva.  |
|
| Volver arriba |
|
 |
Invitado
|
Publicado: Jue 20 Feb, 2003 5:20 pm Asunto: |
|
|
Hola novatilla. He visto tu contestación pero no la entiendo bien.Yo en el evento OnClose del formulario MDIChild tengo una función llamada FormClose que solo se encarga de cerrar haciendo: Action = caFree;
¿Cómo arreglarlo?Es que me urge un montón y se me queda colgado...Gracias! |
|
| Volver arriba |
|
 |
novatilla Invitado
|
Publicado: Jue 20 Feb, 2003 5:46 pm Asunto: A ver si lo explico mejor |
|
|
Yo tenía un formulario al que le daba a la propiedad FormStyle el valor fsMDIChild en tiempo de diseño. Este formulario, en tiempo de ejecución, creaba en tiempo de ejecución un componente diseñado por mi y derivado de TDrawGrid. En OnClose, o tambien llamado en tiempo de diseño LoQueSeaClose(), tenía que eliminar ese componente y darle a Action el valor de caFree. A ver si lo pillas con el código siguiente, era más o menos esto:
| Código: |
//en miMDIKidForm.cpp
void __fastcall TmiMDIChild::TmiMDIChild(TComponent* Owner)
:TForm(Owner)
{
miTabla=new TmiDrawGridMine(this); //miTabla como miembro público
//en archivo cabecera
}
void __fastcall TmiMDIChild::FormClose(TObject *Sender,
TCloseAction &Action)
{
delete miTabla;
Action=caFree;
}
//-----------------------------------------------------------------------
#include "miMDIKidForm.h"
void __fastcall TmiMDIMainForm::Button1Click(TObject *Sender)
{
TmiMDIChild *nuevoForm;
nuevoForm=new TmiMDIChild(this); //tambien vale Application como
//parámetro
}
|
Espero que haya conseguido ayudarte.  |
|
| Volver arriba |
|
 |
gizmo Lt JG

Registrado: 07 Feb 2003Mensajes: 54
|
Publicado: Vie 21 Feb, 2003 1:06 pm Asunto: |
|
|
Hola de nuevo!He estado probando a hacer lo que me comentaste y sigue sin funcionarme:
| Código: | void __fastcall TMenuprinc::BitBtn1Click(TObject *Sender)
{
CreateMDIChild(Archivos->FileName);
}
|
Dicha función es la siguiente:
| Código: | TMDIChild * __fastcall TMenuprinc::CreateMDIChild(String Name)
{
TMDIChild *Child;
//--- create a new MDI child window ----
Child = new TMDIChild(Application);
Child->Caption = Name;
if (FileExists (Name)) {
Child->Image1->Picture->Bitmap->LoadFromFile (Name);
Child->WHRatio = (float)Child->Image1->Picture->Bitmap->Width / (float)Child->Image1->Picture->Bitmap->Height;
}
return (Child);
} |
Que es la que se encarga de abrir una nueva ventana donde debe ir el zoom de la imagen. El código de la nueva ventana que hace el zoom es:
| Código: | #include <vcl.h>
#pragma hdrstop
#include "ChildWin.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
//---------------------------------------------------------------------
__fastcall TMDIChild::TMDIChild(TComponent *Owner)
: TForm(Owner)
{
Pressed = false;
WHRatio = 0.71;
}
//---------------------------------------------------------------------
void __fastcall TMDIChild::FormClose(TObject *Sender, TCloseAction &Action)
{
delete Child;
Action = caFree;
}
//---------------------------------------------------------------------
void __fastcall TMDIChild::FormResize(TObject *Sender)
{
ShapeForeGround->Height = Panel1->Height - 30;
ShapeForeGround->Width = ShapeForeGround->Height * WHRatio;
ShapeForeGround->Top = 10;
ShapeForeGround->Left = Panel1->Width * 0.5 - ShapeForeGround->Width * 0.5;
ShapeBackGround->Top = ShapeForeGround->Top;
ShapeBackGround->Left = ShapeForeGround->Left;
ShapeBackGround->Width = ShapeForeGround->Width;
ShapeBackGround->Height = ShapeForeGround->Height;
ShapeBackGround->Top += 2;
ShapeBackGround->Left+= 2;
Image1->Top = ShapeForeGround->Top+10;
Image1->Left = ShapeForeGround->Left+10;
Image1->Width = ShapeForeGround->Width-20;
Image1->Height = ShapeForeGround->Height-20;
}
//---------------------------------------------------------------------------
void __fastcall TMDIChild::TB_ZoomInClick(TObject *Sender)
{
ShapeForeGround->Height *= 1.2;
ShapeForeGround->Width *= 1.2;
ShapeForeGround->Top = 10;
ShapeForeGround->Left = Panel1->Width * 0.5 - ShapeForeGround->Width * 0.5;
if (ShapeForeGround->Left < 10) ShapeForeGround->Left = 10;
ShapeBackGround->Top = ShapeForeGround->Top;
ShapeBackGround->Left = ShapeForeGround->Left;
ShapeBackGround->Width = ShapeForeGround->Width;
ShapeBackGround->Height = ShapeForeGround->Height;
ShapeBackGround->Top += 2;
ShapeBackGround->Left+= 2;
Image1->Top = ShapeForeGround->Top+10;
Image1->Left = ShapeForeGround->Left+10;
Image1->Width = ShapeForeGround->Width-20;
Image1->Height = ShapeForeGround->Height-20;
}
//---------------------------------------------------------------------------
void __fastcall TMDIChild::TB_ZoomOutClick(TObject *Sender)
{
ShapeForeGround->Height *= 0.8;
ShapeForeGround->Width *= 0.8;
ShapeForeGround->Top = 10;
ShapeForeGround->Left = Panel1->Width * 0.5 - ShapeForeGround->Width * 0.5;
if (ShapeForeGround->Left < 10) ShapeForeGround->Left = 10;
ShapeBackGround->Top = ShapeForeGround->Top;
ShapeBackGround->Left = ShapeForeGround->Left;
ShapeBackGround->Width = ShapeForeGround->Width;
ShapeBackGround->Height = ShapeForeGround->Height;
ShapeBackGround->Top += 2;
ShapeBackGround->Left+= 2;
Image1->Top = ShapeForeGround->Top+10;
Image1->Left = ShapeForeGround->Left+10;
Image1->Width = ShapeForeGround->Width-20;
Image1->Height = ShapeForeGround->Height-20;
}
//---------------------------------------------------------------------------
void __fastcall TMDIChild::Image1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if (Shift.Contains (ssLeft) && !Pressed) {
Pressed = true;
OldX = X,
OldY = Y;
}
if (!Shift.Contains (ssLeft)) {
Pressed = false;
}
if (Pressed) {
ScrollBox1->ScrollBy (X-OldX, Y-OldY);
}
}
//---------------------------------------------------------------------------
void __fastcall TMDIChild::FormShow(TObject *Sender)
{
FormResize(Sender);
} |
Se sigue colgando aún cerrando la ventana con delete child, ¿por qué ?Todo esto para hacer el zoom de la imagen...Alguien sabe otra forma que me sea más sencilla???Es que me urge bastante...Muchas gracias por tus respuestas novatilla  |
|
| Volver arriba |
|
 |
Invitado
|
Publicado: Vie 21 Feb, 2003 4:56 pm Asunto: Ayuda... |
|
|
AYUDA POR FAVOR!!!  |
|
| Volver arriba |
|
 |
novatilla Invitado
|
Publicado: Vie 21 Feb, 2003 6:50 pm Asunto: otra respuesta de la misma |
|
|
La cosa no es eliminar la ventana desde el formclose de la misma ventana. Lo que tienes que eliminar son los elementos creados dinámicamente por la ventana. Imagina que tengo una ventana padre y una hija. Si yo en la hija creo por ejemplo un TStringList con el operador new en el constructor, o en cualquier método, en el método del formulario padre que hace referencia al método OnClose del formulario hijo, antes de hacer Action=caFree, deberé liberar la memoria asignada del miembro de tipo TStringList. Por ejemplo:
| Código: |
//en MDIChildMine.h , ah, y recuerda quitar el TmiMDIChild *miMDIChild tanto en la cabecera como en el cuerpo que deja builder al hacer un nuevo formulario, y poner el valor adecuado a la propieadad FormStyle
class TmiMDIChild:public TForm
{
...
...
private:
TStringList *listaArchivos;
...
};
//en MDIChildMine.cpp
void __fastcall TmiMDIChild::TmiMDIChild(TComponent* Owner)
:TForm(Owner)
{
listaArchivos=new TStringList();
}
void __fastcall TmiMDIChild::FormClose(TObject *Sender, TCloseAction &Action)
{
delete listaArchivos; //elimino "el miembro"de la clase TmiMDIChild
Action=caFree;
}
//en MDIFormMine.cpp
void __fastcall TmiMDIForm::ButtonClick(TObject *Sender)
{
TmiMDIChild *ventana;
ventana=new TmiMDIChild(this); //o Application
}
|
En cuanto a lo que quieres hacer, yo lo haría con lo que lo haces tú, (TScrollBox, TImage, ...) y le añadiría un TBitmap aparte para que guardara la imagen abierta, y al hacer zoom la pintaría sobre el canvas de Image1 con StretchDraw.
Otra opcion es manejarte con DCs. Esa información la tienes en la ayuda de Builder, la del Win32 Developer's Reference, buscando por Scaling an Image.
Seguiremos intentandolo, que la fuerza te acompañe |
|
| Volver arriba |
|
 |
gizmo Lt JG

Registrado: 07 Feb 2003Mensajes: 54
|
Publicado: Sab 22 Feb, 2003 2:18 pm Asunto: |
|
|
Muchas gracias por tu ayuda!Voy a trabajar este finde en ello. Ya informaré...  |
|
| 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.
|