Главная Новые темы Список тем Задать вопрос Поиск  

Форум "Delphi"


Паскаль, Делфи


 #0 Deep © 24.01.07 16:34:23 - 04.09.07 09:43:09

Как сделать чтобы можно было менять размер панели в рантайме?



так же как в режиме дизайна формы в Делфи. По идее там должен быть простенький код, только вот какой... )) Цитата

 #1 Vlad © 21.08.07 13:44:21

panel1.Left:=
Width
т.п.
 #2 Vlad © 21.08.07 13:44:51

тьфу, случайная тема была :)
 #3 Deep © 21.08.07 14:37:32

> #1   Vlad ©
надо с помощью мышки    
 #4 Mystic © 21.08.07 15:17:21

> надо с помощью мышки

Ну... попробовать перекрыть NC_HITTEST для панели
 #5 Юрий Федоров © 01.09.07 09:11:06

Думаю, NC_HITTEST не прокатит, окно то не с теми параметрами создано :-)
А вот присвоить мышинные события (OnMouseDown, OnMouseMove), и немного вписать логики - действительно получится простенький код в несколько строчек :-)
 #6 Паша © 04.09.07 09:40:24


// unit Delfi_Panel
//
// a form that acts like component it can be dropped on form at design time
// and stays there it has caption bar so it can be moved at runtime ...
//
// version 1.0  2001 Delfi
//
// this component is freeware for non-commercial applications you use it on your own responsibility !
// you may modify this unit only for non-commercial applications
// you may not change the AUTHOR you must leave this comment here !
//
// if you improved this component add your comment after this line

// uses some routines from forms.pas

// IMPORTANT THERE ARE PROBLEMS IF THERE IS AN EDIT OR MEMO ON THIS COMPONENT !!!
// IT HAS SEVERAL PROBLEMS BUT IT IS STABLE

unit Delfi_Panel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  Tbordericons_ = (smsystem_menu, smMaximize, smMinimize);
  Tbordericons = set of Tbordericons_;
  TDelfi_Panel = class(TPanel)
  private
    { Private declarations }
    Fsizable:boolean;
    Fborder:boolean;
    Ftoolwindow:boolean;
    Fbordericons: Tbordericons;
    fIcon : TIcon;
    fonclosequery : TNotifyEvent;
    procedure Setsizable(value:boolean);
    procedure Setborder(value:boolean);
    procedure Settoolwindow(value:boolean);
    procedure Setbordericons(value:Tbordericons);
    procedure SetIcon(Value : TIcon);
    procedure IconChanged(Sender: TObject);
    procedure WMClose(var Message: TWMClose); message WM_CLOSE;
    procedure WMIconEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ICONERASEBKGND;
  protected
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    { Published declarations }
    property sizable:boolean read fsizable write Setsizable;
    property border:boolean read fborder write Setborder;
    property toolwindow:boolean read ftoolwindow write Settoolwindow;
    property Bordericons: Tbordericons read Fbordericons write Setbordericons;
    property Icon : TIcon read fIcon write SetIcon;
    property onclosequery : TNotifyEvent read Fonclosequery write Fonclosequery;
    property ShowHint;
    property OnMouseMove;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnExit;
    property OnEnter;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property TabOrder;
    property TabStop;
    property OnstartDock;
    property OnstartDrag;
    property Visible;
    property Popupmenu;
    property helpcontext;
    property cursor;
    property dragkind;
    property dragmode;
    property dragcursor;

  end;

procedure Register;

implementation

// WM_ERASEBKGND:
// WM_ICONERASEBKGND;


procedure TDelfi_Panel.WMIconEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  SendMessage(Handle, WM_SETICON, 1, ficon.Handle);
end;

{procedure TCustomForm.WMIconEraseBkgnd(var Message: TWMIconEraseBkgnd);
begin
FillRect(Message.DC, ClientRect, Application.MainForm.Brush.Handle)
end; }

procedure TDelfi_Panel.IconChanged(Sender: TObject);
begin
  SendMessage(Handle, WM_SETICON, 1, ficon.Handle);
end;

procedure TDelfi_Panel.SetIcon(Value : Ticon);
begin
  if Value <> fIcon then
  begin
    fIcon.Assign(value);
  end;
end;

procedure TDelfi_Panel.WMClose(var Message: TWMClose);
begin
  if assigned(Fonclosequery)then Fonclosequery(self);
  visible:=false;
end;

procedure TDelfi_Panel.CreateParams(var Params: TCreateParams);
begin
  inherited;

  if fsizable = true then Params.Style:=Params.Style or WS_THICKFRAME;
  if fsizable = false then Params.Style:=Params.Style AND NOT WS_THICKFRAME;

  if fborder = true then Params.Style:=Params.Style or WS_CAPTION;
  if fborder = false then Params.Style:=Params.Style and not WS_CAPTION;

  if (smsystem_menu in Fbordericons) then
    Params.Style:=Params.Style or WS_SYSMENU
  else
  begin
    Params.Style:=Params.Style AND NOT WS_SYSMENU;
  end;

  if (smMaximize in Fbordericons) then
    Params.Style:=Params.Style or WS_MAXIMIZEBOX
  else
    Params.Style:=Params.Style AND NOT WS_MAXIMIZEBOX;

  if (smMinimize in Fbordericons) then
    Params.Style:=Params.Style or WS_GROUP
  else
    Params.Style:=Params.Style AND NOT WS_GROUP;

  if ftoolwindow = true then Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
  if ftoolwindow = false then Params.ExStyle := Params.ExStyle and not WS_EX_TOOLWINDOW;

  SendMessage(Handle, WM_SETICON, 1, ficon.Handle);
end;

 #7 Паша © 04.09.07 09:43:09


constructor TDelfi_Panel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  border:=true;
  bordericons:=bordericons+[smsystem_menu­]+[smMaximize]+[smMinimize];
  sizable:=true;
  //bevelouter:=bvnone;
  borderstyle:=bsSingle;
  width:=188;
  height:=130;
  fIcon:= ticon.create;
  FIcon.OnChange := IconChanged;
end;

destructor TDelfi_Panel.Destroy;
begin
  fIcon.free;
  inherited Destroy;
end;

procedure TDelfi_Panel.Setsizable(Value: boolean);
begin
  Fsizable:=Value;
  RecreateWnd;
end;

procedure TDelfi_Panel.setborder(Value: boolean);
begin
  Fborder:=Value;
  RecreateWnd;
end;

procedure TDelfi_Panel.settoolwindow(Value: boolean);
begin
  Ftoolwindow:=Value;
  RecreateWnd;
  SendMessage(Handle, WM_SETICON, 1, ficon.Handle);
end;

procedure TDelfi_Panel.Setbordericons(value:Tbord­ericons);
begin
  Fbordericons:=value;
  RecreateWnd;
end;

procedure Register;
begin
  RegisterComponents('Утилиты', [TDelfi_Panel]);
end;

end.


такая вот панелька, в рантайме, не помню уже, где дернул. но у не некоторые траблы есть с едитами, не помню уже какие, потому не использовал. а вообще-то можно поглядеть в ВСЛ, как там дизигнтайм обрабатывается и сдублировать.




  • Написать ответ

    Имя: Регистрация HTML?
    smiles смайлики
    Потом перейти в:    
    паутина



      ©  webest.net, 2002-2007  

    top.mail.ru
    » Бесплатный счетчик посещений
    » Рейтинг сайтов