Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Share tech news, updates, or what's on your mind.

Sign up to Post

i am currently try to remove node background white color i try to use TargetCanvas.Brush.Style := bsClear; inside BeforeCellPaint event but the white background of node still visible how do i remove that white back ground color of node ? here what i tried

procedure TForm2.VTs1BeforeCellPaint(Sender: TBaseVirtualTree;   TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;   CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); 
var Data: PUData;
 Data := VTS1.GetNodeData(Node);
  if not Assigned(Node) then Exit;
 TargetCanvas.Brush.Style := bsClear;

Open in new window

I updated Delphi 6's TShellTreeView component using the download from

After getting this update the component appears to work ok but it isn't easy to see which folder is currently open. The folder icon changes from a closed file icon to an open one but the visible difference is really small and our users are often elderly and find it hard to see which folder is open. If the component has keyboard focus then the whole folder name is highlighted and you can see it easily, but I'd like it to be subtly highlighted even when it doesn't have focus - just like a Windows Explorer folder tree.

The attached screen shots show  TShellTreeView with and without keyboard focus, and Windows Explorer with and without keyboard focus.

My question is: how can I add the subtle focus in that Pascal code? I can't find where to do it.  TShellTreeView.TIF
When I add lookup field to SQLQuery field definitions then some other string field is not displaying data in DBGrid. Just empty column. When I remove lookup field then fields displays correctly. If I add two lookup fields then two another fields don't display data.

I use Lazarus standard components.

What could be wrong?

I have a simple process with ADOquery running on a timer event, but I keep losing memory, memory keep increasing, in about 12 hours increased from 35MB to 75MB

The code
  TNotifyPolicy = record
    ID: String;
    Title: String;
    EmpID: String;
    EmpName: String;
    DeptName: String;
    DeptID: String;
    OrgID: String;
    OrgName: String;
    Email: String;
    ReportedTo: String;
    DeptEmail: String;
    ShowBeginLate: Boolean;
    ShowOutEarly: Boolean;
    ShowGap: Boolean;
    ShowAbsentTime: Boolean;
    ShowAbsent: Boolean;
    ShowMissPunch: Boolean;
    ShowErrorPunch: Boolean;
    ShowContAbsent: Boolean;
    AbsentCntToNotify: Integer; 
    CAResetOnOffDay: Boolean; 
    SendEmail: Boolean;
    SendEndOfShift: Boolean;
    SendFrom: String;
    SendTo: String;
    SendCC: String;
    SendBCC: String;
    EmailSubject: String;
    EmailMsgText: String;
    SMTP: String;
    SMTPPORT: Integer;
    SMTPTYPE: Integer;
    SMTPUSERID: String;
    SMTPPWD: String;
    TranslateTXT: String;
Function TemxNotify.GetNotifyPolicy(EmpID: String): TNotifyPolicy;
      {get notify policy for employee}
      qryNotifyPolicy.SQL.Text := Format('SELECT * FROM VEMPNOTIFYLST WHERE NPEMID = ''%s''', [EmpID]);

      {if not found get default notify policy}
      if qryNotifyPolicy.IsEmpty then begin
        qryNotifyPolicy.SQL.Text := 

Open in new window

I build an application using delphi 2007, and I am using ADO as database connection object.
in the application there is about 200 ADODataset\ADOQuery all those are connected to one ADOConnection and they exists in deferent Forms. The application can work with MSSQL server or Oracle.
The application works perfectly, but some times specially when I am using Oracle as backend, I am receiving an error "Object was open"
This error raise sometimes from deferent places. for example I open customer form, and I work on it, and it is perfect, but some times it raise the error "Object was open", If close the form and I open it again it works.

So the error happens specially when the application is connected to oracle database.
and it happens suddenly in deferent forms, and there is no way to follow certain steps to raise the error.
Please a solution

Note: I do not how to give a point on this questions
I will make this as short as possible

