- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个自定义组件,当鼠标移到它上面时显示一个图标。我正在加载这样的图标:
UNIT Test;
constructor TTestPath.Create(aOwner: TComponent);
VAR myIcon: TIcon;
begin
inherited Create(aOwner);
ImgList:= TImageList.Create(Self);
myicon := TIcon.Create;
TRY
myicon.LoadFromResourceName(HInstance, 'FOLDER'); <------ this becomes application's icon!
ImgList.AddIcon(myicon);
FINALLY
FreeAndNil(myicon);
end;
问题是,一旦我将 Test.pas 添加到测试应用程序的 USES 原因中,应用程序的图标(红色 delphi Helm )就会被“文件夹”图标替换。
更新:
EXE 文件中的图标按以下顺序排列:“FOLDER”、Default_Delphi_icon因此,TTestPath 的图标会添加到 exe 应用程序图标之前。
这里出了什么问题:TTestPath 的图标以这种方式出现在 EXE 文件中,或者它放置在应用程序的(默认)图标之前?
<小时/>控件的代码如下:
UNIT test;
INTERFACE
USES
System.SysUtils, Winapi.Windows, System.Classes, Vcl.StdCtrls, Vcl.Controls, Vcl.Graphics, vcl.imglist, Vcl.ExtCtrls; {$WARN GARBAGE OFF} {Silent the: 'W1011 Text after final END' warning }
TYPE
TValidity= (vaNone, vaValid, vaInvalid); { Normal / Green / Red color }
TInputType= (itFile, itFolder); { What kind of path will the user type in this control: folder or file }
TTestPath = class(TCustomGroupBox)
private
edtPath : TButtonedEdit;
btnApply : TButton;
btnExplore : TButton;
FInputType : TInputType;
imgList : TImageList;
FShowApplyBtn: Boolean;
protected
public
constructor Create(aOwner: TComponent); override;
published
property Align;
property Anchors;
property BiDiMode;
property Caption;
property Color;
property Constraints;
property Ctl3D;
property DockSite;
property DoubleBuffered;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Padding;
property ParentBackground default True;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentDoubleBuffered;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Touch;
property Visible;
property StyleElements;
property OnAlignInsertBefore;
property OnAlignPosition;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDockDrop;
property OnDockOver;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGesture;
property OnGetSiteInfo;
property OnMouseActivate;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
procedure Register;
IMPLEMENTATION {$R cPathEdit.res}
USES cIO;
constructor TTestPath.Create(aOwner: TComponent);
VAR myIcon: TIcon;
begin
inherited Create(aOwner);
Caption := 'Folder';
Height:= 41;
FShowApplyBtn:= TRUE;
ImgList:= TImageList.Create(Self); { Freed by Self }
myicon := TIcon.Create;
TRY
myicon.LoadFromResourceName(HInstance, 'FOLDER');
ImgList.AddIcon(myicon);
myicon.LoadFromResourceName(HInstance, 'FOLDER_OPEN');
ImgList.AddIcon(myicon);
FINALLY
FreeAndNil(myicon);
end;
edtPath:= TButtonedEdit.Create(Self);
WITH edtPath DO
begin
Parent := Self;
Align := alClient;
Margins.Left := 1;
Margins.Top := 2;
Margins.Right := 1;
Margins.Bottom := 1;
AlignWithMargins := TRUE;
Images := imgList;
TabOrder := 0 ;
OnChange := nil;
RightButton.Hint := 'Browse for a folder';
RightButton.ImageIndex:= 0;
RightButton.HotImageIndex:= 1;
RightButton.Visible := TRUE;
OnRightButtonClick := nil;
OnKeyPress := nil;
end;
btnExplore:= TButton.Create(Self);
WITH btnExplore DO
begin
Parent := Self;
Align := alRight;
Width := 22;
Margins.Left := 1;
Margins.Top := 1;
Margins.Right := 1;
Margins.Bottom := 1;
AlignWithMargins := TRUE;
Caption := '^';
TabOrder := 1;
Hint := 'Open this folder in Windows Explorer';
OnClick := nil;
end;
btnApply:= TButton.Create(Self);
WITH btnApply DO
begin
Parent := Self;
Align := alRight;
Width := 38;
Margins.Left := 1;
Margins.Top := 1;
Margins.Right := 1;
Margins.Bottom := 1;
AlignWithMargins := TRUE;
Hint := 'Create folder if necessary';
Caption := 'Apply';
TabOrder := 2;
OnClick := nil;
end;
FInputType:= itFolder;
end;
procedure Register;
begin
RegisterComponents('xxx', [TTestPath]);
end;
end.
测试应用:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, Forms,
test; <-------- this
type
TForm1 = class(TForm)
private
public
end;
var
Form1: TForm1;
IMPLEMENTATION
{$R *.dfm}
end.
最佳答案
由于 Embarcadero 做出了相当困惑的决定,图标资源在链接时按字母顺序排序。 Windows 规则是 shell 用于可执行文件的图标是第一个图标。 Delphi VCL 代码假定应用程序图标名为'MAINICON'
。
将这些要求放在一起,您可以推断出所有图标的名称必须按字母顺序出现在 'MAINICON'
之后。
这相当令人沮丧,但很容易解决。为您的图标采用合适的命名约定,一切都会按照您的预期运行。
为什么 Embarcadero 不更改他们的代码以确保首先发出名为 'MAINICON'
的图标,这让我无法理解。或者安排应用程序图标被定义为第一个,从而遵循平台的规则。但我们无能为力。
关于delphi - 从 RES 文件加载图标后,错误的图标用作默认图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39942848/
我正在使用 express并试图通过管道传输 req到远程服务器进行处理,然后通过 res 将结果通过管道传回客户端.它运行良好,但有时我认为 res由 connect-timeout 的操作结束,导
我正在尝试使用 fetch 进行简单的发布请求: const headers = new Headers({ Accept: 'application/json', 'Content-Type
我偶然发现了一个代码示例 here .引起我注意的行(跳过所有其他行): { ... void *res; ... s = pthread_join(tinfo[tnum].thread_id
我有一个 NodeJS 代码,使用请求模块向服务器发出请求。如果我使用“http.request”,代码工作正常,但在 res.on() 上显示错误使用请求来调用电话。以下是显示错误的部分: cons
我想知道这两种不同的方法在 expressjs 中是否相同? res.statusCode = 500; return res.json({ status: "error" }); 或者 r
我正在尝试在 Node.js 中制作简单的 ftp 客户端。一切正常,但我不知道如何在我的 Jade 模板中编写“singleFile.name”。 app.post('/ftp/login', fu
在frameworks/base下有这个xml文件。 /frameworks/base/core/res/res/layout/simple_dropdown_item_2line.xml 如何在我自
我是 odoo v8 的新手,我无法理解 res_partner 和 res_users 表之间的关系以及与 hr_employee 表之间的关系,它们都相关吗? 最佳答案 res.partner之间
我正在开发一个用于用户登录的小部件。基本上,当他们输入有效的帐户详细信息时,我希望它呈现相同的页面(使用 Handlebars )并声明“帐户已成功验证”之类的内容,然后 3 秒后重定向用户。 这是我
我有这种形式的数据 [ { device_id: '12335', timestamp: '2018-05-14T08:31:23.000Z', temperatur: 21,
我是 android 开发的新手,您可能会从我的问题中看出这一点。我发现我有一个 res/menu 文件夹和一个 res/layout 文件夹。它们都包含每个 Activity 的 XML 文件。但是
当我尝试按照指南中的说明在 res/menu 中创建新的菜单资源文件时,该文件夹不存在。 res/xml 也不是。有人可以告诉我如何解决这个问题吗?我尝试创建文件夹,但它不允许我这样做 最佳答案 如果
调用有什么区别: res.flushBuffer(); 对比 res.getOutputStream().flush(); 这些方法是否刷新相同的缓冲区? 如果是这样,你能告诉我这个缓冲区是如何由
为什么以下不起作用? res.send({ successMessage: 'Task saved successfully.' }); res.redirect('/'); 我基本上需要 A
我正在尝试确定是否可以同时调用 res.send(data) 和 res.render('reports')。 为了进一步详细解释,当我路由到“/reports”时,首先在我的服务器端我对返回 jso
app.get('/p/:tagId', function(req, res) { res.send("tagId is set to " + req.param("tagId")); }); 上
我在使用express.js 时遇到一些问题。我想在第一次请求时渲染我的模板,然后从路由中获取一些数据。我的路由如下所示: app.use(function (req, res, next) { r
我想根据屏幕尺寸加载 dimens.xml,但无论屏幕尺寸如何都使用相同的颜色。 我有以下目录结构 res res/values colors.xml res/values-small d
我有一张图片,rectangle.png。它的尺寸是 75x197。它位于 res/drawable 和 res/drawable-xhdpi。它在像这样的网格布局中显示了很多次(截图来自 Nexus
我很好奇返回响应和仅创建响应的区别。 我见过大量使用 return res.status(xxx).json(x) 的代码示例和res.status(xxx).json(x) . 谁能详细解释一下两者
我是一名优秀的程序员,十分优秀!