mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
lcl, ide: redo LoadGlypFromResource to LoadGlyphFromResourceName with ability to pass an Instance handle
git-svn-id: trunk@42972 -
This commit is contained in:
parent
1f87e24e5e
commit
102a858398
@ -110,9 +110,9 @@ begin
|
|||||||
CloseButton.Caption:=lisClose;
|
CloseButton.Caption:=lisClose;
|
||||||
ApplyButton.Caption:=lisConvert;
|
ApplyButton.Caption:=lisConvert;
|
||||||
HelpButton.Caption:=lisHelp;
|
HelpButton.Caption:=lisHelp;
|
||||||
CloseButton.LoadGlyphFromResource('btn_close');
|
CloseButton.LoadGlyphFromResourceName(hInstance, 'btn_close');
|
||||||
ApplyButton.LoadGlyphFromResource('btn_ok');
|
ApplyButton.LoadGlyphFromResourceName(hInstance, 'btn_ok');
|
||||||
HelpButton.LoadGlyphFromResource('btn_help');
|
HelpButton.LoadGlyphFromResourceName(hInstance, 'btn_help');
|
||||||
|
|
||||||
PreviewGroupBox.Caption:=dlgWRDPreview;
|
PreviewGroupBox.Caption:=dlgWRDPreview;
|
||||||
PreviewListView.Column[0].Caption:=dlgEnvFiles;
|
PreviewListView.Column[0].Caption:=dlgEnvFiles;
|
||||||
|
@ -274,7 +274,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
CancelScanningButton.LoadGlyphFromResource('btn_cancel');
|
CancelScanningButton.LoadGlyphFromResourceName(hInstance, 'btn_cancel');
|
||||||
CloseButton.Caption:=lisClose;
|
CloseButton.Caption:=lisClose;
|
||||||
OpenInEditorButton.Caption:=lisDiffDlgOpenDiffInEditor;
|
OpenInEditorButton.Caption:=lisDiffDlgOpenDiffInEditor;
|
||||||
SaveDiffButton.Caption:=lisDlgSave;
|
SaveDiffButton.Caption:=lisDlgSave;
|
||||||
|
@ -159,7 +159,7 @@ begin
|
|||||||
cbAutoCloseOnSuccess.Checked := EnvironmentOptions.AutoCloseCompileDialog;
|
cbAutoCloseOnSuccess.Checked := EnvironmentOptions.AutoCloseCompileDialog;
|
||||||
|
|
||||||
ToAbort := True;
|
ToAbort := True;
|
||||||
BClose.LoadGlyphFromResource('btn_ok');
|
BClose.LoadGlyphFromResourceName(hInstance, 'btn_ok');
|
||||||
|
|
||||||
SetProjectName('');
|
SetProjectName('');
|
||||||
SetStatus('');
|
SetStatus('');
|
||||||
|
@ -168,7 +168,7 @@ type
|
|||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
procedure LoadGlyphFromResource(const AName: String);
|
procedure LoadGlyphFromResourceName(Instance: THandle; const AName: String);
|
||||||
procedure LoadGlyphFromLazarusResource(const AName: String);
|
procedure LoadGlyphFromLazarusResource(const AName: String);
|
||||||
procedure LoadGlyphFromStock(idButton: Integer);
|
procedure LoadGlyphFromStock(idButton: Integer);
|
||||||
function CanShowGlyph: Boolean;
|
function CanShowGlyph: Boolean;
|
||||||
@ -332,7 +332,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function FindDownButton: TCustomSpeedButton;
|
function FindDownButton: TCustomSpeedButton;
|
||||||
procedure Click; override; // make Click public
|
procedure Click; override; // make Click public
|
||||||
procedure LoadGlyphFromResource(const AName: String);
|
procedure LoadGlyphFromResourceName(Instance: THandle; const AName: String);
|
||||||
procedure LoadGlyphFromLazarusResource(const AName: String);
|
procedure LoadGlyphFromLazarusResource(const AName: String);
|
||||||
public
|
public
|
||||||
property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default false;
|
property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default false;
|
||||||
@ -416,7 +416,7 @@ var
|
|||||||
GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil;
|
GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil;
|
||||||
|
|
||||||
function GetLCLDefaultBtnGlyph(Kind: TBitBtnKind): TGraphic;
|
function GetLCLDefaultBtnGlyph(Kind: TBitBtnKind): TGraphic;
|
||||||
procedure LoadGlyphFromResource(AGlyph: TButtonGlyph; const AName: String);
|
procedure LoadGlyphFromResourceName(AGlyph: TButtonGlyph; Instance: THandle; const AName: String);
|
||||||
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
||||||
procedure LoadGlyphFromStock(AGlyph: TButtonGlyph; idButton: Integer);
|
procedure LoadGlyphFromStock(AGlyph: TButtonGlyph; idButton: Integer);
|
||||||
|
|
||||||
@ -480,17 +480,14 @@ begin
|
|||||||
Result.LoadFromResourceName(hInstance, BitBtnResNames[idButton]);
|
Result.LoadFromResourceName(hInstance, BitBtnResNames[idButton]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LoadGlyphFromResource(AGlyph: TButtonGlyph; const AName: String);
|
procedure LoadGlyphFromResourceName(AGlyph: TButtonGlyph; Instance: THandle; const AName: String);
|
||||||
var
|
var
|
||||||
C: TPortableNetworkGraphic;
|
C: TCustomBitmap;
|
||||||
begin
|
begin
|
||||||
if AName = '' then
|
if AName = '' then
|
||||||
C := nil
|
C := nil
|
||||||
else
|
else
|
||||||
begin
|
C := CreateBitmapFromResourceName(Instance, AName);
|
||||||
C := TPortableNetworkGraphic.Create;
|
|
||||||
C.LoadFromResourceName(hInstance, AName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
AGlyph.Glyph.Assign(C);
|
AGlyph.Glyph.Assign(C);
|
||||||
|
@ -1367,7 +1367,7 @@ begin
|
|||||||
Button.ControlStyle := Button.ControlStyle + [csNoDesignSelectable];
|
Button.ControlStyle := Button.ControlStyle + [csNoDesignSelectable];
|
||||||
aGlyph := GetDefaultGlyph;
|
aGlyph := GetDefaultGlyph;
|
||||||
if aGlyph = nil then
|
if aGlyph = nil then
|
||||||
Button.LoadGlyphFromResource(GetDefaultGlyphName)
|
Button.LoadGlyphFromResourceName(hInstance, GetDefaultGlyphName)
|
||||||
else
|
else
|
||||||
Button.Glyph := aGlyph;
|
Button.Glyph := aGlyph;
|
||||||
Button.Parent:=self;
|
Button.Parent:=self;
|
||||||
@ -1404,7 +1404,7 @@ begin
|
|||||||
FButton.ControlStyle := FButton.ControlStyle + [csNoDesignSelectable];
|
FButton.ControlStyle := FButton.ControlStyle + [csNoDesignSelectable];
|
||||||
B := GetDefaultGlyph;
|
B := GetDefaultGlyph;
|
||||||
if B = nil
|
if B = nil
|
||||||
then FButton.LoadGlyphFromResource(GetDefaultGlyphName)
|
then FButton.LoadGlyphFromResourceName(hInstance, GetDefaultGlyphName)
|
||||||
else FButton.Glyph := B;
|
else FButton.Glyph := B;
|
||||||
ControlStyle := ControlStyle - [csSetCaption];
|
ControlStyle := ControlStyle - [csSetCaption];
|
||||||
end;
|
end;
|
||||||
|
@ -2016,6 +2016,7 @@ function LoadBitmapFromLazarusResource(const ResourceName: String): TBitmap; dep
|
|||||||
function LoadBitmapFromLazarusResourceHandle(Handle: TLResource): TBitmap; deprecated;
|
function LoadBitmapFromLazarusResourceHandle(Handle: TLResource): TBitmap; deprecated;
|
||||||
|
|
||||||
// technically a bitmap is created and not loaded
|
// technically a bitmap is created and not loaded
|
||||||
|
function CreateBitmapFromResourceName(Instance: THandle; const ResName: String): TCustomBitmap;
|
||||||
function CreateBitmapFromLazarusResource(const AName: String): TCustomBitmap;
|
function CreateBitmapFromLazarusResource(const AName: String): TCustomBitmap;
|
||||||
function CreateBitmapFromLazarusResource(const AName: String; AMinimumClass: TCustomBitmapClass): TCustomBitmap;
|
function CreateBitmapFromLazarusResource(const AName: String; AMinimumClass: TCustomBitmapClass): TCustomBitmap;
|
||||||
function CreateBitmapFromLazarusResource(AHandle: TLResource): TCustomBitmap;
|
function CreateBitmapFromLazarusResource(AHandle: TLResource): TCustomBitmap;
|
||||||
@ -2199,6 +2200,27 @@ begin
|
|||||||
Result := CreateBitmapFromLazarusResource(AName, TCustomBitmap);
|
Result := CreateBitmapFromLazarusResource(AName, TCustomBitmap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CreateBitmapFromResourceName(Instance: THandle; const ResName: String): TCustomBitmap;
|
||||||
|
var
|
||||||
|
ResHandle: TFPResourceHandle;
|
||||||
|
begin
|
||||||
|
ResHandle := FindResource(Instance, PChar(ResName), PChar(RT_BITMAP));
|
||||||
|
if ResHandle <> 0 then
|
||||||
|
begin
|
||||||
|
Result := TBitmap.Create;
|
||||||
|
Result.LoadFromResourceName(Instance, ResName);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
ResHandle := FindResource(Instance, PChar(ResName), PChar(RT_RCDATA));
|
||||||
|
if ResHandle <> 0 then
|
||||||
|
begin
|
||||||
|
Result := TPortableNetworkGraphic.Create;
|
||||||
|
Result.LoadFromResourceName(Instance, ResName);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function CreateBitmapFromLazarusResource(const AName: String; AMinimumClass: TCustomBitmapClass): TCustomBitmap;
|
function CreateBitmapFromLazarusResource(const AName: String; AMinimumClass: TCustomBitmapClass): TCustomBitmap;
|
||||||
var
|
var
|
||||||
Stream: TLazarusResourceStream;
|
Stream: TLazarusResourceStream;
|
||||||
|
@ -64,9 +64,9 @@ begin
|
|||||||
inherited Click;
|
inherited Click;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomBitBtn.LoadGlyphFromResource(const AName: String);
|
procedure TCustomBitBtn.LoadGlyphFromResourceName(Instance: THandle; const AName: String);
|
||||||
begin
|
begin
|
||||||
Buttons.LoadGlyphFromResource(FButtonGlyph, AName);
|
Buttons.LoadGlyphFromResourceName(FButtonGlyph, Instance, AName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomBitBtn.LoadGlyphFromLazarusResource(const AName: String);
|
procedure TCustomBitBtn.LoadGlyphFromLazarusResource(const AName: String);
|
||||||
|
@ -281,7 +281,7 @@ begin
|
|||||||
if CurButtonType in [nbPrior,nbNext] then
|
if CurButtonType in [nbPrior,nbNext] then
|
||||||
CurButton.NavStyle:=CurButton.NavStyle+[nsAllowTimer];
|
CurButton.NavStyle:=CurButton.NavStyle+[nsAllowTimer];
|
||||||
//Load default images
|
//Load default images
|
||||||
CurButton.LoadGlyphFromResource(DBNavButtonResourceName[CurButtonType]);
|
CurButton.LoadGlyphFromResourceName(hInstance, DBNavButtonResourceName[CurButtonType]);
|
||||||
//Apply custom images if available
|
//Apply custom images if available
|
||||||
if Assigned(FImages) and (Ord(CurButtontype) < FImages.Count) then
|
if Assigned(FImages) and (Ord(CurButtontype) < FImages.Count) then
|
||||||
FImages.GetBitmap(Ord(CurButtonType), CurButton.Glyph);
|
FImages.GetBitmap(Ord(CurButtonType), CurButton.Glyph);
|
||||||
@ -314,7 +314,7 @@ begin
|
|||||||
if CurButtonType in [nbPrior,nbNext] then
|
if CurButtonType in [nbPrior,nbNext] then
|
||||||
CurFocusableButton.NavStyle:=CurFocusableButton.NavStyle+[nsAllowTimer];
|
CurFocusableButton.NavStyle:=CurFocusableButton.NavStyle+[nsAllowTimer];
|
||||||
//Load default images
|
//Load default images
|
||||||
CurFocusableButton.LoadGlyphFromResource(DBNavButtonResourceName[CurButtonType]);
|
CurFocusableButton.LoadGlyphFromResourceName(hInstance, DBNavButtonResourceName[CurButtonType]);
|
||||||
//Apply custom images if available
|
//Apply custom images if available
|
||||||
if Assigned(FImages) and (Ord(CurButtontype) < FImages.Count) then
|
if Assigned(FImages) and (Ord(CurButtontype) < FImages.Count) then
|
||||||
FImages.GetBitmap(Ord(CurButtonType), CurFocusableButton.Glyph);
|
FImages.GetBitmap(Ord(CurButtonType), CurFocusableButton.Glyph);
|
||||||
|
@ -970,9 +970,9 @@ begin
|
|||||||
SetDown(FDownLoaded);
|
SetDown(FDownLoaded);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSpeedButton.LoadGlyphFromResource(const AName: String);
|
procedure TCustomSpeedButton.LoadGlyphFromResourceName(Instance: THandle; const AName: String);
|
||||||
begin
|
begin
|
||||||
Buttons.LoadGlyphFromResource(FGlyph, AName);
|
Buttons.LoadGlyphFromResourceName(FGlyph, Instance, AName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSpeedButton.LoadGlyphFromLazarusResource(const AName: String);
|
procedure TCustomSpeedButton.LoadGlyphFromLazarusResource(const AName: String);
|
||||||
|
Loading…
Reference in New Issue
Block a user