I have a Turbo Pascal (7.0 I think) OLD DOS APP - Which I am upgrading for customers that need to get to updated software/hardware "Windows 8.1,10.0, etc"
I have been able to get (VDOS) to work on all aspects except for printing with OS 8.1

Here is the Problem - the DOS software will work on 8.1 and new hardware except when trying to print from the LASER PRINTING version of the OLD DOS CODE - prints fine without those BMP'S - when I config the invoices to printout on the BMP files I get nothing - NO ERROR OR PRINTOUT -


Don't have and can't get the original source and the original PROGRAMMER will not help in any way
Need more development time to finish code for new release! - which is why I must find a solution NOW!
Hi there,

I am trying to export data to Excel from a Lazarus application using OLE.
When I try to add a value in a cell it works, but as soon as I try to add a formula in a cell I receive an error message.

procedure TForm1.Button1Click(Sender: TObject);
var XLApp: OLEVariant;
    x, y: Byte;
    tmpValue: Variant;
  // bron:
  XLApp := CreateOleObject('Excel.Application');
    XLApp.Visible := true;
    XLApp.DisplayAlerts := False;
    XLApp.Workbooks.Add; // alternatief: XLApp.Workbooks.Open(filename);

    // Column headers...
    For x := 0 to Query1.FieldCount-1 do begin
      tmpValue := Query1.FieldDefs.Items[x].Name;
      XLApp.Cells[1, x+1] := tmpValue;

    tmpValue := '% actual/max';
    XLApp.Cells[1, x+2].Value := tmpValue;

    // Data...
    y := 2;
    while not Query1.Eof do begin
      for x := 0 to Query1.FieldCount-1 do begin
        tmpValue := Query1.Fields[x].Value;
        XLApp.Cells.Item[y, x+1].Value := tmpValue;

      tmpValue := 'IF(I2<>0;(100*J2)/I2;0)';
      XLApp.Cells[y, x+3].Value := tmpValue;


    // Formatting...
    XLApp.Range['A1:XFD1'].Font.Bold := true;

    XLAPP := Unassigned;

Open in new window

The problem code is at line 30 and 31.

What is going wrong here? I'm working in a Windows environment.

Thank you for your help!

Kind Regards,
Hi there,

I am trying to save files which are stored in BLOB fields in a Sybase database.

The routine below seems to work, files are being saved in my folder, but when opening them they seem to be corrupt. For example when I open a Word or Excel file it needs to be repaired (by Office) before I can read the contents.

procedure TForm1.saveBlobs;
var tmpFilename: String;
    tmpList: TStringList;
  While not Query1.Eof do begin
    tmpFilename := prgPath + '_output\' + Query1.FieldByName('DOCU_ORG_FILENAME').AsString;

    tmpList := TStringList.Create;


Open in new window

Could my routine be the root cause of these corruptions?

Could you please help me out? Notice: I am using Lazarus (@Windows), not all Delphi stuff is available.

Kind Regards,
Delphi XE8

when i compile my code i can see that some lines are not compiled. Due to this issue some codes does not execute according to the way i want.
i have attached a screenshot of the delphi IDE in the debug mode. Blue dots on the left shows the lines which are compiled and those lines without the blue dots does not function properly or not complied
As can see on the watch window that variable dPcnt value is 0 taxP, srvP, serv_charge does not have a proper value but in the code window can see that the variables have been initialized to 0
Can someone help me out to correct the issue.
i have a global bolean variable in one unit, to pass it as a reference to the constructor in another unit i do by:

Constructor Create(var myBol:Boolean);

But it will only exist in the constructor, and die when the constructor dies. How do i make this reference stay alive in the object as long as the instance exists?

I tried this (and it did not work)

(in the interface)
    var gBol:Boolean;

and then in the constructor:


but it does not work. What is the proper way to do this?
Working in Pascal, I would like a regular expression that can split a string into 3 parts. The string to be split will always be 1 or more digits, followed by 1 or 2 letters, followed by 1 or more digits.

