Hi my dear friends!
Here I come...to ask for the impossible!
I have a TEdit, which I fill with the string: 'This line is far too long we should shorten it a bit!'
Now the TEdit is too small to display the entire string, so I use MinimizeName and get something like >
'This line ...a bit!'
Now I want to have some kind of mechanism which helps me to write and read to and from the registry so the TEdit displays 'This line ...a bit!' while the actual string that is written to the registry is: 'This line is far too long we should shorten it a bit!'
Moreover, when the TEdit reads from the registry it should also read: 'This line is far too long we should shorten it a bit!' but display > 'This line ...a bit!'
Is this abacadabra enough to you wizards? To me it is....if you need more info...please ask. What I'n trying to do here is configure the Open Dialog Places Bar. The 5 shortcuts located on the far left when you open a document in Notepad for example.
Currently my TEdit displays for example:'K:\ 06 xp iso\ 01 xp iso unattended instal'
While the actual contents is: 'K:\ 06 xp iso\ 01 xp iso unattended installs\xp sp2 pro nl 251006 working_iso\xp sp2 pro nl 251006 working.iso'
So I have no idea where it leads to....If I could simply display only the last foldername...it would be great..but then again...how to make sure that the correct path is stored in teh registry and not just simply only the foldername?
Get the idea?
Kind regards,
Paul
Ps workin samples do the trick....heres the code fragment that fills my TEdits with the paths to the folders I want shortcuts to:
procedure TMainfrm.ButtonClick(Sende
r: TObject);
var
lpbi: TBrowseInfo;
pidlStart: PItemIDList;
Malloc: IMalloc;
sFolder: string;
pidlSelected: PItemIDList;
Edit: TEdit;
begin
SHGetSpecialFolderLocation
(Handle, $11, pidlStart);
SHGetMalloc(Malloc);
with lpbi do
begin
hwndOwner := Handle;
pidlRoot := pidlStart;
GetMem(pszDisplayName, MAX_PATH);
lpszTitle := PChar('Selecteer folder');
ulFlags := $00000001;
lpfn := nil;
end;
pidlSelected := SHBrowseForFolder(lpbi);
if pidlSelected <> nil then
begin
if SHGetPathFromIDList(pidlSe
lected, lpbi.pszDisplayName) then
sFolder := StrPas(lpbi.pszDisplayName
);
if (Sender is TsuiButton) then
begin
Edit := FindComponent('edt' + Copy((Sender as TsuiButton).Name, 4, 255)) as
TEdit;
Edit.Text := sFolder;
Canvas.Font := Edit.Font;
Edit.Text := MinimizeName(sFolder,Canva
s,edit.Wid
th); { this is great! but when this takes effect an invalid folder reference is saved to the registry...obviously. A work aroudn for this???}
Malloc.Free(pidlSelected);
end;
if lblWarning.Visible = False then
lblWarning.Visible := True;
if imgWarning.Visible = False
then imgWarning.Visible := True;
FreeMem(lpbi.pszDisplayNam
e);
Malloc.Free(pidlStart);
end;
end;
This is the code fragment which shows how I write the TEdits content to the registry (all credits go the RLibby for this tremendous piece of code!!)
procedure TMainfrm.btnOKClick(Sender
: TObject);
begin
if (mrYes = MessageDlg('Alle wijzigingen worden opgeslagen. Doorgaan?', mtConfirmation, [mbYes, mbNo], 0)) then
begin
SetRegistryData(HKEY_CURRE
NT_USER, PlacesBar,'place0',rdStrin
g,edt1.Tex
t);
SetRegistryData(HKEY_CURRE
NT_USER, PlacesBar,'place1',rdStrin
g,edt2.Tex
t);
SetRegistryData(HKEY_CURRE
NT_USER, PlacesBar,'place2',rdStrin
g,edt3.Tex
t);
SetRegistryData(HKEY_CURRE
NT_USER, PlacesBar,'place3',rdStrin
g,edt4.Tex
t);
SetRegistryData(HKEY_CURRE
NT_USER, PlacesBar,'place4',rdStrin
g,edt5.Tex
t);
Close;
end;
end;