Модераторы: volvo877, Snowy, MetalFan

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Delphi - 8. Первые впечатления. Шаг вперёд - 2 шага назад 
:(
    Опции темы
mr.DUDA
Дата 14.1.2004, 00:50 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


3D-маньяк
****


Профиль
Группа: Экс. модератор
Сообщений: 8244
Регистрация: 27.7.2003
Где: город-герой Минск

Репутация: нет
Всего: 232



Цитата
Допустим, при установке делфи вносит в NET свои компоненты

Возможно ли такое ? Имхо, нет - нигде не написано, что стандартные либы .NET расширяемы.

Вообще, .NET "славится" тем, что вместе с Framework идет сотня стандартных библиотек, в которых "есть всё", поэтому для переноса кода с одной платформы на другую достаточно не выходить за рамки стандартных либ.

Это сообщение отредактировал(а) mr.DUDA - 14.1.2004, 00:50


--------------------
user posted image
PM MAIL WWW   Вверх
Sardar
Дата 14.1.2004, 00:51 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бегун
****


Профиль
Группа: Модератор
Сообщений: 6986
Регистрация: 19.4.2002
Где: Нидерланды, Groni ngen

Репутация: нет
Всего: 317



2foRaver, посмотрел в eMule уже у кучи народа есть, скачается быстро.


--------------------
 Опыт - сын ошибок трудных  © А. С. Пушкин
 Процесс написания своего велосипеда повышает профессиональный уровень программиста. © Opik
 Оценить мои качества можно тут.
PM   Вверх
Vit
Дата 14.1.2004, 00:51 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



2 dr.ZmeY - разобрался, там run-time библиотек до хрени, всего целиком метров до 20
потянут. Без них, понятное дело, ничего работать не будет, даже с одними кнопками.


--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
stab
Дата 14.1.2004, 00:52 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Экс. модератор
Сообщений: 1839
Регистрация: 1.1.2003

Репутация: нет
Всего: 48



Еще вопросы. От какого класса наследуются события? Есть ли понятие делегата? Есть ли исходники борландовских модулей (System, SysUtils, Forms, ... сейчас, конечно, это все несколько по другому называется)? Если есть выложи, пожалуйста, на всеобщее обозрение, хоть посмотрим как это выглядит.

з.ы. Простите за огромное кол-во вопросов, но уж очень интересно smile.gif


--------------------
6, 6, 6 - the number of the beast.
PM MAIL WWW   Вверх
Vit
Дата 14.1.2004, 00:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Цитата
Возможно ли такое ? Имхо, нет - нигде не написано, что стандартные либы .NET расширяемы.



Конечно возможно, а как же иначе?

Цитата
Вообще, .NET "славится" тем, что вместе с Framework идет сотня стандартных библиотек, в которых "есть всё"


Ну знаешь, такого не бывает. Я вот например подключил утюг к компьютеру, теперь мне нужен
объект для работы с этим утюгом, я его должен иметь возможность включить.

Так не может быть, никогда никаких библиотек не хватит. .net точно расширяемая, иначе она 100%
обречена на вымирание. Это как сказать писателю - мы для Вас составили все нужные предложения -
Вам остаётся только работать... Эволюция языков идёт по пути инкапсуляции, если система не
поддерживает инкапсуляцию создаваемых продуктов в виде модулей, классов, объектов то
это не шаг назад - это скачёк назад на 20 лет...





--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
stab
Дата 14.1.2004, 00:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Экс. модератор
Сообщений: 1839
Регистрация: 1.1.2003

Репутация: нет
Всего: 48



Цитата
... и будут ли они, даже со стандартными "кнопками" работать на системах без NET?

Конечно, нет.


--------------------
6, 6, 6 - the number of the beast.
PM MAIL WWW   Вверх
Vit
Дата 14.1.2004, 00:58 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



2 cully - часа через 2 прийду домой, посмотрю внимательнее, попробую ответить на все вопросы,
пока пожалуйста сформулируйте конкретно, что хотите узнать...


--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Vit
Дата 14.1.2004, 01:00 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Код
и будут ли они, даже со стандартными "кнопками" работать на системах без NET?


Нет, даже если там кроме begin..end ничего нет .net framework абсолютно необходим для
запуска.


--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
foRaver
Дата 14.1.2004, 01:43 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 561
Регистрация: 6.7.2003
Где: Düsseldorf

Репутация: нет
Всего: 3



Sardar, чем же так качать, чтобы быстро через eMule получилосb???
Ладно, подожду пока на сайте Борланда появится... с FTP быстрее качает smile.gif
PM MAIL WWW ICQ YIM   Вверх
Vit
Дата 14.1.2004, 02:04 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Отвечаю на вопросы по очереди:

Цитата
Vit, скажи чем отличаются VCL Forms Application и Windows Forms Application.



Windows Forms Application - типичный .net, компоненты есть только те что есть в классическом .net.

Вот как выглядит автосгенерированный модуль формы с одной кнопкой:

Код
unit WinForm1;

interface

uses
 System.Drawing, System.Collections, System.ComponentModel,
 System.Windows.Forms, System.Data;

type
 TWinForm1 = class(System.Windows.Forms.Form)
 {$REGION 'Designer Managed Code'}
 strict private
   /// <summary>
   /// Required designer variable.
   /// </summary>
   Components: System.ComponentModel.Container;
   Button1: System.Windows.Forms.Button;
   /// <summary>
   /// Required method for Designer support - do not modify
   /// the contents of this method with the code editor.
   /// </summary>
   procedure InitializeComponent;
   procedure Button1_Click(sender: System.Object; e: System.EventArgs);
 {$ENDREGION}
 strict protected
   /// <summary>
   /// Clean up any resources being used.
   /// </summary>
   procedure Dispose(Disposing: Boolean); override;
 private
   { Private Declarations }
 public
   constructor Create;
 end;

 [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm1))]

implementation

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm1.InitializeComponent;
begin
 Self.Button1 := System.Windows.Forms.Button.Create;
 Self.SuspendLayout;
 //
 // Button1
 //
 Self.Button1.Location := System.Drawing.Point.Create(104, 144);
 Self.Button1.Name := 'Button1';
 Self.Button1.Size := System.Drawing.Size.Create(104, 48);
 Self.Button1.TabIndex := 0;
 Self.Button1.Text := 'Button1';
 Include(Self.Button1.Click, Self.Button1_Click);
 //
 // TWinForm1
 //
 Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
 Self.ClientSize := System.Drawing.Size.Create(292, 273);
 Self.Controls.Add(Self.Button1);
 Self.Name := 'TWinForm1';
 Self.Text := 'WinForm1';
 Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm1.Dispose(Disposing: Boolean);
begin
 if Disposing then
 begin
   if Components <> nil then
     Components.Dispose();
 end;
 inherited Dispose(Disposing);
end;

constructor TWinForm1.Create;
begin
 inherited Create;
 //
 // Required for Windows Form Designer support
 //
 InitializeComponent;
 //
 // TODO: Add any constructor code after InitializeComponent call
 //
end;

procedure TWinForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
 Close;
end;

end.



--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Vit
Дата 14.1.2004, 02:08 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



VCL Forms Application - это приложение VCL - набор компонентов для него точно такой же как для Дельфи 7.
Все функции, классы, методы и т.п. от VCL доступны. Единственное различие от Дельфи 7, как я понял,
только в том, что сама VCL базируется не на вызовах WinAPI, а на соответствующих .net классах. Для программиста
переделывание классического дельфовского приложения из Дельфи 7 в Дельфи 8, как я понимаю, затруднений не
составит.

Вот пример аналогичного кода - модуль формы с кнопкой.

Код
unit Unit3;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, System.ComponentModel, Borland.Vcl.StdCtrls;

type
 TForm3 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form3: TForm3;

implementation