Examples are '1A1', 12B6', '4AA17'.

These should be split into [1, A, 1], [12, B, 6] and [4, AA, 17].

The Pascal code will look like this:
  ResultArray: TArray<string>;
  MyRegEx: string;
  MyRegEx := 'The RegEx I am looking for';
  ResultArray := nil;
    ResultArray := TRegEx.Split(MyInputString, MyRegEx);

Open in new window

Is it possible to do this with a single regular expression?
Hi all,

I want to be able to use 'Inno Setup' ( to not only install a WIndows exe file but to also pin a shortcut to the installed App in the Task Bar.

I've found this link:
But unable to get it working properly.

Is someone able to give me some advice on how to get it working or another solution that may work?

I can determine if the computer are in secure boot (UEFI) or not with this function:

GetFirmwareEnvironmentVariableA('','{00000000-0000-0000-0000-000000000000}', nil,0);
    if (GetLastError = ERROR_INVALID_FUNCTION) then
      Writeln('Legacy BIOS')
      Writeln('UEFI Boot Mode');
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);

Open in new window

But i need disable this option without change directly on BIOS, how i can do it with delphi?
How can I get notified when a TPopupMenu closes? (Not just by clicking on a menu item but also when closing the popup menu with the Esc key or by clicking elsewhere).

It MUST be a TPopupMenu.

Delphi XE8
I am writing an Intraweb application that has a login form. When I submit the login details it seems the form fields are submitted using a get request. Is there a way to force the form submission to be done through a POST request in Intraweb?
have a serious problem - that's endangering a project of mine -
I have to mine out the data of the attached file (and many others like 'em)

the file is a TURBO PASCAL file (version 7 "I BELIEVE") and I'm wondering if anybody can tell me how go get it to a ".csv", ACSII text, or anything I can read - and no I don 't have any table layouts and the original PROGRAMMER did not work out

If I can see the data I believe I can figure out the layout and then get them to a .mdb  or something that my new code can read
I will rename the file to a .txt so I can upload.
 the file is a ".dat" originally
I am trying to send virtual mouse clicks to a flash object in Twebbrowser. I couldn't achive it by delphi
on the otherhand it seems they achived it in C or C# can someone help me to convert this code into pascal please?
thank you

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName,int nMaxCount);

Open in new window

IntPtr handle = webBrowser1.Handle;
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "Internet Explorer_Server") // your mileage may vary with this classname
   handle = GetWindow(handle, 5); // 5 == child
   GetClassName(handle, className, className.Capacity);
IntPtr lParam = (IntPtr)((y << 16) | x); // X and Y coordinates of the click
const IntPtr wParam = IntPtr.Zero; // change this if you want to simulate Ctrl-Click and such
const uint downCode = 0x201; // these codes are for single left clicks
const uint upCode   = 0x202;
SendMessage(handle, downCode, wParam, lParam); // mousedown
SendMessage(handle, upCode, wParam, lParam); // mouseup

Open in new window

and also there is another in here but I am not sure which is the best

Open in new window

I am trying to use SHBrowseForFolder to select a folder.
The callback procedure is preselecting a specific folder.

function SelectFolder(Caption, DefPath: string): string;
  bi: TBrowseInfo; 
  lpBuffer: PChar; 
  pidlPrograms, pidlBrowse: PItemIDList; 

  function BrowseCallbackProc(hwnd: HWND; uMsg: UINT; lParam: Cardinal; 
    lpData: Cardinal): Integer; stdcall; 
    PathName: array[0..MAX_PATH] of Char; 
    case uMsg of 
        SendMessage(Hwnd, BFFM_SETSELECTION, Ord(True), Integer(lpData));
          SHGetPathFromIDList(PItemIDList(lParam), @PathName); 
          SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, Longint(PChar(@PathName))); 
    Result := 0; 
  if (not SUCCEEDED(SHGetSpecialFolderLocation(GetActiveWindow, CSIDL_DRIVES, 
    pidlPrograms))) then exit; 

  GetMem(lpBuffer, MAX_PATH );

  FillChar(BI, SizeOf(BrowseInfo), 0); 
  bi.hwndOwner := GetActiveWindow; 
  bi.pidlRoot := pidlPrograms; 
  bi.pszDisplayName := lpBuffer; 
  bi.lpszTitle := PChar(Caption); 
  bi.lpfn := @BrowseCallbackProc; 
  bi.lParam := Integer(PChar(DefPath)); 

  pidlBrowse := SHBrowseForFolder(bi); 

