Board index » cppbuilder » MDI Child Float
Saravanan
![]() CBuilder Developer |
Saravanan
![]() CBuilder Developer |
MDI Child Float2005-12-14 09:47:22 PM cppbuilder15 Hi I need a way to float MDI child window as normal Form(fsNormal) and bring it back as MDI child window(fsMDIChild) whenever required. How to do this ? Thanx in Advance, Saravnan A |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2005-12-15 04:29:56 AM
Re:MDI Child Float
"Saravanan" < XXXX@XXXXX.COM >wrote in message
QuoteI need a way to float MDI child window as normal Form(fsNormal) What EXACTLY are you trying to accomplish in the first place? Gambit |
Saravanan
![]() CBuilder Developer |
2005-12-17 02:46:15 PM
Re:MDI Child Float
Hi,
Requirement : I need to implement attach/detach windows for the application. Attach mean displaying a window as child and Dettach meaning displaying the window as seperate application(a icon in the task bar). I should able to toggle between attach and dettach at runtime. Problem : When i change the formstyle from fsChild to fsNormal, Form Handle is getting changed. I need same handle because some other child window will be posting the messages using this handle(Please don't ask me to use Form->handle each time..). I also have some of the third-party control which uses postmessage that should not be affected due to this Form Style Change. I have seen a MFC application which does this. I don't have the source code but i can capture the events in SPY++. Will that help. Regards, Saravanan A "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
{smallsort} |
JD
![]() CBuilder Developer |
2005-12-18 01:41:53 AM
Re:MDI Child Float
"Saravanan" < XXXX@XXXXX.COM >wrote:
Quote
QuoteI need same handle because some other child window will QuoteI also have some of the third-party control which uses Ultimately, I think that you could solve these issues by using AllocateHWnd and using the resulting Handle for everything because that will not be effected when the form's underlying Handle is recreated. For example: private: HWND MyHandle; void __fastcall MyWndProc( TMessage &Message ); public: __fastcall ~TForm2(); //------------------------------------------------------------- __fastcall TForm2::TForm2( TComponent *Owner ) : TForm(Owner) { MyHandle = AllocateHWnd( MyWndProc ); } //------------------------------------------------------------- __fastcall TForm2::~TForm2() { DeallocateHWnd( MyHandle ); } //------------------------------------------------------------- void __fastcall TForm2::MyWndProc( TMessage &Message ) { switch( Message.Msg ) { case WM_SomeThing: .... case WM_SomethingElse: default: Message.Result = DefWindowProc( FHandle, Message.Msg, Message.WParam, Message.LParam ); } } //------------------------------------------------------------- QuoteI have seen a MFC application which does this. I don't have in reverse the mdi child was recreated incorrectly in terms of size and position and I could not prevent or fix it. Then there is the issue of the seperate icon on the taskbar. If you determine that you absolutely can not live with the form's Handle being recreated, you have no choice but to use 2 seperate forms - one fsMDIChild and the other fsNormal - and copy everything over from one to the other. For the fsNormal form, you'll also need to override it's CreateParams methods so that you can apply the WS_EX_APPWINDOW flag to the form's ExStyle. For example: protected: virtual void __fastcall CreateParams( TCreateParams &Params ); //------------------------------------------------------------- void __fastcall TForm2::CreateParams( TCreateParams &Params ) { TForm::CreateParams( Params ); Params.ExStyle |= WS_EX_APPWINDOW; } //------------------------------------------------------------- OTOH, if you can live dynamically changing the FormStyle at runtime, you can use the win32 API's GetWindowLong and SetWindowLong to add and remove WS_EX_MDICHILD and WS_EX_APPWINDOW. ~ JD |
JD
![]() CBuilder Developer |
2005-12-19 06:08:21 PM
Re:MDI Child Float
"saravanan" < XXXX@XXXXX.COM >wrote:
Quote
QuoteThird-party control that we use, have problems if we change QuoteI don't have source code for the third-party contorls. QuoteI have a doubt how MFC application could able to do this QuoteI have mentioned URL for the application that i have seen QuoteIn that software, there is an icon on the caption bar to magic. If your components can't deal with the Handle changing *and* they can't work with AllocateHWnd, then you have no choice but to dynamically allocate and delete objects at runtime. One approach would be to allocate a copy of the components in question, copying their properties, and then deleting the originals. Another approach (as noted in my other post) would be to have 2 duplicate forms with different FormStyle's and the fsNormal form overriding it's CreateParams method (which would be my prefered method). To accomplish this, I would create a wrapper class that would allocate both types of the form and assign the events which all live in the wrapper class. This would keep all of the code centralized - preventing duplicate coding. In addition, if the wrapper class dynamically allocated the form's control's, the only duplicattion would be 2 blank form's with different FormStyle's and one with an overriden method to produce the seperate icon on the taskbar. As for your concern about flickering, that's easily handled by using the correct order of operation. When switching, size and position the new form exactly over the old form *before* you delete the old form. ~ JD |
saravanan
![]() CBuilder Developer |
2005-12-19 06:37:54 PM
Re:MDI Child Float
Hi,
Third-party control that we use, have problems if we change the FormStyle dynamically. I don't have source code for the third-party contorls. I have a doubt how MFC application could able to do this without changing the handle why not with borland. I have mentioned URL for the application that i have seen which has this attach/detaching window feature. www.esignal.com/download/default.asp No User id or password required for that application. Please have a look at the software. In that software, there is an icon on the caption bar to attach/detach windows. It is really smooth and no flickering at all. Please help me in solving this issue. Regards, Saravanan A "JD" < XXXX@XXXXX.COM >wrote in message Quote
|
JD
![]() CBuilder Developer |
2005-12-19 06:48:46 PM
Re:MDI Child Float
"saravanan" < XXXX@XXXXX.COM >wrote:
Quote
who may know of a solution. ~ JD |
saravanan
![]() CBuilder Developer |
2005-12-19 07:50:17 PM
Re:MDI Child Float
Hi,
QuoteI *never* use 3rd party objects unless they come with source. QuoteHow do you know that it's not happening with MFC as well? It's receive all the window messages in SPY++ posted to that window. But in our case(Borland) on changing of FormStyle, i could not able to get any messages in SPY++ after detaching the window. QuoteOne approach would be to allocate a copy of the components in the form, I have a problem in performance. QuoteThat's 22mb and a LONG time to download with dialup just so I Regards, Saravanan A "JD" < XXXX@XXXXX.COM >wrote in message Quote
|
saravanan
![]() CBuilder Developer |
2005-12-19 08:24:27 PM
Re:MDI Child Float
Hi,
Requirement : I need to implement attach/detach windows for the application. Attach mean displaying a window as child and Dettach meaning displaying the window as seperate application(a icon in the task bar). I should able to toggle between attach and dettach at runtime. Problem : When i change the formstyle from fsChild to fsNormal, Form Handle is getting changed. I need same handle because some other child window will be posting the messages using this handle(Please don't ask me to use Form->handle each time..). I also have some of the third-party control which uses postmessage that should not be affected due to this Form Style Change. I have seen a MFC application which does this. I don't have the source code but i can capture the events in SPY++. Will that help. Complete List of conversion between me and JD is available in borland.public.cppbuilder.vcl.components.using (Subject: MDI Child Float) Regards, Saravanan A "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Saravanan
![]() CBuilder Developer |
2005-12-20 05:18:07 PM
Re:MDI Child Float
Hi,
Is Gambit available...Please help me Regards, Saravanan A "JD" < XXXX@XXXXX.COM >wrote in message Quote
|
Saravanan
![]() CBuilder Developer |
2005-12-20 05:18:34 PM
Re:MDI Child Float
Please help me
"saravanan" < XXXX@XXXXX.COM >wrote in message QuoteHi, |
JD
![]() CBuilder Developer |
2005-12-20 05:20:33 PM
Re:MDI Child Float
"Saravanan" < XXXX@XXXXX.COM >wrote:
Quote
reason Gambit wouldn't reply would be if he didn't think that he had anything to add. Quote..Please help me will get you there. ~ JD |
PaoloItaly
![]() CBuilder Developer |
2005-12-21 01:23:17 AM
Re:MDI Child FloatQuoteProblem : When i change the formstyle from fsChild to fsNormal, Form using or not WS_EX_MDICHILD in CreateWindowEx(). I don't think you can't find any other solution that use Form->handle. Regards |
saravanan
![]() CBuilder Developer |
2005-12-21 06:17:09 PM
Re:MDI Child FloatQuoteHow do you know that it's not happening with MFC as well? It's form. How to retain the window position when toggling between attach and detaching windows ? I tried using Application->MainForm->ClientToScreen ( TPoint (Left, Top). But there is small difference in the window position when toggling. I don't know is that because of toolbar. Regards, Saravanan A. "JD" < XXXX@XXXXX.COM >wrote in message Quote
|
JD
![]() CBuilder Developer |
2005-12-21 07:12:44 PM
Re:MDI Child Float
"saravanan" < XXXX@XXXXX.COM >wrote:
Quote
I previousely posted. Use the IDE to design the fsNormal form with all of it's components and events ect. and the fsNormal form will need to have it's CreateParams overridden so that you can add the seperate taskbar icon. You don't *have* to design the fsNormal form to host the components but it will be easier because you can't hide an MDIChild, you have to destroy it. If all of the event code is in the MDIChild and you destroy that class, everything will stop working and you'll get AV's and Exceptions. Then you need to modify ProjectName.cpp to remove the 2 forms so that they are not autocreated and add the wrapper class to the project. Click File | New | Unit and save the unit with an appropriate name for the wrapper. Include the wrapper's header in the main form, dynamically allocate the wrapper in the main form's constructor and delete the the wrapper in the main form's destructor. The rest of your coding goes into the wrapper class. QuoteHow to retain the window position when toggling [...] that as to assign the sfNormal Left/Top. Going from fsNormal to fsMDIChild requires additional logic because fsNormal could be in a position that is incompatable. For example, if the fsNormal form is at 0,0 and the MDIParent is at 100,100, where are you going to put the fsMDIChild? 0,0? QuoteI tried using Application->MainForm->ClientToScreen QuoteBut there is small difference in the window position when ~ JD |