Page 1 of 1

how can I open a Frame from another Frame ?

Posted: Wed Apr 27, 2005 4:06 pm
by deuch
Hello !

as you know i'm a new user and developper .I learn JAVA but actually ,I've to do a project in C++.So...

is somebody can help me to open a Frame from another Frame with a buttonclick ? like :
void prjMicrocobFrm::WxButtonFicheCliClick(wxCommandEvent& event)
{

Fcheclientfrm->Show(TRUE); (that doesn't work )

event.Skip();
}
Thank for help me .

Posted: Wed Apr 27, 2005 7:05 pm
by GianT
Try to use ShowModal() instead of Show(TRUE)

Posted: Wed Apr 27, 2005 7:09 pm
by tbreina
I just tried this and it seems to work.

Just to be sure: you have Fcheclientfrm defined, right?

In my case, I tried added a button to the default frame with this code:

Code: Select all

/*
 * WxButton1Click
 */
void Project1Frm::WxButton1Click(wxCommandEvent& event)
{
	Project1Frm *Fcheclientfrm = new  Project1Frm(NULL);
  
	 Fcheclientfrm->Show(TRUE);
	// insert your code here
	event.Skip();
}
So a new main window is created every time the button is pressed.

NOTE: The event.Skip() is not needed and probably should be removed.

-Tony

Posted: Wed Apr 27, 2005 8:07 pm
by deuch
I did
void prjMicrocobFrm::WxButtonFicheCliClick(wxCommandEvent& event)
{
prjMicrocobFrm *Fcheclientfrm = new prjMicrocobFrm(Null);
Fcheclientfrm->show(true);
//event.Skip();
}

the compiler said :

In member function `void prjMicrocobFrm::WxButtonFicheCliClick(wxCommandEvent&)':
404 C:\PAE\projet Microcoob\prjMicrocobFrm.cpp `Null' undeclared (first use this function)
405 C:\PAE\projet Microcoob\prjMicrocobFrm.cpp 'class prjMicrocobFrm' has no member named 'show'

I try the showmodal too ,but the problem is before

so ...

Posted: Wed Apr 27, 2005 9:00 pm
by krysa
deuch wrote:I did
void prjMicrocobFrm::WxButtonFicheCliClick(wxCommandEvent& event)
{
prjMicrocobFrm *Fcheclientfrm = new prjMicrocobFrm(Null);
Fcheclientfrm->show(true);
//event.Skip();
}

the compiler said :

In member function `void prjMicrocobFrm::WxButtonFicheCliClick(wxCommandEvent&)':
404 C:\PAE\projet Microcoob\prjMicrocobFrm.cpp `Null' undeclared (first use this function)
405 C:\PAE\projet Microcoob\prjMicrocobFrm.cpp 'class prjMicrocobFrm' has no member named 'show'

I try the showmodal too ,but the problem is before

so ...
C++ is case sensitive. You must write 'NULL' instead of 'Null' or you can simply write 0 (zero).
And, the method name is 'Show' (not 'show') so you must change it as well.
Good luck.

Posted: Thu Apr 28, 2005 2:48 pm
by GianT
It seems that ShowModal does not work. I looked my code, and it is Show(TRUE) which is written... :D

If you want to open a new frame and don't want to open the same frame again, you have to change

prjMicrocobFrm *Fcheclientfrm = new prjMicrocobFrm(NULL);

by

NameOfNewFrame *Fcheclientfrm = new NameOfNewFrame (NULL)

Posted: Thu Apr 28, 2005 5:24 pm
by deuch
first ,thanks to you help !

so

I try :
.......Fcheclientfrm(NULL); and (Null) ; but the answer was the same :

Null (or NULL) undeclared .
I retry with Fcheclientfrm(0) ;(zero) as you tald me and it was ok for compilation ..... BUT
it doesn't work when I click the button (GRRRRR !)
or exactly ,I think it re-open the same frame

maybe you know why ?
I'll move my little brain tonight .

Posted: Fri Apr 29, 2005 9:21 am
by tbreina
or exactly ,I think it re-open the same frame
Right. I think what's happening is that when you hit the button you are opening a new window that is exactly the same as the old one. This is because your command is:

Code: Select all

 prjMicrocobFrm *Fcheclientfrm = new prjMicrocobFrm(Null);
This means that you are creating a new frame called Fcheclientfrm, but that frame is of the class prjMicrocobFrm. Since your main frame is of the same class, then both windows look exactly the same. This is a basic concept of object oriented code like C++: you can use the same class over and over again.

If you want to have a different window frame appear when you click the button, then you'll have to declare a different window frame class. For example, go to New->New wxFrame. You see a new window frame be generated. You can modify that frame any way you like it (add controls, colors, etc). Then in your code:

Code: Select all

/*
 * WxButton1Click
 */
void Project1Frm::WxButton1Click(wxCommandEvent& event)
{
        Untitiled1Frm *Fcheclientfrm = new  Untitled1Frm(NULL);
 
        Fcheclientfrm->Show(TRUE);
        // insert your code here
        event.Skip();
}
where Untitled1Frm is the name of your new frame.

-Tony

Posted: Fri Apr 29, 2005 7:35 pm
by deuch
Hi everybody! Me again !
so
it's going better now :my mistake was between the of the class and the frame.wxform ,a confusion .
and I did something : I write an "Include" card ,with the name MySecondFram.h in the "MyFirstFrame.cpp" file ,and finally that work .BUT... there's always a 'BUT' ,when I click it open two or three frames ,and now I know why ,it's ok ?!? I made a third frame witch open with a bitmapButton and i have the same problem :two frame appears .
If someone know why ? and maybe you if I can get informations from a MySql database to wxTextCtrl.
Thanks

Posted: Wed May 04, 2005 7:44 pm
by GianT
You should post this again because I don't really understand what you mean. There seem to be missing words in your post. Plus you say that you now know why it opens 2 or 3 frames, so if you know why (I didn't understand why by the way) how can't you solve the problem? Try posting with a safe language if you want us to help you :wink:

I have this same problem

Posted: Thu May 05, 2005 12:12 pm
by Bundy
I have two identical function - one is executed when user click button in menuBar and second when user click normal button on panel. Its weird - when user click button in menu it shows dialog and disapear when I click Close button but when I click normal button and click close button dialog disapear and shows again. From where is that diffrent?

I resolv my problem like this:

Posted: Thu May 05, 2005 12:22 pm
by Bundy

Code: Select all

void klient::WxButton6Click(wxCommandEvent& event)
{
    static int zn=0;
    if(zn==0)
      {
	    Kal *kal = new Kal(NULL); 
            kal->ShowModal(); 
            //some instructions
	    delete kal;
	    zn++;
      }
    else
      zn--;
    event.Skip();
}

Posted: Fri May 06, 2005 5:49 pm
by deuch
I'm sorry ,I forgot some words and my english is bad .

I'll try to explain :
the problem is when I click the button to call my second frame ,two appears .so I tried to understand ,i read the code , I cleaned some comments etc... bur I didn't change anything .I retried and then all was ok , only one frame appear .Well . so I made another event from a bitmatButton and I had the same problem : When I click it ,two frame appear (a third frame ).
I said before , that I wrote in "myFirstFram.cpp" file ,where there is all Buttons and bitmapbuttons declaration and event ,an "#include MysecondFrame.h" instruction ,and for "mythirdFrame" too .And it work .
so ,I hope you 'll understand ,sorry for my bad english (if you speak french....).
Do you know why two frme appear ?