Board index » cppbuilder » Programaticly Docking a Window

Programaticly Docking a Window

    I have created a panel and set it Dock Site property to True and set
it's AutoSize propertiy to true.  I have added code to make my toolbar
window dock and undock the way I'd like too I am trying to save my tool
bar's state. And I would like to Programaticly reposition the window where
the user left it last. If the user has docked it I want it Docked. I also
want the default position to be Docked.

    How do you programaticly Dock a Window to a control?

    Likewise, I have a widow docked to a control. How do I Undock it
programaticly?

 

Re:Programaticly Docking a Window


Hi Rodney --

Quote
> How do you programaticly Dock a Window to a control?

You use the TControl::ManualDock() member function...

__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
   ToolBar1->ManualDock(Panel1, NULL, alClient);

Quote
}
> Likewise, I have a widow docked to a control. How do I Undock
> it programaticly?

You use the TControl::ManualFloat() member function...

void __fastcall TForm1::FloatButtonClick(TObject *Sender)
{
   POINT PMouse;
   GetCursorPos(&PMouse);

   RECT RFloat = {
       PMouse.x,
       PMouse.y,
       PMouse.x + Panel1->Width,
       PMouse.y + Panel1->Height
       };
   ToolBar1->ManualFloat(RFloat);

Quote
}

HTH.

--
Damon Chandler (TeamB)
http://bcbcaq.freeservers.com

Other Threads