In DelphiXe I create through the master of projects the new applet of the Control panel, I change an icon, the name, etc.
To activation reactions I write Showmessage (' Test '); Compile, receive dll, rename in *.cpl. In a win.explorer at start of this file the message appears.
In WinXp I insert this file in c:\windows\system32, open Control panel Windows, I see the applet and at its start the test message stands out.
I make too most on Win7x64 (or on 2008r2), but in the control panel of the applet I do not observe, reboot of a problem does not solve.
Tried to duplicate a file in c:\windows\syswow64, too there is no result.
How to force the applet will appear in the panel under Win7?
Code:
library Project1;
uses
CtlPanel,
AppletModule1 in 'AppletModule1.pas' {AppletModule1AppletModule: TAppletModule};
exports CPlApplet;
{$R *.RES}
{$E cpl}
begin
Application.Initialize;
Application.CreateForm(TAppletModule1AppletModule, AppletModule1AppletModule);
Application.Run;
end.
////////////// and Unit module
unit AppletModule1;
interface
uses
Windows, Messages, SysUtils, Classes, CtlPanel, Dialogs;
type
TAppletModule1AppletModule = class(TAppletModule)
procedure AppletModuleActivate(Sender: TObject; Data: Integer);
private
{ private declarations }
protected
{ protected declarations }
public
{ public declarations }
end;
var
AppletModule1AppletModule: TAppletModule1AppletModule;
implementation
{$R *.DFM}
procedure TAppletModule1AppletModule.AppletModuleActivate(Sender: TObject;
Data: Integer);
begin
Showmessage('Test');
end;
end.
On XP, you can drop the .cpl file into the system folder and be done with it:
How to Register DLL Control Panel Items
As of Windows XP, new Control Panel item DLLs should be installed in the associated application's folder under the Program Files folder. Items that are stored in the System32 directory with a .cpl extension do not need to be registered; they are automatically shown in the Control Panel. All other Control Panel items that use CPlApplet must be registered in one of two ways:
If the Control Panel item is to be available to all users, register the path on a per-computer basis by adding a REG_EXPAND_SZ value to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Cpls subkey, set to the DLL path.
If the Control Panel item is to be available on a per-user basis, use HKEY_CURRENT_USER as the root key instead of HKEY_LOCAL_MACHINE.
However, on Vista and later, your .cpl applet needs to be registered in the Registry. Dropping it in the system folder may not be enough.
Developing for the Control Panel
Types of Control Panel Applets
There are three types of Control Panel applets:
Command objects—applets that run commands specified in the registry
Shell folders—applets open up in the Control Panel. Examples of shell folder applets are the Fonts Folder, Administrative Tools, Personalization, System, User Accounts, and Programs
CPLs—applets that implement the CplApplet function
Command objects are the easiest to implement.
Adding and Registering Your Own Applets and Tasks
Adding your own applet to Control Panel is easier in Windows Vista. Software developers can now easily add their own applets and tasks to Control Panel.
In previous versions of Windows, you add applets to the Control Panel by using the Windows Registry and the CplApplet function. The operating system uses the Registry to enumerate the modules containing the applets. Each module's CplApplet function is called to display the applet, its icon and description, and then invoke the applet. This process is more complicated than using command objects because the applet must implement the CplApplet Interface. Although this process is still supported in Windows Vista, using command objects is encouraged since it is easier to implement.
Now, in Windows Vista, you can just write an executable (.exe), register it as a command object and the applet appears in Control Panel. For example, you can write an executable, MySystemApplet.exe, for your applet and add the applet to Control Panel by simply registering MySystemApplet.exe as a shell command object instead of tediously modifying the binary with an implementation of the CplApplet interface.
Related
For example: I define a ClientSocket1 variable in TForm1, and use ClientSocket1 in TForm1.Button1Click procedure:
procedure TForm1.Button1Click(Sender: TObject);
begin
if ClientSocke{ready to completion} then
end;
I press Ctrl+Space , But System Input Method was shown instead of completion,
please looking following gif animation screen record for explanation(please note the right bottom corner of the input method activity)
In Lazarus , I can use Ctrl+W to complete related variable in Unit, However I cannot do the same operation in Delphi, and the Delphi CTRL+Space is conflict with system input method.
If you want to change the default hotkeys for Delphi code editor there are few available presets in Tools -> Options -> Editor options - Key mappings.
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Key_Mappings
It is possible to install additional presets through Open Tools API.
Amongst the provided presets are also New IDE Emacs and New IDE Clasic which are such custom key mappings installed into Delphi IDE through the Open Tools API.
According to documentation you can find ready examples for changing these in Samples > Delphi > VCL > ToolsAPI > Editor KeyBinding, but I can't find such example on my computer. Perhaps it is because I only own Professional edition of Delphi.
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/New_IDE_Classic_and_New_IDE_Emacs_Keyboard_Shortcuts
it is bug in Delphi IDE,
only close the Delphi and restart it again
I'm testing on Delphi 2007 and my groupproject is composed by 2 packages.
PackageRun.bpl
It's marked as "runtime only" and contains a unit named "uMyTestRun.pas" in which is defined an empty TFrame descendant:
unit uMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
PackageDes.bpl
It requires PackageRun.bpl, it's marked as "designtime only" and contains a unit named "uMyTestDes.pas" in which I wrote the following code:
unit uMyTestDes;
interface
uses
Classes,
uMyTestRun;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Output directories of both packages are in Library paths (Inside there are bpl, dcp and dcu).
Trying to install PackageDes.bpl (Component, Install Packages..., Add...), I'm getting the following error:
Can't load package C:\<...>\PackageDes.bpl. Impossibile trovare il
modulo specificato.
The last part of the message is in my OS's language, in english it should be something like "Can't find specified module". (My OS is Windows 10 Pro 64bit).
PackageDes.bpl is exactly in the same path shown in the error message (C:\<...>\PackageDes.bpl).
After some tests, I found that the error disappear by removing the following line from uMyTestDes.pas unit:
RegisterComponents('MyComponents', [TMyTest]);
Is there something wrong in my code/projects/environment?
Run Process Monitor from http://SysInternals.com and set the filters to intercept only file operations ( toolbar rightmost buttons ) of your Delphi IDE process (check the process name in TaskManager or shortcut properties (it is bds.exe for Delphi XE2), then add the filter similar to Include / Process Name / Ends With / bds.exe ).
Then clear the log in PM, switch to Delphi and try to load the package, then as soon as error pops up switch back to PM and stop capturing events. Try to do it fast as you can, for example do not waste your time closing error box.
Now you would get a trace of file I/O activity of Delphi loading the package of yours (and some other background activity noise - the faster you do the less noise there'd be). In that trace look for all the errors and see where and which package Delphi tries to find.
You can also try Microsoft Dependency Walker or similar tools to se if your Design-Time BPL has all the DLL-dependency tree resolvable. Personally I usually use Unreal/Total commander with FileInfo plugin or ntCore CFF Explorer.
Easy way to solve this issue is to add a post build action to your run time project:
copy "$(OUTPUTDIR)\$(OUTPUTFILENAME)" "$(BDSCOMMONDIR)\Bpl"
The command above copies your run time file to the default IDE Bpl location.
I had a similar issue. In my case I had the same library name in a different Delphi version BPL path. I found out the solution for my issue looking at the comments above, so this is only a reminder for basic things to check:
BPL path have to be included in your OS path variable;
Search for a BPL module with the same name in other OS path before the right one (mutiple Delphi version installations).
Try to change the register procedure to uMyTestRun unit.
unit UMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Now, the package will install correctly.
Regards.
Create a new VCL Forms application
On the main form add a Tbutton and a TSaveDialog
Set "ofOverwritePrompt" to True in properties for the SaveDialog1
Use:
procedure TForm1.Button1Click(Sender: TObject);
begin
SaveDialog1.Execute();
end;
Run the app. Press the button to execute the save dialog. Try to save to a file that already exists.
A message box appears if you want to replace the file. Press cancel. All fine so far. Close the app.
Go to Project/Options/Application/Appearance and select a Custom style (e.g. Amakrits). Set Amakrits as the default style.
Run the app as in #5 above. Only a small bit of the message box will be shown. You will have to press Enter to be able to continue.
(Using a TFileSaveDialog will give the same result)
If I compile and run the app using Delphi XE8 it will be ok since the save dialog window seems to use the default windows style even if another style is chosen.
Edit:
I have Windows 10 pro. Source compiled as win32 with Delphi 10.1 Berlin.
The replace message box is partly hidden. Only a small top left part is shown, see figure.
And here it is compiled with XE8 win32:
Ps. I am using the default 100% scale factor.
Compiling with win64 (Delphi 10.1 Berlin) seems to be ok:
So, compiling to win32 does not work for me, but 64-bit will. Any clues?
Edit: Trying with "GetSaveFileName(OFN)" will also not work for me in win32 (win 64 is ok):
You can avoid this issue using the dialog styling code of the VCL Styles Utils project.
Just Add these units to your project.
uses
Vcl.Styles.Utils.Menus, //Popup and Shell Menus (class #32768)
Vcl.Styles.Utils.Forms, //dialogs box (class #32770)
Vcl.Styles.Utils.StdCtrls, //buttons, static, and so on
Vcl.Styles.Utils.ComCtrls, //SysTreeView32, SysListView32
Vcl.Styles.Utils.ScreenTips, //tooltips_class32 class
Vcl.Styles.Utils.SysControls,
Vcl.Styles.Utils.SysStyleHook;
{$R *.dfm}
procedure TForm26.Button1Click(Sender: TObject);
begin
UseLatestCommonDialogs := false;
SaveDialog1.Execute();
end;
I cannot confirm the problem, and all looks well here, (32 bit executalbe, themed with Amakrits, compiled with 10.1 Berlin, on Windows 7, 100% scaling) but you could try this:
uses ... Winapi.CommDlg;
...
var
OFN: TOpenFileName;
begin
FillChar(OFN, SizeOf(OFN), 0);
OFN.lStructSize := SizeOf(OFN);
OFN.nMaxFile := MAX_PATH;
OFN.Flags := OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ENABLESIZING or OFN_EXPLORER;
GetSaveFileName(OFN);
end;
The result is an Amakrits-themed, new Explorer-like save dialog, which works fine (for me). Only the two round, blue "back" and "forth" (<- and ->) buttons at the top left of the dialog look a little weird.
But I did not try this with custom scaling settings (e.g. Medium 125% in the Control Panel -> Display panel, etc.). I think this could influence such things.
Update
I just tried to use SaveDialog1 (commenting out the OFN code above) with custom Display scaling (125%). All looked fine, so that is not it. Also when I use the OFN code, all looks fine (actually, better, i.e. no XP style dialog, but a real Explorer-like dialog instead).
If I set "Enable High-DPI" to true in Project/Options/Application it will work (replace box properly displayed). Disabling it will cause the problem (both in win32 and win64).
For the record, I had exactly the same problem (Delphi 10.1 Berlin, compiling on Windows 10 64 bit, 100% screen settings, compiled for 32 bit target). Enabling or disabling High-DPMI awareness didn't help.
A workaround is to disable styles for dialog boxes before executing the TSaveDialog (or TOpenDialog) like this:
TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shDialogs];
The file dialog itself will still be themed. You will get standard Windows-style message boxes in case an overwrite prompt (or create prompt) pops up, but they will be large enough for the user to read and click them. After the file dialog has finished, you can enable styled dialogs again by re-adding shDialogs to SystemHooks if needed.
Let's admit, I create new package in Delphi Xe2. I keep under a name "My". I add a simple component "MyComponent". I compile, I receive file Bpl in C:\Users\Public\Documents\RAD Studio\9.0\Bpl\My.bpl.
I add a platform "Win x64".
I compile, I receive C:\Users\Public\Documents\RAD Studio\9.0\Bpl\Win64\My.bpl.
...\Bpl\Win64\My.bpl to establish as new package does not give, writes "is not windows x32 applications".
The first is established normally and on a palette the component appears "MyComponent".
If to bring to are mute the index of a mouse will appear hint where it will be written, that it x32-compatible.
And at native component Delphi - at all x32-64 compatible.
Together with a disk to Xe2 there is a free disk with Free and Tral components if to put therefrom for example OverByteIcs or Ip*Works, that at them at all components will be 32-64х compatibility.
Questions:
1. How to establish the x64 the version package?
2. How to achieve, that the component had a compatibility 32-64, and not just 32?
P.S. Bad English language: ON
The Delphi IDE is 32 bit and so can only load 32 bit designtime packages. You can of course create 64 bit runtime packages.
Has earned, has understood!
We create empty package
We add the component, for example Button and it is specified what platforms for a component (the key moment are necessary!)
Example
unit GuButton;
interface
uses
System. SysUtils, System. Classes, Vcl. Controls, Vcl. StdCtrls;
type
[ComponentPlatformsAttribute (pidWin32 or pidWin64)] // !!!!!!!!!!!!!!!
TButtonGu = class (TButton)
private
{Private declarations}
protected
{Protected declarations}
public
{Public declarations}
published
{Published declarations}
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents (' Gu ', [TButtonGu]);
end;
We keep, we compile under x32. We add a platform x64 (in options should be registered, that directories under platforms different).
We compile under x64. We receive 2 BPL (as in the first question). We establish x32. We look - new component ButtonGu - 32-64 compatible was added.
Here I that wanted, all thanks.
In addition http://docwiki.embarcadero.com/RADStudio/en/64-bit_Cross-Platform_Application_Development_for_Windows
I want to be able to open files in Delphi with a Windows GUI where you can scroll through the folders etc. I have already done this with Matlab with a single function that (after selecting the file) returns a string of the path. You could event specify which extension the be shown. Is this kind of function available in delphi and how should I use it.
you can use the TOpenDialog component which is part of the Dialogs unit. you can create in runtime or drop this component from the Dialogs palette.
if you drop the component to your form you can use in this way
OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
if OpenDialog1.Execute then
//do you stuff here
or if you create the component in runtime
Var
OpenDialog1 : TOpenDialog;
begin
OpenDialog1:=TOpenDialog.Create(nil);
try
OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
if OpenDialog1.Execute then
ShowMessage('Selected File '+OpenDialog1.FileName);
finally
OpenDialog1.Free;
end;
end;
That's available via TOpenDialog which encapsulates the relevant Windows functionality.
Drop a TOpenDialog component on your form. Then you can call OpenDialog1.Execute to show the Windows dialog.