{$R *.nfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
 Close;
end;

end.



--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Vit
Дата 14.1.2004, 02:11 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Цитата
От какого класса наследуются события?


С разгону и не поймёшь. Как-то сделано не так как было до сих пор.
Вот как выглядит декларация класса (для VCL):

Код
 TCustomForm = class(TScrollingWinControl, IMDIForm)
 private
   FActiveControl: TWinControl;
   FFocusedControl: TWinControl;
   FBorderIcons: TBorderIcons;
   FBorderStyle: TFormBorderStyle;
   FSizeChanging: Boolean;
   FWindowState: TWindowState;
   FShowAction: TShowAction;
   FKeyPreview: Boolean;
   FActive: Boolean;
   FFormStyle: TFormStyle;
   FPosition: TPosition;
   FDefaultMonitor: TDefaultMonitor;
   FTileMode: TTileMode;
   FDropTarget: Boolean;
   FPrintScale: TPrintScale;
   FCanvas: TControlCanvas;
   FHelpFile: string;
   FIcon: TIcon;
   FInCMParentBiDiModeChanged: Boolean;
   FMenu: TMainMenu;
   FModalResult: TModalResult;
   FDesigner: IDesignerHook;
   FClientHandle: THWndWrapper;
   FWindowMenu: TMenuItem;
   FPixelsPerInch: Integer;
   FObjectMenuItem: TMenuItem;
   FOleForm: IOleForm;
   FClientWidth: Integer;
   FClientHeight: Integer;
   FTextHeight: Integer;
   FDefClientProc: IntPtr;
   FActiveOleControl: TWinControl;
   FSavedBorderStyle: TFormBorderStyle;
   FOnActivate: TNotifyEvent;
   FOnClose: TCloseEvent;
   FOnCloseQuery: TCloseQueryEvent;
   FOnDeactivate: TNotifyEvent;
   FOnHelp: THelpEvent;
   FOnHide: TNotifyEvent;
   FOnPaint: TNotifyEvent;
   FOnShortCut: TShortCutEvent;
   FOnShow: TNotifyEvent;
   FOnCreate: TNotifyEvent;
   FOnDestroy: TNotifyEvent;
   FAlphaBlend: Boolean;
   FAlphaBlendValue: Byte;
   FPopupChildren: TList;
   FPopupMode: TPopupMode;
   FPopupParent: TCustomForm;
   FRecreateChildren: TList;
   FPopupWnds: TPopupWndArray;
   FInternalPopupParent: TCustomForm;
   FInternalPopupParentWnd: HWND;
   FScreenSnap: Boolean;
   FSnapBuffer: Integer;
   FTransparentColor: Boolean;
   FTransparentColorValue: TColor;
   procedure RefreshMDIMenu;
   procedure ClientWndProc(var Message: TMessage);
   function GetCanvas: TCanvas;
   function GetClientHandle: HWND;
   function GetFormStyle: TFormStyle;
   function GetIconHandle: HICON;
   function GetMonitor: TMonitor;
   function GetPixelsPerInch: Integer;
   function GetPopupChildren: TList;
   function GetRecreateChildren: TList;
   function GetScaled: Boolean;
   function GetTextHeight: Integer;
   procedure IconChanged(Sender: TObject);
   function IsAutoScrollStored: Boolean;
   function IsClientSizeStored: Boolean;
   function IsForm: Boolean;
   function IsFormSizeStored: Boolean;
   function IsIconStored: Boolean;
   procedure MergeMenu(MergeState: Boolean);
   procedure ReadIgnoreFontProperty(Reader: TReader);
   procedure IgnoreIdent(Reader: TReader);
   procedure ReadTextHeight(Reader: TReader);
   procedure SetActive(Value: Boolean);
   procedure SetActiveControl(Control: TWinControl);
   procedure SetBorderIcons(Value: TBorderIcons);
   procedure SetBorderStyle(Value: TFormBorderStyle);
   procedure SetClientHeight(Value: Integer);
   procedure SetClientWidth(Value: Integer);
   procedure SetDesigner(ADesigner: IDesignerHook);
   procedure SetFormStyle(Value: TFormStyle);
   procedure SetIcon(Value: TIcon);
   procedure SetMenu(Value: TMainMenu);
   procedure SetPixelsPerInch(Value: Integer);
   procedure SetPosition(Value: TPosition);
   procedure SetPopupMode(Value: TPopupMode);
   procedure SetPopupParent(Value: TCustomForm);
   procedure SetScaled(Value: Boolean);
   procedure SetVisible(Value: Boolean);
   procedure SetWindowFocus;
   procedure SetWindowMenu(Value: TMenuItem);
   procedure SetObjectMenuItem(Value: TMenuItem);
   procedure SetWindowState(Value: TWindowState);
   procedure SetWindowToMonitor;
   procedure WritePixelsPerInch(Writer: TWriter);
   procedure WriteTextHeight(Writer: TWriter);
   function NormalColor: TColor;
 public
   procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
   procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
   procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
   procedure WMIconEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ICONERASEBKGND;
   procedure WMQueryDragIcon(var Message: TWMQueryDragIcon); message WM_QUERYDRAGICON;
   procedure WMNCCreate(var Message: TWMNCCreate); message WM_NCCREATE;
   procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
   procedure WMNCLButtonDown(var Message: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
   procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY;
   procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
   procedure WMInitMenuPopup(var Message: TWMInitMenuPopup); message WM_INITMENUPOPUP;
   procedure WMMenuChar(var Message: TWMMenuChar); message WM_MENUCHAR;
   procedure WMMenuSelect(var Message: TWMMenuSelect); message WM_MENUSELECT;
   procedure WMActivate(var Message: TWMActivate); message WM_ACTIVATE;
   procedure WMClose(var Message: TWMClose); message WM_CLOSE;
   procedure WMQueryEndSession(var Message: TWMQueryEndSession); message WM_QUERYENDSESSION;
   procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
   procedure WMShowWindow(var Message: TWMShowWindow); message WM_SHOWWINDOW;
   procedure WMMDIActivate(var Message: TWMMDIActivate); message WM_MDIACTIVATE;
   procedure WMNextDlgCtl(var Message: TWMNextDlgCtl); message WM_NEXTDLGCTL;
   procedure WMEnterMenuLoop(var Message: TMessage); message WM_ENTERMENULOOP;
   procedure WMHelp(var Message: TWMHelp); message WM_HELP;
   procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
   procedure WMSettingChange(var Message: TMessage); message WM_SETTINGCHANGE;
   procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
   procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
   procedure CMActivate(var Message: TCMActivate); message CM_ACTIVATE;
   procedure CMAppSysCommand(var Message: TMessage); message CM_APPSYSCOMMAND;
   procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
   procedure CMDeactivate(var Message: TCMDeactivate); message CM_DEACTIVATE;
   procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
   procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
   procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
   procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
   procedure CMMenuChanged(var Message: TMessage); message CM_MENUCHANGED;
   procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
   procedure CMIconChanged(var Message: TMessage); message CM_ICONCHANGED;
   procedure CMRelease(var Message: TMessage); message CM_RELEASE;
   procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
   procedure CMUIActivate(var Message); message CM_UIACTIVATE;
   procedure CMParentBiDiModeChanged(var Message: TMessage); message CM_PARENTBIDIMODECHANGED;
   procedure CMParentFontChanged(var Message: TCMParentFontChanged); message CM_PARENTFONTCHANGED;
   procedure CMPopupHwndDestroy(var Message: TCMPopupHWndDestroy); message CM_POPUPHWNDDESTROY;
   procedure CMIsShortCut(var Message: TWMKey); message CM_ISSHORTCUT;
   procedure CMUpdateActions(var Message: TMessage); message CM_UPDATEACTIONS;
 private
   function ActionExecute(Action: TBasicAction): Boolean;
   function ActionUpdate(Action: TBasicAction): Boolean;
   procedure SetLayeredAttribs;
   procedure SetAlphaBlend(const Value: Boolean);
   procedure SetAlphaBlendValue(const Value: Byte);
   procedure SetTransparentColor(const Value: Boolean);
   procedure SetTransparentColorValue(const Value: TColor);
   procedure InitAlphaBlending(var Params: TCreateParams);
 protected
   FFormState: TFormState;
   procedure Activate; virtual;
   procedure ActiveChanged; virtual;
   procedure AlignControls(AControl: TControl; var Rect: TRect); override;
   procedure BeginAutoDrag; override;
   procedure ChangeScale(M, D: Integer); override;
   procedure CloseModal;
   procedure CreateParams(var Params: TCreateParams); override;
   procedure CreateWindowHandle(const Params: TCreateParams); override;
   procedure CreateWnd; override;
   procedure Deactivate; virtual;
   procedure DefineProperties(Filer: TFiler); override;
   procedure DestroyHandle; override;
   procedure DestroyWindowHandle; override;
   procedure DoClose(var Action: TCloseAction); virtual;
   procedure DoCreate; virtual;
   procedure DoDestroy; virtual;
   procedure DoHide; virtual;
   procedure DoShow; virtual;
   function GetClientRect: TRect; override;
   function GetFloating: Boolean; override;
   function GetOwnerWindow: HWND; virtual;
   function HandleCreateException: Boolean; virtual;
   procedure Loaded; override;
   procedure Notification(AComponent: TComponent;
     Operation: TOperation); override;
   procedure Paint; virtual;
   procedure PaintWindow(DC: HDC); override;
   function PaletteChanged(Foreground: Boolean): Boolean; override;
   procedure ReadState(Reader: TReader); override;
   procedure RequestAlign; override;
   procedure SetChildOrder(Child: TComponent; Order: Integer); override;
   procedure SetParentBiDiMode(Value: Boolean); override;
   procedure DoDock(NewDockSite: TWinControl; var ARect: TRect); override;
   procedure SetParent(AParent: TWinControl); override;
   procedure UpdateActions; virtual;
   procedure UpdateWindowState;
   procedure ValidateRename(AComponent: TComponent;
     const CurName, NewName: string); override;
   procedure VisibleChanging; override;
   procedure WndProc(var Message: TMessage); override;
   procedure Resizing(State: TWindowState); override;
   function get_ActiveMDIChild: TForm;
   function get_MDIChildCount: Integer;
   function get_MDIChildren(I: Integer): TForm;
   property ActiveMDIChild: TForm read get_ActiveMDIChild;
   property AlphaBlend: Boolean read FAlphaBlend write SetAlphaBlend;
   property AlphaBlendValue: Byte read FAlphaBlendValue write SetAlphaBlendValue;
   property BorderIcons: TBorderIcons read FBorderIcons write SetBorderIcons stored IsForm
     default [biSystemMenu, biMinimize, biMaximize];
   property AutoScroll stored IsAutoScrollStored;
   property ClientHandle: HWND read GetClientHandle;
   property ClientHeight write SetClientHeight stored IsClientSizeStored;
   property ClientWidth write SetClientWidth stored IsClientSizeStored;
   property TransparentColor: Boolean read FTransparentColor write SetTransparentColor;
   property TransparentColorValue: TColor read FTransparentColorValue write SetTransparentColorValue;
   property Ctl3D default True;
   property DefaultMonitor: TDefaultMonitor read FDefaultMonitor write FDefaultMonitor
     stored IsForm default dmActiveForm;
   property FormStyle: TFormStyle read GetFormStyle write SetFormStyle
     stored IsForm default fsNormal;
   property Height stored IsFormSizeStored;
   property HorzScrollBar stored IsForm;
   property Icon: TIcon read FIcon write SetIcon stored IsIconStored;
   property MDIChildCount: Integer read get_MDIChildCount;
   property MDIChildren[I: Integer]: TForm read get_MDIChildren;
   property ObjectMenuItem: TMenuItem read FObjectMenuItem write SetObjectMenuItem
     stored IsForm;
   property PixelsPerInch: Integer read GetPixelsPerInch write SetPixelsPerInch
     stored False;
   property ParentFont default False;
   property PopupMenu stored IsForm;
   property PopupChildren: TList read GetPopupChildren;
   property Position: TPosition read FPosition write SetPosition stored IsForm
     default poDefaultPosOnly;
   property PrintScale: TPrintScale read FPrintScale write FPrintScale stored IsForm
     default poProportional;
   property Scaled: Boolean read GetScaled write SetScaled stored IsForm default True;
   property TileMode: TTileMode read FTileMode write FTileMode default tbHorizontal;
   property VertScrollBar stored IsForm;
   property Visible write SetVisible default False;
   property Width stored IsFormSizeStored;
   property WindowMenu: TMenuItem read FWindowMenu write SetWindowMenu stored IsForm;
   property OnActivate: TNotifyEvent read FOnActivate write FOnActivate stored IsForm;
   property OnCanResize stored IsForm;
   property OnClick stored IsForm;
   property OnClose: TCloseEvent read FOnClose write FOnClose stored IsForm;
   property OnCloseQuery: TCloseQueryEvent read FOnCloseQuery write FOnCloseQuery
     stored IsForm;
   property OnCreate: TNotifyEvent read FOnCreate write FOnCreate stored IsForm;
   property OnDblClick stored IsForm;
   property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy stored IsForm;
   property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate stored IsForm;
   property OnDragDrop stored IsForm;
   property OnDragOver stored IsForm;
   property OnHelp: THelpEvent read FOnHelp write FOnHelp;
   property OnHide: TNotifyEvent read FOnHide write FOnHide stored IsForm;
   property OnKeyDown stored IsForm;
   property OnKeyPress stored IsForm;
   property OnKeyUp stored IsForm;
   property OnMouseDown stored IsForm;
   property OnMouseMove stored IsForm;
   property OnMouseUp stored IsForm;
   property OnPaint: TNotifyEvent read FOnPaint write FOnPaint stored IsForm;
   property OnResize stored IsForm;
   property OnShortCut: TShortCutEvent read FOnShortCut write FOnShortCut;
   property OnShow: TNotifyEvent read FOnShow write FOnShow stored IsForm;
 public
   constructor Create(AOwner: TComponent); override;
   constructor CreateNew(AOwner: TComponent; Dummy: Integer  = 0); virtual;
   destructor Destroy; override;
   procedure Close;
   function CloseQuery: Boolean; virtual;
   procedure DefaultHandler(var Message); override;
   procedure DefocusControl(Control: TWinControl; Removing: Boolean);
   procedure Dock(NewDockSite: TWinControl; ARect: TRect); override;
   procedure FocusControl(Control: TWinControl);
   procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
   function GetRootDesigner: IDesignerNotify; override;
   function GetFormImage: TBitmap;
   procedure Hide;
   function IsShortCut(var Message: TWMKey): Boolean; virtual;
   procedure MakeFullyVisible(AMonitor: TMonitor = nil);
   procedure MouseWheelHandler(var Message: TMessage); override;
   procedure Print;
   procedure RecreateAsPopup(AWindowHandle: HWND);
   procedure Release;
   procedure SendCancelMode(Sender: TControl);
   procedure SetFocus; override;
   function SetFocusedControl(Control: TWinControl): Boolean; virtual;
   procedure Show;
   function ShowModal: Integer; virtual;
   function WantChildKey(Child: TControl; var Message: TMessage): Boolean; virtual;
   property Active: Boolean read FActive;
   property ActiveControl: TWinControl read FActiveControl write SetActiveControl
     stored IsForm;
   property Action;
   property ActiveOleControl: TWinControl read FActiveOleControl write FActiveOleControl;
   property BorderStyle: TFormBorderStyle read FBorderStyle write SetBorderStyle
     stored IsForm default bsSizeable;
   property Canvas: TCanvas read GetCanvas;
   property Caption stored IsForm;
   property Color nodefault;
   property Designer: IDesignerHook read FDesigner write SetDesigner;
   property DropTarget: Boolean read FDropTarget write FDropTarget;
   property Font;
   property FormState: TFormState read FFormState;
   property HelpFile: string read FHelpFile write FHelpFile;
   property KeyPreview: Boolean read FKeyPreview write FKeyPreview
     stored IsForm default False;
   property Menu: TMainMenu read FMenu write SetMenu stored IsForm;
   property ModalResult: TModalResult read FModalResult write FModalResult;
   property Monitor: TMonitor read GetMonitor;
   property OleFormObject: IOleForm read FOleForm write FOleForm;
   property PopupMode: TPopupMode read FPopupMode write SetPopupMode default pmNone;
   property PopupParent: TCustomForm read FPopupParent write SetPopupParent;
   property ScreenSnap: Boolean read FScreenSnap write FScreenSnap default False;
   property SnapBuffer: Integer read FSnapBuffer write FSnapBuffer;
   property WindowState: TWindowState read FWindowState write SetWindowState
     stored IsForm default wsNormal;
 end;






--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Vit
Дата 14.1.2004, 02:14 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Цитата
Есть ли понятие делегата?


Если б я ещё знал что это такое...

Цитата
Есть ли исходники борландовских модулей (System, SysUtils, Forms
,


Есть.

Выложить затруднительно, там многие тысячи строк.

Вот кусок из SysUtils:


Код
function IsValidIdent(const Ident: string; AllowDots: Boolean): Boolean;
var
 I: Integer;
begin
 Result := False;
 if (Length(Ident) = 0) or not (Ident[1] in Alpha) then Exit;
 if AllowDots then
   for I := 2 to Length(Ident) do
   begin
     if not (Ident[I] in AlphaNumericDot) then Exit
   end
 else
   for I := 2 to Length(Ident) do
     if not (Ident[I] in AlphaNumeric) then Exit;
 Result := True;
end;

function IntToStr(Value: Integer): string;
begin
 Result := System.Convert.ToString(Value);
end;

function IntToStr(Value: Int64): string;
begin
 Result := System.Convert.ToString(Value);
end;

function UIntToStr(Value: LongWord): string;
begin
 Result := System.Convert.ToString(Value);
end;

function UIntToStr(Value: UInt64): string;
begin
 Result := System.Convert.ToString(Value);
end;

function IntToHex(Value: Integer; Digits: Integer): string;
begin
 FmtStr(Result, '%.*x', [Digits, Value]);
end;

function IntToHex(Value: Int64; Digits: Integer): string;
begin
 FmtStr(Result, '%.*x', [Digits, Value]);
end;

function StrToInt(const S: string): Integer;
var
 E: Integer;
begin
 Val(S, Result, E);
 if E <> 0 then ConvertErrorFmt(SInvalidInteger, [S]);
end;

function StrToIntDef(const S: string; Default: Integer): Integer;
begin
 if not TryStrToInt(S, Result) then
   Result := Default;
end;

function TryStrToInt(const S: string; out Value: Integer): Boolean;
var
 E: Integer;
begin
 Val(S, Value, E);
 Result := E = 0;
end;

function StrToLongWord(const S: string): LongWord;
var
 E: Integer;
begin
 Val(S, Result, E);
 if E <> 0 then ConvertErrorFmt(SInvalidInteger, [S]);
end;

function StrToLongWordDef(const S: string; Default: LongWord): LongWord;
begin
 if not TryStrToLongWord(S, Result) then
   Result := Default;
end;

function TryStrToLongWord(const S: string; out Value: LongWord): Boolean;
var
 E: Integer;
begin
 Val(S, Value, E);
 Result := E = 0;
end;

function StrToInt64(const S: string): Int64;
var
 E: Integer;
begin
 Val(S, Result, E);
 if E <> 0 then ConvertErrorFmt(SInvalidInteger, [S]);
end;

function StrToInt64Def(const S: string; const Default: Int64): Int64;
begin
 if not TryStrToInt64(S, Result) then
   Result := Default;
end;

function TryStrToInt64(const S: string; out Value: Int64): Boolean;
var
 E: Integer;
begin
 Val(S, Value, E);
 Result := E = 0;
end;

function StrToUInt64(const S: string): UInt64;
var
 E: Integer;
begin
 Val(S, Result, E);
 if E <> 0 then ConvertErrorFmt(SInvalidInteger, [S]);
end;

function StrToUInt64Def(const S: string; const Default: UInt64): UInt64;
begin
 if not TryStrToUInt64(S, Result) then
   Result := Default;
end;

function TryStrToUInt64(const S: string; out Value: UInt64): Boolean;
var
 E: Integer;
begin
 Val(S, Value, E);
 Result := E = 0;
end;

function StringReplace(const S, OldPattern, NewPattern: string;
 Flags: TReplaceFlags): string;
var
 SearchStr, Patt, NewStr: string;
 Offset: Integer;
 SB: StringBuilder;
begin
 if rfIgnoreCase in Flags then
 begin
   SearchStr := UpperCase(S);
   Patt := UpperCase(OldPattern);
 end else
 begin
   SearchStr := S;
   Patt := OldPattern;
 end;
 NewStr := S;
 SB := StringBuilder.Create;
 while SearchStr <> '' do
 begin
   Offset := Pos(Patt, SearchStr);
   if Offset = 0 then
   begin
     SB.Append(NewStr);
     Break;
   end;
   SB.Append(NewStr, 0, Offset - 1);
   SB.Append(NewPattern);
   NewStr := Copy(NewStr, Offset + Length(OldPattern), MaxInt);
   if not (rfReplaceAll in Flags) then
   begin
     SB.Append(NewStr);
     Break;
   end;
   SearchStr := Copy(SearchStr, Offset + Length(Patt), MaxInt);
 end;
 Result := SB.ToString;
end;

procedure VerifyBoolStrArray;
begin
 if Length(TrueBoolStrs) = 0 then
 begin
   SetLength(TrueBoolStrs, 2);
   TrueBoolStrs[0] := DefaultTrueBoolStr;
   TrueBoolStrs[1] := DefaultTrueBoolStr[1];
 end;
 if Length(FalseBoolStrs) = 0 then
 begin
   SetLength(FalseBoolStrs, 2);
   FalseBoolStrs[0] := DefaultFalseBoolStr;
   FalseBoolStrs[1] := DefaultFalseBoolStr[1];
 end;
end;

function StrToBool(const S: string; StrOnlyTest: Boolean): Boolean;
begin
 if not TryStrToBool(S, Result, StrOnlyTest) then
   ConvertErrorFmt(SInvalidBoolean, [S]);
end;

function StrToBoolDef(const S: string; const Default: Boolean; StrOnlyTest: Boolean): Boolean;
begin
 if not TryStrToBool(S, Result, StrOnlyTest) then
   Result := Default;
end;

function TryStrToBool(const S: string; out Value: Boolean; StrOnlyTest: Boolean): Boolean;

 function CompareWith(const aArray: array of string): Boolean;
 var
   I: Integer;
 begin
   Result := False;
   for I := Low(aArray) to High(aArray) do
     if AnsiSameText(S, aArray[I]) then
     begin
       Result := True;
       Break;
     end;
 end;

var
 LResult: Double;
begin
 if not StrOnlyTest then
 begin
   Result := TryStrToFloat(S, LResult);
   if Result then
   begin
     Value := LResult <> 0;
     Exit;
   end;
 end;

 VerifyBoolStrArray;
 Result := CompareWith(TrueBoolStrs);
 if Result then
   Value := True
 else
 begin
   Result := CompareWith(FalseBoolStrs);
   if Result then
     Value := False;
 end;
end;

const
 cSimpleBoolStrs: array [boolean] of String = ('0', '-1');
 
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
begin
 if UseBoolStrs then
 begin
   VerifyBoolStrArray;
   if B then
     Result := TrueBoolStrs[0]
   else
     Result := FalseBoolStrs[0];
 end
 else
   Result := cSimpleBoolStrs[B];
end;

function Format(const Format: string; const Args: array of const): string;
begin
 FmtStr(Result, Format, Args);
end;

function Format(const Format: string; const Args: array of const;
 const FormatSettings: TFormatSettings): string;
begin
 FmtStr(Result, Format, Args, FormatSettings);
end;

function Format(const Format: string; const Args: array of const;
 Provider: IFormatProvider): string;
begin
 FmtStr(Result, Format, Args, Provider);
end;

procedure FmtStr(var Result: string; const Format: string;
 const Args: array of const);
var
 Buffer: System.Text.StringBuilder;
begin
 Buffer := System.Text.StringBuilder.Create(Length(Format) * 2);
 FormatBuf(Buffer, Format, Length(Format), Args);
 Result := Buffer.ToString;
end;

procedure FmtStr(var Result: string; const Format: string;
 const Args: array of const; const FormatSettings: TFormatSettings);
var
 Buffer: System.Text.StringBuilder;
begin
 Buffer := System.Text.StringBuilder.Create(Length(Format) * 2);
 FormatBuf(Buffer, Format, Length(Format), Args, FormatSettings);
 Result := Buffer.ToString;
end;

procedure FmtStr(var Result: string; const Format: string;
 const Args: array of const; Provider: IFormatProvider);
var
 Buffer: System.Text.StringBuilder;
begin
 Buffer := System.Text.StringBuilder.Create(Length(Format) * 2);
 FormatBuf(Buffer, Format, Length(Format), Args, Provider);
 Result := Buffer.ToString;
end;

function FormatBuf(var Buffer: System.Text.StringBuilder; const Format: string;
 FmtLen: Cardinal; const Args: array of const): Cardinal;
var
 LFormat: NumberFormatInfo;
begin
 LFormat := NumberFormatInfo(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone);
 with LFormat do
 begin
   CurrencyDecimalSeparator := DecimalSeparator;
   CurrencyGroupSeparator := ThousandSeparator;
   NumberDecimalSeparator := DecimalSeparator;
   NumberGroupSeparator := ThousandSeparator;
   CurrencySymbol := CurrencyString;
   CurrencyPositivePattern := CurrencyFormat;
   CurrencyNegativePattern := NegCurrFormat;
 end;
 Result := FormatBuf(Buffer, Format, FmtLen, Args, LFormat);
end;

function FormatBuf(var Buffer: System.Text.StringBuilder; const Format: string;
 FmtLen: Cardinal; const Args: array of const; const FormatSettings: TFormatSettings): Cardinal;
var
 LFormat: NumberFormatInfo;
begin
 LFormat := NumberFormatInfo(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone);
 with LFormat, FormatSettings do
 begin
   CurrencyDecimalSeparator := DecimalSeparator;
   CurrencyGroupSeparator := ThousandSeparator;
   NumberDecimalSeparator := DecimalSeparator;
   NumberGroupSeparator := ThousandSeparator;
   CurrencySymbol := CurrencyString;
   CurrencyPositivePattern := CurrencyFormat;
   CurrencyNegativePattern := NegCurrFormat;
 end;
 Result := FormatBuf(Buffer, Format, FmtLen, Args, LFormat);
end;

function FormatBuf(var Buffer: System.Text.StringBuilder; const Format: string;
 FmtLen: Cardinal; const Args: array of const; Provider: IFormatProvider): Cardinal;

 procedure Error;
 begin
   raise System.FormatException.Create(SInvalidFormatString);
 end;

var
 s, srclen: Cardinal;
 argIndex: Cardinal;
 precisionStart: Cardinal;
 precisionLen: Integer;
 fmtSpec: System.Text.StringBuilder;
 argStr: string;
begin
 s := 1;
 argIndex := 0;
 srclen := Length(Format);
 fmtSpec := System.Text.StringBuilder.Create;

 while s <= srclen do
 begin
   if Format[s] = '%' then
   begin
     Inc(s);
     if s > srclen then break;
     if Format[s] = '%' then
     begin
       Buffer.Append(Format[s]);
       Inc(s);
       Continue;
     end;

     fmtSpec.Length := 0;
     fmtSpec.Append('{0,');

     if Format[s] = '-' then   // width might be first
     begin
       fmtSpec.Append(Char('-'));
       Inc(s);
     end;

     if Format[s] = '*' then
     begin
       fmtSpec.Append(Args[argIndex]);
       Inc(argIndex);
       Inc(s);
     end
     else
     begin
       while (s < srclen) and System.Char.IsDigit(Format[s]) do
       begin
         fmtSpec.Append(Format[s]);
         Inc(s);
       end;
     end;

     if s > srclen then Error;

     if Format[s] = ':' then
     begin
       Inc(s);

       // something got added, it must be the index
       if fmtSpec.Length > 3 then
       begin
         argStr := fmtSpec.ToString(3, fmtSpec.Length - 3);
         argIndex := Int32.Parse(argStr);
         fmtSpec.Length := 3;
       end

       // nothing got added, the index then defaults to zero
       else
         argIndex := 0;

       //  width follows argIndex
       if Format[s] = '-' then
       begin
         fmtSpec.Append(Char('-'));
         Inc(s);
       end;

       if Format[s] = '*' then
       begin
         fmtSpec.Append(Args[argIndex]);
         Inc(argIndex);
         Inc(s);
       end
       else
       begin
         while (s < srclen) and System.Char.IsDigit(Format[s]) do
         begin
           fmtSpec.Append(Format[s]);
           Inc(s);
         end;
       end;
     end;

     if fmtSpec.Length = 3 then
       fmtSpec.Length := 2;    // remove comma if no width spec was found

     if s > srclen then Error;

     if Format[s] = '.' then
     begin
       Inc(s);
       if Format[s] = '*' then
       begin
         precisionStart := Integer(Args[argIndex]);
         precisionLen := -1;
         Inc(argIndex);
         Inc(s);
       end
       else
       begin
         precisionStart := s - 1;
         while (s < srclen) and System.Char.IsDigit(Format[s]) do
           Inc(s);
         precisionLen := s - precisionStart - 1;
       end;
     end
     else
     begin
       precisionStart := 0;
       precisionLen := 0;
     end;

     fmtSpec.Append(Char(':'));
     case Format[s] of
       'd', 'D',
       'u', 'U': fmtSpec.Append(Char('d'));
       'e', 'E',
       'f', 'F',
       'g', 'G',
       'n', 'N',
       'x', 'X': fmtSpec.Append(Char(Format[s]));
       'm', 'M': fmtSpec.Append(Char('c'));
       'p', 'P': fmtSpec.Append(Char('x'));
       's', 'S':;   // no format spec needed for strings
     else
       Error;
     end;

     if precisionLen > 0 then
       fmtSpec.Append(Format, precisionStart, precisionLen)
     else if precisionLen < 0 then
       fmtSpec.Append(precisionStart);

     fmtSpec.Append(Char('}'));
     Buffer.AppendFormat(Provider, fmtSpec.ToString, [Args[argIndex]]);
     Inc(argIndex);
   end
   else
     Buffer.Append(Format[s]);

   Inc(s);
 end;
 Result := Buffer.Length;
end;

function WideFormat(const AFormat: WideString;
 const Args: array of const): WideString;
begin
 Result := Format(AFormat, Args);
end;

function WideFormat(const AFormat: WideString;
 const Args: array of const; const FormatSettings: TFormatSettings): WideString;
begin
 Result := Format(AFormat, Args, FormatSettings);
end;

function WideFormat(const AFormat: WideString;
 const Args: array of const; Provider: IFormatProvider): WideString;
begin
 Result := Format(AFormat, Args, Provider);
end;

procedure WideFmtStr(var AResult: WideString; const AFormat: WideString;
 const Args: array of const);
begin
 FmtStr(AResult, AFormat, Args);
end;

procedure WideFmtStr(var AResult: WideString; const AFormat: WideString;
 const Args: array of const; const FormatSettings: TFormatSettings);
begin
 FmtStr(AResult, AFormat, Args, FormatSettings);
end;

procedure WideFmtStr(var AResult: WideString; const AFormat: WideString;
 const Args: array of const; Provider: IFormatProvider);
begin
 FmtStr(AResult, AFormat, Args, Provider);
end;

function WideFormatBuf(var ABuffer: System.Text.StringBuilder; const AFormat: WideString;
 AFmtLen: Cardinal; const Args: array of const): Cardinal;
begin
 Result := FormatBuf(ABuffer, AFormat, AFmtLen, Args);
end;

function WideFormatBuf(var ABuffer: System.Text.StringBuilder; const AFormat: WideString;
 AFmtLen: Cardinal; const Args: array of const; const FormatSettings: TFormatSettings): Cardinal;
begin
 Result := FormatBuf(ABuffer, AFormat, AFmtLen, Args, FormatSettings);
end;

function WideFormatBuf(var ABuffer: System.Text.StringBuilder; const AFormat: WideString;
 AFmtLen: Cardinal; const Args: array of const; Provider: IFormatProvider): Cardinal;
begin
 Result := FormatBuf(ABuffer, AFormat, AFmtLen, Args, Provider);
end;

function StrToFloat(const S: string): Extended;
var
 Value: Double;
begin
 if not TryStrToFloat(S, Value) then
   ConvertErrorFmt(SInvalidFloat, [S]);
 Result := Value;
end;

function StrToFloat(const S: string; const FormatSettings: TFormatSettings): Extended;
var
 Value: Double;
begin
 if not TryStrToFloat(S, Value, FormatSettings) then
   ConvertErrorFmt(SInvalidFloat, [S]);
 Result := Value;
end;

function StrToFloat(const S: string; Provider: IFormatProvider): Extended;
var
 Value: Double;
begin
 if not TryStrToFloat(S, Value, Provider) then
   ConvertErrorFmt(SInvalidFloat, [S]);
 Result := Value;
end;

function StrToFloatDef(const S: string; const Default: Extended): Extended;
var
 Value: Double;
begin
 if TryStrToFloat(S, Value) then
   Result := Value
 else
   Result := Default;
end;

function StrToFloatDef(const S: string; const Default: Extended;
 const FormatSettings: TFormatSettings): Extended;
var
 Value: Double;
begin
 if TryStrToFloat(S, Value, FormatSettings) then
   Result := Value
 else
   Result := Default;
end;

function StrToFloatDef(const S: string; const Default: Extended;
 Provider: IFormatProvider): Extended;
var
 Value: Double;
begin
 if TryStrToFloat(S, Value, Provider) then
   Result := Value
 else
   Result := Default;
end;

function TryStrToFloat(const S: string; out Value: Double): Boolean;
var
 LFormat: NumberFormatInfo;
begin
 LFormat := NumberFormatInfo(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone);
 with LFormat do
 begin
   CurrencyDecimalSeparator := DecimalSeparator;
   CurrencyGroupSeparator := ThousandSeparator;
   NumberDecimalSeparator := DecimalSeparator;
   NumberGroupSeparator := ThousandSeparator;
 end;
 Result := TryStrToFloat(S, Value, LFormat);
end;

function TryStrToFloat(const S: string; out Value: Double;
 const FormatSettings: TFormatSettings): Boolean;
var
 LFormat: NumberFormatInfo;
begin
 LFormat := NumberFormatInfo(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone);
 with LFormat, FormatSettings do
 begin
   CurrencyDecimalSeparator := DecimalSeparator;
   CurrencyGroupSeparator := ThousandSeparator;
   NumberDecimalSeparator := DecimalSeparator;
   NumberGroupSeparator := ThousandSeparator;
 end;
 Result := TryStrToFloat(S, Value, LFormat);
end;

function TryStrToFloat(const S: string; out Value: Double;
 Provider: IFormatProvider): Boolean;
begin
 Result := System.Double.TryParse(S, NumberStyles.Float, Provider, Value);
end;

function TryStrToFloat(const S: string; out Value: Single): Boolean;
var
 LValue: Double;
begin
 Result := TryStrToFloat(S, LValue);
 if Result then
   Value := LValue;
end;

function TryStrToFloat(const S: string; out Value: Single;
 const FormatSettings: TFormatSettings): Boolean;
var
 LValue: Double;
begin
 Result := TryStrToFloat(S, LValue, FormatSettings);
 if Result then
   Value := LValue;
end;


function TryStrToFloat(const S: string; out Value: Single;
 Provider: IFormatProvider): Boolean;
var
 LValue: Double;
begin
 Result := TryStrToFloat(S, LValue, Provider);
 if Result then
   Value := LValue;
end;

function StrToCurr(const S: string): Currency;
begin
 if not TryStrToCurr(S, Result) then
   ConvertErrorFmt(SInvalidFloat, [S]);
end;

function StrToCurr(const S: string; const FormatSettings: TFormatSettings): Currency;
begin
 if not TryStrToCurr(S, Result, FormatSettings) then
   ConvertErrorFmt(SInvalidFloat, [S]);
end;

function StrToCurr(const S: string; Provider: IFormatProvider): Currency;
begin
 if not TryStrToCurr(S, Result, Provider) then
   ConvertErrorFmt(SInvalidFloat, [S]);
end;


function StrToCurrDef(const S: string; const Default: Currency): Currency;
begin
 if not TryStrToCurr(S, Result) then
   Result := Default;
end;

function StrToCurrDef(const S: string; const Default: Currency;
 const FormatSettings: TFormatSettings): Currency;
begin
 if not TryStrToCurr(S, Result, FormatSettings) then
   Result := Default;
end;

function StrToCurrDef(const S: string; const Default: Currency;
 Provider: IFormatProvider): Currency;
begin
 if not TryStrToCurr(S, Result, Provider) then
   Result := Default;
end;

function TryStrToCurr(const S: string; out Value: Currency): Boolean;
var
 LFormat: NumberFormatInfo;
begin
 LFormat := NumberFormatInfo(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone);
 with LFormat do
 begin
   CurrencyDecimalSeparator := DecimalSeparator;
   CurrencyGroupSeparator := ThousandSeparator;
   NumberDecimalSeparator := DecimalSeparator;
   NumberGroupSeparator := ThousandSeparator;
 end;
 Result := TryStrToCurr(S, Value, LFormat);
end;




--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Vit
Дата 14.1.2004, 02:17 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Вот нашёл модуль поменьше, привожу целиком:

Код
unit Borland.Vcl.ActnList platform;

{$T-,H+,X+}

interface

uses Classes, Messages, ImgList, Contnrs,
 System.ComponentModel.Design.Serialization;

type

{ TContainedAction }

 TCustomActionList = class;

 TContainedAction = class(TBasicAction)
 private
   FCategory: string;
   FActionList: TCustomActionList;
   class constructor Create;
   function GetIndex: Integer;
   function IsCategoryStored: Boolean;
   procedure SetCategory(const Value: string);
   procedure SetIndex(Value: Integer);
   procedure SetActionList(AActionList: TCustomActionList);
 protected
   procedure Change; override;
   procedure ReadState(Reader: TReader); override;
 public
   destructor Destroy; override;
   function Execute: Boolean; override;
   function GetParentComponent: TComponent; override;
   function HasParent: Boolean; override;
   procedure SetParentComponent(AParent: TComponent); override;
   function Update: Boolean; override;
   property ActionList: TCustomActionList read FActionList write SetActionList;
   property Index: Integer read GetIndex write SetIndex stored False;
 published
   property Category: string read FCategory write SetCategory stored IsCategoryStored;
 end;

 TContainedActionClass = class of TContainedAction;

{ TCustomActionList }

 TActionEvent = procedure (Action: TBasicAction; var Handled: Boolean) of object;
 TActionListState = (asNormal, asSuspended, asSuspendedEnabled);

 [RootDesignerSerializerAttribute('', '', False)]
 TCustomActionList = class(TComponent)
 private
   FActions: TList;
   FImageChangeLink: TChangeLink;
   FImages: TCustomImageList;
   FOnChange: TNotifyEvent;
   FOnExecute: TActionEvent;
   FOnUpdate: TActionEvent;
   FState: TActionListState;
   FOnStateChange: TNotifyEvent;
   class constructor Create;
   function GetAction(Index: Integer): TContainedAction;
   function GetActionCount: Integer;
   procedure SetAction(Index: Integer; Value: TContainedAction);
   procedure SetState(const Value: TActionListState);
   procedure ImageListChange(Sender: TObject);
 protected
   procedure AddAction(Action: TContainedAction);
   procedure RemoveAction(Action: TContainedAction);
   procedure Change; virtual;
   procedure Notification(AComponent: TComponent;
     Operation: TOperation); override;
   procedure SetChildOrder(Component: TComponent; Order: Integer); override;
   procedure SetImages(Value: TCustomImageList); virtual;
   property OnChange: TNotifyEvent read FOnChange write FOnChange;
   property OnExecute: TActionEvent read FOnExecute write FOnExecute;
   property OnUpdate: TActionEvent read FOnUpdate write FOnUpdate;
 public
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
   function ExecuteAction(Action: TBasicAction): Boolean; override;
   procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
   function IsShortCut(var Message: TWMKey): Boolean;
   function UpdateAction(Action: TBasicAction): Boolean; override;
   property Actions[Index: Integer]: TContainedAction read GetAction write SetAction; default;
   property ActionCount: Integer read GetActionCount;
   property Images: TCustomImageList read FImages write SetImages;
   property State: TActionListState read FState write SetState default asNormal;
   property OnStateChange: TNotifyEvent read FOnStateChange write FOnStateChange;
 end;

{ TActionList }

 TActionList = class(TCustomActionList)
 published
   property Images;
   property State;
   property OnChange;
   property OnExecute;
   property OnStateChange;
   property OnUpdate;
 end;

{ TShortCutList }

 TShortCutList = class(TStringList)
 private
   function GetShortCuts(Index: Integer): TShortCut;
 public
   function Add(const S: String): Integer; override;
   function IndexOfShortCut(const Shortcut: TShortCut): Integer;
   property ShortCuts[Index: Integer]: TShortCut read GetShortCuts;
 end;

{ TCustomAction }

 THintEvent = procedure (var HintStr: string; var CanShow: Boolean) of object;

 TCustomAction = class(TContainedAction)
 private
   FDisableIfNoHandler: Boolean;
   FCaption: string;
   FChecking: Boolean;
   FChecked: Boolean;
   FEnabled: Boolean;
   FGroupIndex: Integer;
   FHelpType: THelpType;
   FHelpContext: THelpContext;
   FHelpKeyword: string;
   FHint: string;
   FImageIndex: TImageIndex;
   FShortCut: TShortCut;
   FVisible: Boolean;
   FOnHint: THintEvent;
   FSecondaryShortCuts: TShortCutList;
   FSavedEnabledState: Boolean;
   FAutoCheck: Boolean;
   FImage: TObject;
   FMask: TObject;
   procedure SetAutoCheck(Value: Boolean);
   procedure SetCaption(const Value: string);
   procedure SetChecked(Value: Boolean);
   procedure SetEnabled(Value: Boolean);
   procedure SetGroupIndex(const Value: Integer);
   procedure SetHelpType(Value: THelpType);
   procedure SetHint(const Value: string);
   procedure SetImageIndex(Value: TImageIndex);
   procedure SetShortCut(Value: TShortCut);
   procedure SetVisible(Value: Boolean);
   function GetSecondaryShortCuts: TShortCutList;
   procedure SetSecondaryShortCuts(const Value: TShortCutList);
   function IsSecondaryShortCutsStored: Boolean;
 protected
   procedure AssignTo(Dest: TPersistent); override;
   procedure SetName(const Value: TComponentName); override;
   procedure SetHelpContext(Value: THelpContext); virtual;
   procedure SetHelpKeyword(const Value: string); virtual;
   function HandleShortCut: Boolean; virtual;
   property SavedEnabledState: Boolean read FSavedEnabledState write FSavedEnabledState;
 public
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
   function DoHint(var HintStr: string): Boolean; dynamic;
   function Execute: Boolean; override;
   property AutoCheck: Boolean read FAutoCheck write  SetAutoCheck default False;
   property Caption: string read FCaption write SetCaption;
   property Checked: Boolean read FChecked write SetChecked default False;
   property DisableIfNoHandler: Boolean read FDisableIfNoHandler write FDisableIfNoHandler default False;
   property Enabled: Boolean read FEnabled write SetEnabled default True;
   property GroupIndex: Integer read FGroupIndex write SetGroupIndex default 0;
   property HelpContext: THelpContext read FHelpContext write SetHelpContext default 0;
   property HelpKeyword: string read FHelpKeyword write SetHelpKeyword;
   property HelpType: THelpType read FHelpType write SetHelpType default htKeyword;
   property Hint: string read FHint write SetHint;
   property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
   property ShortCut: TShortCut read FShortCut write SetShortCut default 0;
   property SecondaryShortCuts: TShortCutList read GetSecondaryShortCuts
     write SetSecondaryShortCuts stored IsSecondaryShortCutsStored;
   property Visible: Boolean read FVisible write SetVisible default True;
   property OnHint: THintEvent read FOnHint write FOnHint;
   { Property access for design time support }
   property Image: TObject read FImage write FImage;
   property Mask: TObject read FMask write FMask;
 end;

 TAction = class(TCustomAction)
 public
   constructor Create(AOwner: TComponent); override;
 published
   property AutoCheck;
   property Caption;
   property Checked;
   property Enabled;
   property GroupIndex;
   property HelpContext;
   property HelpKeyword;
   property HelpType;
   property Hint;
   property ImageIndex;
   property ShortCut;
   property SecondaryShortCuts;
   property Visible;
   property OnExecute;
   property OnHint;
   property OnUpdate;
 end;

{ TActionLink }

 TActionLink = class(TBasicActionLink)
 protected
   function IsCaptionLinked: Boolean; virtual;
   function IsCheckedLinked: Boolean; virtual;
   function IsEnabledLinked: Boolean; virtual;
   function IsGroupIndexLinked: Boolean; virtual;
   function IsHelpContextLinked: Boolean; virtual;
   function IsHelpLinked: Boolean; virtual;
   function IsHintLinked: Boolean; virtual;
   function IsImageIndexLinked: Boolean; virtual;
   function IsShortCutLinked: Boolean; virtual;
   function IsVisibleLinked: Boolean; virtual;
   procedure SetAutoCheck(Value: Boolean); virtual;
   procedure SetCaption(const Value: string); virtual;
   procedure SetChecked(Value: Boolean); virtual;
   procedure SetEnabled(Value: Boolean); virtual;
   procedure SetGroupIndex(Value: Integer); virtual;
   procedure SetHelpContext(Value: THelpContext); virtual;
   procedure SetHelpKeyword(const Value: string); virtual;
   procedure SetHelpType(Value: THelpType); virtual;
   procedure SetHint(const Value: string); virtual;
   procedure SetImageIndex(Value: Integer); virtual;
   procedure SetShortCut(Value: TShortCut); virtual;
   procedure SetVisible(Value: Boolean); virtual;
 end;

 TActionLinkClass = class of TActionLink;

{ Action registration }

 TEnumActionProc = procedure (const Category: string; ActionClass: TBasicActionClass;
   Info: TObject) of object;

procedure RegisterActions(const CategoryName: string;
 const AClasses: array of TBasicActionClass; Resource: TComponentClass);
procedure UnRegisterActions(const AClasses: array of TBasicActionClass);
procedure EnumRegisteredActions(Proc: TEnumActionProc; Info: TObject);
function CreateAction(AOwner: TComponent; ActionClass: TBasicActionClass): TBasicAction;

const
 RegisterActionsProc: procedure (const CategoryName: string;
   const AClasses: array of TBasicActionClass; Resource: TComponentClass) = nil;
 UnRegisterActionsProc: procedure (const AClasses: array of TBasicActionClass) = nil;
 EnumRegisteredActionsProc: procedure (Proc: TEnumActionProc; Info: TObject) = nil;
 CreateActionProc: function (AOwner: TComponent; ActionClass: TBasicActionClass): TBasicAction = nil;

implementation

uses SysUtils, Windows, Forms, Menus, Graphics, Controls, Consts,
 System.Runtime.InteropServices;

procedure RegisterActions(const CategoryName: string;
 const AClasses: array of TBasicActionClass; Resource: TComponentClass);
begin
 if Assigned(RegisterActionsProc) then
   RegisterActionsProc(CategoryName, AClasses, Resource) else
   raise Exception.Create(SInvalidActionRegistration);
end;

procedure UnRegisterActions(const AClasses: array of TBasicActionClass);
begin
 if Assigned(UnRegisterActionsProc) then
   UnRegisterActionsProc(AClasses) else
   raise Exception.Create(SInvalidActionUnregistration);
end;

procedure EnumRegisteredActions(Proc: TEnumActionProc; Info: TObject);
begin
 if Assigned(EnumRegisteredActionsProc) then
   EnumRegisteredActionsProc(Proc, Info) else
   raise Exception.Create(SInvalidActionEnumeration);
end;

function CreateAction(AOwner: TComponent; ActionClass: TBasicActionClass): TBasicAction;
begin
 if Assigned(CreateActionProc) then
   Result := CreateActionProc(AOwner, ActionClass) else
   raise Exception.Create(SInvalidActionCreation);
end;

{ TContainedAction }

class constructor TContainedAction.Create;
begin
 GroupDescendentsWith(TContainedAction, TControl);
end;

destructor TContainedAction.Destroy;
begin
 if ActionList <> nil then ActionList.RemoveAction(Self);
 inherited Destroy;
end;

function TContainedAction.GetIndex: Integer;
begin
 if ActionList <> nil then
   Result := ActionList.FActions.IndexOf(Self) else
   Result := -1;
end;

function TContainedAction.IsCategoryStored: Boolean;
begin
 Result := True;//GetParentComponent <> ActionList;
end;

function TContainedAction.GetParentComponent: TComponent;
begin
 if ActionList <> nil then
   Result := ActionList else
   Result := inherited GetParentComponent;
end;

function TContainedAction.HasParent: Boolean;
begin
 if ActionList <> nil then
   Result := True else
   Result := inherited HasParent;
end;

procedure TContainedAction.Change;
begin
 inherited Change;
end;

procedure TContainedAction.ReadState(Reader: TReader);
begin
 inherited ReadState(Reader);
 if Reader.Parent is TCustomActionList then
   ActionList := TCustomActionList(Reader.Parent);
end;

procedure TContainedAction.SetIndex(Value: Integer);
var
 CurIndex, Count: Integer;
begin
 CurIndex := GetIndex;
 if CurIndex >= 0 then
 begin
   Count := ActionList.FActions.Count;
   if Value < 0 then Value := 0;
   if Value >= Count then Value := Count - 1;
   if Value <> CurIndex then
   begin
     ActionList.FActions.Delete(CurIndex);
     ActionList.FActions.Insert(Value, Self);
   end;
 end;
end;

procedure TContainedAction.SetCategory(const Value: string);
begin
 if Value <> Category then
 begin
   FCategory := Value;
   if ActionList <> nil then
     ActionList.Change;
 end;
end;

procedure TContainedAction.SetActionList(AActionList: TCustomActionList);
begin
 if AActionList <> ActionList then
 begin
   if ActionList <> nil then ActionList.RemoveAction(Self);
   if AActionList <> nil then AActionList.AddAction(Self);
 end;
end;

procedure TContainedAction.SetParentComponent(AParent: TComponent);
begin
 if not (csLoading in ComponentState) and (AParent is TCustomActionList) then
   ActionList := TCustomActionList(AParent);
end;

function TContainedAction.Execute: Boolean;
begin
 Result := (ActionList <> nil) and ActionList.ExecuteAction(Self) or
   Application.ExecuteAction(Self) or inherited Execute;
 if not Result then
   if Assigned(Application) then
     Result := Application.DispatchAction(True, self, False);
end;

function TContainedAction.Update: Boolean;
begin
 Result := (ActionList <> nil) and ActionList.UpdateAction(Self) or
   Application.UpdateAction(Self) or inherited Update;
  if not Result then
    if Assigned(Application) then
      Result := Application.DispatchAction(False, self, False);
end;

{ TCustomActionList }

class constructor TCustomActionList.Create;
begin
 GroupDescendentsWith(TCustomActionList, TControl);
end;

constructor TCustomActionList.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 FActions := TList.Create;
 FImageChangeLink := TChangeLink.Create;
 FImageChangeLink.OnChange := ImageListChange;
 FState := asNormal;
end;

destructor TCustomActionList.Destroy;
begin
 FImageChangeLink.Free;
 while FActions.Count > 0 do TContainedAction(FActions.Last).Free;
 FActions.Free;
 inherited Destroy;
end;

procedure TCustomActionList.GetChildren(Proc: TGetChildProc; Root: TComponent);
var
 I: Integer;
 Action: TCustomAction;
begin
 for I := 0 to FActions.Count - 1 do
 begin
   Action := TCustomAction(FActions.List[I]);
   if Action.Owner = Root then Proc(Action);
 end;
end;

procedure TCustomActionList.SetChildOrder(Component: TComponent; Order: Integer);
begin
 if FActions.IndexOf(Component) >= 0 then
   (Component as TContainedAction).Index := Order;
end;

function TCustomActionList.GetAction(Index: Integer): TContainedAction;
begin
 Result := TContainedAction(FActions[Index]);
end;

function TCustomActionList.GetActionCount: Integer;
begin
 Result := FActions.Count;
end;

procedure TCustomActionList.SetAction(Index: Integer; Value: TContainedAction);
begin
 TContainedAction(FActions[Index]).Assign(Value);
end;

procedure TCustomActionList.SetImages(Value: TCustomImageList);
begin
 if Images <> nil then Images.UnRegisterChanges(FImageChangeLink);
 FImages := Value;
 if Images <> nil then
 begin
   Images.RegisterChanges(FImageChangeLink);
   Images.FreeNotification(Self);
 end;
end;

procedure TCustomActionList.ImageListChange(Sender: TObject);
begin
 if Sender = Images then Change;
end;

procedure TCustomActionList.Notification(AComponent: TComponent;
 Operation: TOperation);
begin
 inherited Notification(AComponent, Operation);
 if Operation = opRemove then
   if AComponent = Images then
     Images := nil
   else if (AComponent is TContainedAction) then
     RemoveAction(TContainedAction(AComponent));
end;

procedure TCustomActionList.AddAction(Action: TContainedAction);
begin
 FActions.Add(Action);
 Action.FActionList := Self;
 Action.FreeNotification(Self);
end;

procedure TCustomActionList.RemoveAction(Action: TContainedAction);
begin
 if FActions.Remove(Action) >= 0 then
   Action.FActionList := nil;
end;

procedure TCustomActionList.Change;
var
 I: Integer;
begin
 if Assigned(FOnChange) then FOnChange(Self);
 for I := 0 to FActions.Count - 1 do
   TContainedAction(FActions.List[I]).Change;
 if csDesigning in ComponentState then
 begin
   if (Owner is TForm) and (TForm(Owner).Designer <> nil) then
     TForm(Owner).Designer.Modified;
 end;
end;

function TCustomActionList.IsShortCut(var Message: TWMKey): Boolean;
var
 I: Integer;
 ShortCut: TShortCut;
 ShiftState: TShiftState;
 Action: TCustomAction;
begin
 ShiftState := KeyDataToShiftState(Message.KeyData);
 ShortCut := Menus.ShortCut(Message.CharCode, ShiftState);
 if ShortCut <> scNone then
   for I := 0 to FActions.Count - 1 do
   begin
     Action := TCustomAction(FActions.List[I]);
     if (TObject(Action) is TCustomAction) then
       if (Action.ShortCut = ShortCut) or (Assigned(Action.FSecondaryShortCuts) and
          (Action.SecondaryShortCuts.IndexOfShortCut(ShortCut) <> -1)) then
       begin
         Result := Action.HandleShortCut;
         Exit;
       end;
   end;
 Result := False;
end;

function TCustomActionList.ExecuteAction(Action: TBasicAction): Boolean;
begin
 Result := False;
 if Assigned(FOnExecute) then FOnExecute(Action, Result);
end;

function TCustomActionList.UpdateAction(Action: TBasicAction): Boolean;
begin
 Result := False;
 if Assigned(FOnUpdate) then FOnUpdate(Action, Result);
end;

procedure TCustomActionList.SetState(const Value: TActionListState);
var
 I: Integer;
 Action: TCustomAction;
 OldState: TActionListState;
begin
 if FState <> Value then
 begin
   OldState := FState;
   FState := Value;
   if State = asSuspended then exit;
   for I := 0 to FActions.Count - 1 do
   begin
     Action := TCustomAction(FActions.List[I]);
     case Value of
       asNormal:
         begin
           if Action is TCustomAction then
             if OldState = asSuspendedEnabled then
               with Action as TCustomAction do
                 Enabled := SavedEnabledState;
           Action.Update;
         end;
       asSuspendedEnabled:
         if Action is TCustomAction then
           if Value = asSuspendedEnabled then
             with Action as TCustomAction do
             begin
               SavedEnabledState := Enabled;
               Enabled := True;
             end;
     end;
   end;
   if Assigned(FOnStateChange) then
     FOnStateChange(Self);
 end;
end;

{ TActionLink }

function TActionLink.IsCaptionLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsCheckedLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsEnabledLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsGroupIndexLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsHelpContextLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsHelpLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsHintLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsImageIndexLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsShortCutLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

function TActionLink.IsVisibleLinked: Boolean;
begin
 Result := Action is TCustomAction;
end;

procedure TActionLink.SetAutoCheck(Value: Boolean);
begin
end;

procedure TActionLink.SetCaption(const Value: string);
begin
end;

procedure TActionLink.SetChecked(Value: Boolean);
begin
end;

procedure TActionLink.SetEnabled(Value: Boolean);
begin
end;

procedure TActionLink.SetGroupIndex(Value: Integer);
begin
end;

procedure TActionLink.SetHelpContext(Value: THelpContext);
begin
end;

procedure TActionLink.SetHelpKeyword(const Value: string);
begin
end;

procedure TActionLink.SetHelpType(Value: THelpType);
begin
end;

procedure TActionLink.SetHint(const Value: string);
begin
end;

procedure TActionLink.SetImageIndex(Value: Integer);
begin
end;

procedure TActionLink.SetShortCut(Value: TShortCut);
begin
end;

procedure TActionLink.SetVisible(Value: Boolean);
begin
end;

{ TCustomAction }

constructor TCustomAction.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 FEnabled := True;
 FImageIndex := -1;
 FVisible := True;
 FSecondaryShortCuts := nil;
end;

destructor TCustomAction.Destroy;
begin
 FImage.Free;
 FMask.Free;
 if Assigned(FSecondaryShortCuts) then
   FreeAndNil(FSecondaryShortCuts);
 inherited Destroy;
end;

procedure TCustomAction.AssignTo(Dest: TPersistent);
begin
 if Dest is TCustomAction then
   with TCustomAction(Dest) do
   begin
     Caption := Self.Caption;
     Checked := Self.Checked;
     Enabled := Self.Enabled;
     HelpContext := Self.HelpContext;
     Hint := Self.Hint;
     ImageIndex := Self.ImageIndex;
     ShortCut := Self.ShortCut;
     Visible := Self.Visible;
     OnExecute := Self.OnExecute;
     OnUpdate := Self.OnUpdate;
     OnChange := Self.OnChange;
   end else inherited AssignTo(Dest);
end;

procedure TCustomAction.SetAutoCheck(Value: Boolean);
var
 I: Integer;
begin
 if Value <> FAutoCheck then
 begin
   for I := 0 to FClients.Count - 1 do
     if TBasicActionLink(FClients[I]) is TActionLink then
       TActionLink(FClients[I]).SetAutoCheck(Value);
   FAutoCheck := Value;
   Change;
 end;
end;

procedure TCustomAction.SetCaption(const Value: string);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FCaption then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetCaption(Value);
   end;
   FCaption := Value;
   Change;
 end;
end;

procedure TCustomAction.SetChecked(Value: Boolean);
var
 I: Integer;
 Link: TActionLink;
 Action: TContainedAction;
begin
 if FChecking then exit;
 FChecking := True;
 try
   if Value <> FChecked then
   begin
     for I := 0 to FClients.Count - 1 do
     begin
       Link := TObject(FClients.List[I]) as TActionLink;
       if Assigned(Link) then
         Link.SetChecked(Value);
     end;
     FChecked := Value;
     if (FGroupIndex > 0) and FChecked then
       for I := 0 to ActionList.ActionCount - 1 do
       begin
         Action := ActionList.Actions[I];
         if (Action <> Self) and
            (TObject(Action) is TCustomAction) and
            (TCustomAction(Action).FGroupIndex = FGroupIndex) then
           TCustomAction(Action).Checked := False;
       end;
     Change;
   end;
 finally
   FChecking := False;
 end;
end;

procedure TCustomAction.SetEnabled(Value: Boolean);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FEnabled then
 begin
   if Assigned(ActionList) then
     if ActionList.State = asSuspended then
     begin
       FEnabled := Value;
       exit;
     end
     else
       if (ActionList.State = asSuspendedEnabled) then
         Value := True;
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       TActionLink(Link).SetEnabled(Value);
   end;
   FEnabled := Value;
   Change;
 end;
end;

procedure TCustomAction.SetGroupIndex(const Value: Integer);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FGroupIndex then
 begin
   FGroupIndex := Value;
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetGroupIndex(Value);
   end;
   Change;
 end;
end;

procedure TCustomAction.SetHelpType(Value: THelpType);
var
 I: Integer;
begin
 if Value <> FHelpType then
 begin
   for I := 0 to FClients.Count -1 do
    if TBasicActionLink(FCLients[I]) is TActionLink then
      TActionLink(FClients[I]).SetHelpType(Value);
   FHelpType := Value;
   Change;
 end;
end;

procedure TCustomAction.SetHelpKeyword(const Value: string);
var
 I: Integer;
begin
 if Value <> FHelpKeyword then
 begin
   for I := 0 to FClients.Count -1 do
    if TBasicActionLink(FCLients[I]) is TActionLink then
      TActionLink(FClients[I]).SetHelpKeyword(Value);
   FHelpKeyword := Value;
   Change;
 end;
end;

procedure TCustomAction.SetHelpContext(Value: THelpContext);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FHelpContext then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetHelpContext(Value);
   end;
   FHelpContext := Value;
   Change;
 end;
end;

procedure TCustomAction.SetHint(const Value: string);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FHint then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetHint(Value);
   end;
   FHint := Value;
   Change;
 end;
end;

procedure TCustomAction.SetImageIndex(Value: TImageIndex);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FImageIndex then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetImageIndex(Value);
   end;
   FImageIndex := Value;
   Change;
 end;
end;

procedure TCustomAction.SetShortCut(Value: TShortCut);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FShortCut then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetShortCut(Value);
   end;
   FShortCut := Value;
   Change;
 end;
end;

procedure TCustomAction.SetVisible(Value: Boolean);
var
 I: Integer;
 Link: TActionLink;
begin
 if Value <> FVisible then
 begin
   for I := 0 to FClients.Count - 1 do
   begin
     Link := TObject(FClients.List[I]) as TActionLink;
     if Assigned(Link) then
       Link.SetVisible(Value);
   end;
   FVisible := Value;
   Change;
 end;
end;

procedure TCustomAction.SetName(const Value: TComponentName);
var
 ChangeText: Boolean;
begin
 ChangeText := (Name = Caption) and ((Owner = nil) or
   not (csLoading in Owner.ComponentState));
 inherited SetName(Value);
 { Don't update caption to name if we've got clients connected. }
 if ChangeText and (FClients.Count = 0) then Caption := Value;
end;

function TCustomAction.DoHint(var HintStr: string): Boolean;
begin
 Result := True;
 if Assigned(FOnHint) then FOnHint(HintStr, Result);
end;

function TCustomAction.Execute: Boolean;
begin
 Result := False;
 if Assigned(ActionList) and (ActionList.State <> asNormal) then Exit;
 Update;
 if Enabled and FAutoCheck then
   if not Checked or Checked and (GroupIndex = 0) then
     Checked := not Checked;
 Result := Enabled and inherited Execute;
end;

function TCustomAction.GetSecondaryShortCuts: TShortCutList;
begin
 if FSecondaryShortCuts = nil then
   FSecondaryShortCuts := TShortCutList.Create;
 Result := FSecondaryShortCuts;
end;

procedure TCustomAction.SetSecondaryShortCuts(const Value: TShortCutList);
begin
 if FSecondaryShortCuts = nil then
   FSecondaryShortCuts := TShortCutList.Create;
 FSecondaryShortCuts.Assign(Value);
end;

function TCustomAction.IsSecondaryShortCutsStored: Boolean;
begin
 Result := Assigned(FSecondaryShortCuts) and (FSecondaryShortCuts.Count > 0);
end;

function TCustomAction.HandleShortCut: Boolean;
begin
 Result := Execute;
end;

{ TShortCutList }

function TShortCutList.Add(const S: String): Integer;
begin
 Result := inherited Add(S);
 Objects[Result] := TObject(TextToShortCut(S));
end;

function TShortCutList.GetShortCuts(Index: Integer): TShortCut;
begin
 Result := TShortCut(Objects[Index]);
end;

{ TAction }

constructor TAction.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 DisableIfNoHandler := True;
end;

function TShortCutList.IndexOfShortCut(const Shortcut: TShortCut): Integer;
var
 I: Integer;
begin
 Result := -1;
 for I := 0 to Count - 1 do
   if TShortCut(Objects[I]) = ShortCut then
   begin
     Result := I;
     break;
   end;
end;

end.



--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
Paradox
Дата 14.1.2004, 07:22 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Участник
Сообщений: 1135
Регистрация: 18.11.2002
Где: Россия

Репутация: нет
Всего: 1



Цитата
 
Есть ли понятие делегата?


Если б я ещё знал что это такое...

ИМХО что то вроде дружественных функций в С++ смешанные с указателями на ф-ии


--------------------
---
PM MAIL WWW   Вверх
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi"
THandle
Rrader
volvo877

Запрещается!

1. Обсуждать и делится взломанными компонентами или программным обеспечением

2. Публиковать ссылки на варез

3. Оффтопить

  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, THandle, Rrader, volvo877.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Object Pascal: кроссплатформенные технологии | Следующая тема »


 




[ Время генерации скрипта: 0.0829 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.