con el link proporcionado por beginner01 la cual le doy las gracias y si era lo que deseaba no he logrado la manera en que cada formulario que yo desee aparezca independientemente en un tapSheet.
Este es el codigo el cual permite poner un boton en el componente PageControl cabe destacar el PageControlCloseButton es el nombre que se le dio al componente lo demas son eventos creados.
Código Delphi
[-]
procedure TfrPrincipal.PageControlCloseButtonDrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
CloseBtnSize: Integer;
pagecontrol: TPageControl;
TabCaption: TPoint;
CloseBtnRect: TRect;
CloseBtnDrawState: Cardinal;
CloseBtnDrawDetails: TThemedElementDetails;
begin
pagecontrol := Control as TPageControl;
if InRange(TabIndex, 0, Length(FCloseButtonsRect) - 1) then
begin
CloseBtnSize := 14;
TabCaption.Y := Rect.Top + 3;
if Active then
begin
CloseBtnRect.Top := Rect.Top + 4;
CloseBtnRect.Right := Rect.Right - 5;
TabCaption.X := Rect.Left + 6;
end
else
begin
CloseBtnRect.Top := Rect.Top + 3;
CloseBtnRect.Right := Rect.Right - 5;
TabCaption.X := Rect.Left + 3;
end;
CloseBtnRect.Bottom := CloseBtnRect.Top + CloseBtnSize;
CloseBtnRect.Left := CloseBtnRect.Right - CloseBtnSize;
FCloseButtonsRect[TabIndex] := CloseBtnRect;
pagecontrol.Canvas.FillRect(Rect);
pagecontrol.Canvas.TextOut(TabCaption.X, TabCaption.Y,
pagecontrol.Pages[TabIndex].Caption);
if not UseThemes then
begin
if (FCloseButtonMouseDownIndex = TabIndex) and FCloseButtonShowPushed then
CloseBtnDrawState := DFCS_CAPTIONCLOSE + DFCS_PUSHED
else
CloseBtnDrawState := DFCS_CAPTIONCLOSE;
Windows.DrawFrameControl(pagecontrol.Canvas.Handle,
FCloseButtonsRect[TabIndex], DFC_CAPTION, CloseBtnDrawState);
end
else
begin
Dec(FCloseButtonsRect[TabIndex].Left);
if (FCloseButtonMouseDownIndex = TabIndex) and FCloseButtonShowPushed then
CloseBtnDrawDetails := ThemeServices.GetElementDetails
(twCloseButtonPushed)
else
CloseBtnDrawDetails := ThemeServices.GetElementDetails
(twCloseButtonNormal);
ThemeServices.DrawElement(pagecontrol.Canvas.Handle, CloseBtnDrawDetails,
FCloseButtonsRect[TabIndex]);
end;
end;
end;
procedure TfrPrincipal.PageControlCloseButtonMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
I: Integer;
pagecontrol: TPageControl;
begin
pagecontrol := Sender as TPageControl;
if Button = mbLeft then
begin
for I := 0 to Length(FCloseButtonsRect) - 1 do
begin
if PtInRect(FCloseButtonsRect[i], Point(X, Y)) then
begin
FCloseButtonMouseDownIndex := I;
FCloseButtonShowPushed := True;
pagecontrol.Repaint;
end;
end;
end;
end;
procedure TfrPrincipal.PageControlCloseButtonMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
pagecontrol: TPageControl;
Inside: Boolean;
begin
pagecontrol := Sender as TPageControl;
if (ssLeft in Shift) and (FCloseButtonMouseDownIndex >= 0) then
begin
Inside := PtInRect(FCloseButtonsRect[FCloseButtonMouseDownIndex],
Point(X, Y));
if FCloseButtonShowPushed <> Inside then
begin
FCloseButtonShowPushed := Inside;
pagecontrol.Repaint;
end;
end;
end;
procedure TfrPrincipal.PageControlCloseButtonMouseLeave(Sender: TObject);
var
pagecontrol: TPageControl;
begin
pagecontrol := Sender as TPageControl;
FCloseButtonShowPushed := False;
pagecontrol.Repaint;
end;
procedure TfrPrincipal.PageControlCloseButtonMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
pagecontrol: TPageControl;
begin
pagecontrol := Sender as TPageControl;
if (Button = mbLeft) and (FCloseButtonMouseDownIndex >= 0) then
begin
if PtInRect(FCloseButtonsRect[FCloseButtonMouseDownIndex], Point(X, Y)) then
begin
PageControlCloseButton.ActivePage.Free;
FCloseButtonMouseDownIndex := -1;
pagecontrol.Repaint;
frmCliente.Close;
end;
end;
end;
el asunto es que yo creo un formulario utilizando el pagecontrol como parent de mi formulario sin embargo si llamo a otro formulario se pone en cima del anterior. y al final si cambio de pestaña se borran. pongo mi ejemplo para que alguien me de una posible solución a como manejar este comportamiento indeseado
Saludos
novato_erick
nota: adjunto archivo.