Open in new window

This works fine with 32-bit.
If i compile with 64 bit then it does not work.
BrowseCallbackProc is called twice - but uMsg is not 1 and 2 (like in the 32 bit version) but 0 the first time and the second time it is a high value.

Can anybody tell me where the problem is?

Windows 7 64 bit, Delphi XE6 & XE7
0, vs2012

I have an old "TURBO PASCAL" database (7.0 version (I BELIEVE!!))  "a whole bunch of .DAT files."
and I must bring them to (THE 21ST CENTURY) AND a SQL SERVER database

even if I can get the Pascal data to an comma delimited ASCII file - I think I can take it from there
but I have not a clue on how to mine the data from those old Pascal files!!

And I have very little time, CAN ANYONE TELL ME WHERE TO START, ON THIS ISSUE????
Hi, I'm trying to do a color-coding kind of thing where the user types characters in an Edit box and depending on the character he types in, it turns a certain color. For example if he typed in a alphabetic (a-Z) character it would be black... if he typed in a '#' or a "?" character, it would turn green. Also, I'd like to be able to allow the user to "toggle" those green characters to red just by double-clicking (or right-clicking) on the character position. Can this be done?


P.S: I use Delphi 7.

I just install new Delphi XE7 IDE in my PC...

When i try to compile one project (Any project. Even a blank project), the next error appear:

Checking project dependencies...
Compiling Project1.dproj (Debug, Win32)
Object reference not set to an instance of an object
[Fatal Error] Object reference not set to an instance of an object

I need help to solve this...

i have uploaded the files

there is a DBT too, how can link that too?
I have the following example unit. How do I make TSinceDateTime so that it will not compile the code inside "ErrorConvert" and successfully compile the code in "SuccessConvert" ?  Basically, I want to have a TDateTime type that is a primary type similar to TDateTime in that it can hold a timestamp, but I want the compiler to check that I don't mix those two in my source code. I would like to avoid making TSinceDateTime as a class, because then I have to instantiate that in all my already existing code.

unit MyUnit;


uses SysUtils, Windows;

  TSinceDateTime = type Double;

function ErrorConvert(sdt : TSinceDateTime) : TDateTime;
function SuccessConvert(sdt : TSinceDateTime) : TDateTime;


function ErrorConvert(sdt : TSinceDateTime) : TDateTime;
  Result := sdt; // Should not compile

function SuccessConvert(sdt : TSinceDateTime) : TDateTime;
  Result := TDateTime(sdt); // Should compile


Open in new window

I have a tchart on my form. I draw it by programatically plotting points to a point series. The chart is small on the form and I would like to be able to see it appear as large as the form temporarily. Is there some easy way to make a chart on a form temporarily expand, covering the other objects without moving them ? Otherwise what i am thinking is having a child window open with a tchart on it. Then my question becomes, is there a way to copy the original tchart with the plotted points already on it, to another tchart on a child form ? Or do I need to redraw the points on the second tchart ? Or can I have two charts with the same name that mirror each other so the second tchart is automatically a clone of the first ?
Delphi XE,

I need to protect some files from deleting, files blong to my user mode application.
Need to put code in service which will protect certain files from delete or modification, but still file must be accessed to my app fully not others.
Please advice.


Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Top Experts In

No Top Experts for this time period. Answer questions to earn the title!