Question of changing the Panel component Handle

Category: C/C++ -> VCL/Component Author: jufanbao Date: 2009-03-09 17:14:03
 
jufanbao
2009-03-09 17:14:03
Program starts Form of Form1, Form1 has a Panel1, there is a button Button1
have another Form2
clicking Button1 of Form1 when the Panel1 on Form1 to Form2 moves, namely:

this-> Panel1-> Parent = Form2;

then use spy + + view, Panel1 the Handle will change! ! !

you have not encountered this problem? Because I want Panel1's Handle to others, in the above drawing, when the Form2 Panel1 moved up after, handle change, so I can not continue to draw, how do ah?
wq117361305
2009-03-09 17:25:46
use API: SetParent the Panel's Parent to Form2 to:

::SetParent(Panel1->Handle, Form2->Handle);
greenplum
2009-03-09 17:38:17
directly to the panel passed as a parameter in the call Form2 Form2
when
with
TForm2 * f = new TForm2 (Application, this-> Panel1);
f-> Show ();

in Form2 constructor parameters then pass over to add value
public: / / User declarations
/ / __fastcall TForm2 (TComponent * Owner); modified following
; __ fastcall TForm2 (TComponent * Owner, TPanel * p);
TPanel * panel; / / then define a panel

in Form2.cpp in
__fastcall TForm2 :: TForm2 (TComponent * Owner, TPanel * p) ; / / Here the parameters and definitions as
: TForm (Owner)
{
this-> panel = p;
}
Form2 so that you can direct this-> panel operation and reflected in the Form1 panel effect
weiming0621
2009-03-09 17:57:58
handle changes actually normal, most suck with spy + + to see the class name, it has a case to change
especially for. net program.
q70013284
2009-03-09 18:05:04
ccrun positive solution. Thank
:: SetParent ((HWND) this-> Handle, (HWND) ((THIKSOcx *) Owner) -> Panel1-> Handle);
int Width = ((THIKSOcx *) Owner) -> GetPanelWidth ();
int Height ; = ((THIKSOcx *) Owner) -> GetPanelHeight ();
:: SetWindowPos ((HWND) this-> Handle, HWND_TOP, 0,0, Width, Height,
SWP_SHOWWINDOW);