picture

Archive for the ‘Delphi’ Category

Disconnect mapped network drive in Windows 7. Error “This network connection does not exist”

Friday, April 20th, 2012

I spent some time today to find out, how to disconnect a network drive in Windows 7. Using NET USE command or the explorer function “Disconnect” resulted in message “This network connection does not exist”. One saw a network drive in explore, but it was red X-ed. Using gpedit.msc sloved my issue. The link below describes the solution:
http://forums.windowsforum.org/index.php?showtopic=46984

Open Folder Dialog in Delphi

Tuesday, November 1st, 2011

The function below uses ShellAPI and implements Open Folder Dialog. This function works fine on Windows XP and Windows7 as well.
(more…)

How to Copy Data from Grid and paste it into Excel

Friday, July 22nd, 2011

If you want to copy some lines of data from a Grid (Ctrl+C) and paste (Ctrl+V) it into an Excel document, just use following code:


procedure MyForm.Button1Click(Sender: TObject);
var
  i, j: integer;
  lString: string;
begin
  lString := '';
  for i := 0 to Grid.RowCount - 1 do begin
    for j := 0 to Grid.ColCount - 1 do begin
      lString := lString + Grid.Cells[j, i];
      if j < Grid.ColCount - 1 then
        lString := lString + #9;
    end;
    if i < Grid.RowCount - 1 then
      lString := lString + #13;
  end;
  Clipboard.AsText := lString;
end;

With few modifications this code can be also applied to TDrawGridEx.

Xml Alternative for Delphi’s INI Files.

Thursday, March 31st, 2011

I found on the net the way how to use XML files instead of Delphi ini-files. The advantage of xml uasage is that you could extend the code by methods for iterating through the sections and their entries.
(more…)

How to Make Modal Form?

Monday, April 26th, 2010

Just a short notice how to make modal forms in Delphi. Assume, you have two Forms: AForm and BForm. AForm is your main form and you want now to call B as modal form (a modal form is a child form that requires the user to interact with it before it gets possible to return to the parent form). So inside your AForm you call BForm in the following way: (more…)

Exception Handling in Delphi

Sunday, April 25th, 2010

Exceptions are a vital language structure of any modern programming language. This posting shows the usage of Delphi’s exceptions. (more…)

Problem with Synchronize-calls in DLLs

Wednesday, March 24th, 2010

If you use Synchronize() method for the synchronization of your thread with GUI, be ready to wonder, if this method does not work in DLLs. It’s a buggy feature of Delphi 2006. Peter Below offers a fix for this issue. The fix is to be found here. It is just one file that you add to your DLL. Afterwards Synchronize() works as expected.