Delphi

59K

Solutions

17K

Contributors

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

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

Sign up to Post

Hi

I have a SQL Server table with a varbinary-field in it. I want to insert that record in a MySQL-Database. How can I access this field-data?
myTable is local on a SQL Server
mySqlTable1 is on a MySQL Server in the web

Query1.SQL.Text := 'SELECT myString1, myVarBinary1 FROM myTable';
Query1.Execute;
mySqlQuery1.SQL.Text := 'INSERT INTO mySqlTable1 (str1, blob1) VALUES('+QuotedStr(Query1.FieldByName('myString1').AsString)+','+??myVarBinary1??)'

Open in new window

How can I access the varbinary-field? Something like Query1.FieldByName('myVarBinary1').As???
Thanks for any help
Peter
0
CompTIA Security+
LVL 13
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

I need to query an ASP.NET C # page using Delphi and the ICs overbyte TSslHttpCli component. I can get the login page with "GET" authenticate with "POST" but when making a query on an internal form using "POST" I am logged out with session expired.

I have a simple font doing the operations, who can help I send the fonts already working and showing where the error is.
0
I am using Delphi 7
I need to read/parse a cell in an Excel spreadsheet that displays #VALUE in Excel (ie. a formula with undefined input)

it crashes when I use
var
s80 : string ;
....
s80 := XLApp.Cells[row,col] ;

it clearly does not type caste properly.

So I tried to look at the variant type and act accordingly

var1 : variant ;
s80 : string ;
vt : TVarType ;
...
var1 := XLApp.Cells[row,col] ;
vt := VarType(var1) ;

if vt  = 9 then ... is ok ?
               else .... is a problem ?

vt always returns 9

See Variant Types
   http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Variants_VarType.html

so I am still unable to give cells with #VALUE a miss.

Suggestions please.
0
Hello,
  We have a PCL-1712 PCI Data aquicision device (DAQ). I want to get the data from analog input and pass the to analog output in almost realtime. The DaqNavi SDK contains and DAQ Emulator which you can use for programming/test. Since the SDK is buggy with Delphi it needs to be done in MFC/C++.

Anyone can program it ?

SDK Link: https://support.advantech.com/support/DownloadSRDetail_New.aspx?SR_ID=1-13L33UP&Doc_Source=Download

Thank you
0
Hello;
I have a program c++ which call a Delphi DLL; The Delphi DLL has to inform the program c++ by the result of his work several times during his lifecycle.

in yours opinions what are the possibles methods for doing this? without using files ou databases like a third part!

Thanks in advance.

I will list here what i think:

- First idea is by passing a pointer to delphi dll when launching it; but i don't know which types to use in the two sides and how Delphi treat pointers!

- Second idea is by using an intermediate c++ DLL; Delphi will call a function in the DLL C++ which will modify the values of the c++ dll variables. in the other side, when the c++ program launch the c++ dll, it will pass a pointer. When delphi call the c++ function, the function will fill the pointer passed by c++ program. Do you think that works?

I don't know if i was clear; Thank you
0
Hi !
I am using Delphi7 to develop program.
Firstly,TPrinter.GetPrinter function does not return value of port.The value of port is empty.

procedure TForm1.Button1Click(Sender: TOBject); 
var 
  hPrinter  : THandle; 
  pDevice : array[0..255] of Char; 
  pDriver  : array[0..255] of Char; 
  pPort     : array[0..255] of Char; 

begin 
  Printer.PrinterIndex := -1;
  Printer.GetPrinter(pDevice, pDriver, pPort, hPrinter);
  ShowMessage(pPort);       
end; 

Open in new window


 The following code return usb001 port with function Winspool.GetPrinter( hPrinter, 2, Nil, 0, @bytesNeeded ).
function GetCurrentPrinterHandle: THandle; 
var 
  Device, Driver, Port : array[0..255] of char; 
  hDeviceMode: THandle; 
begin 
  Printer.GetPrinter(Device, Driver, Port, hDeviceMode); 
  if not OpenPrinter(@Device, Result, nil) then 
    RaiseLastWin32Error; 
end;
 
function GetCurrentPrinterInformation: TPrinterInfo; 
var 
  hPrinter  : THandle; 
  pInfo:  PPrinterInfo2; 
  bytesNeeded: DWORD; 
begin 
  hprinter := GetCurrentPrinterHandle; 
  try 
    Winspool.GetPrinter( hPrinter, 2, Nil, 0, @bytesNeeded ); 
    pInfo := AllocMem( bytesNeeded ); 
    try 
      Winspool.GetPrinter( hPrinter, 2, pInfo, bytesNeeded, @bytesNeeded ); 
       Result.SeverName          := pInfo^.pServerName; 
       Result.PrinterName        := pInfo^.pPrinterName; 
       Result.ShareName          := pInfo^.pShareName; 
       Result.PortName           := pInfo^.pPortName; 
       Result.DriverName        

Open in new window

0
Hi Experts!

I have been using DataSnap REST for some weeks but I have problems understanding some concepts related to TJSONObject and how these data are sent.
I have three related questions.
I consider a simple class:


TMyclass = class
  private
    [JSONName('name')] // invio
    Fname: string;
    [JSONName('surname')] // invio
    Fsurname: string;
    [JSONName('mytext')] // invio
    Fmytext: string;

    procedure Setname(const Value: string);
    procedure Setsurname(const Value: string);
    procedure Setmytext(const Value: string);
  public
    property name: string read Fname write Setname;
    property surname: string read Fsurname write Setsurname;
    property mytext: string read Fmytext write Setmytext;
  end;
  
.....

procedure TMyclass.Setname(const Value: string);
begin
  Fname := Value;
end;

procedure TMyclass.Setsurname(const Value: string);
begin
  Fsurname := Value;
end;

procedure TMyclass.Setmytext(const Value: string);
begin
  Fmytext := Value;
end;  

Open in new window


.....

In my code I have something similar to:

Procedure TMain.Send_JSON;
var
   VJSONObject: TJSONObject;
   VMyclass:TMyclass;
begin
   VMyclass:=TMyclass.Create;

   VMyclass.name:='John';
   VMyclass.surname:='Ace';
   VMyclass.mytext:='';

   VJSONObject:=TJson.ObjectToJsonObject(VMyclass);
   //...
   
   RESTClient1.ResetToDefaults;
   RESTRequest1.ResetToDefaults;
   RESTResponse1.ResetToDefaults;
   RESTClient1.BaseURL:='http://111.222.333.444:8080/datasnap/rest/mypath';
   RESTRequest1.Timeout:=RESTRequest_Timeout;
   
   RESTRequest1.Resource:='/MyParam'; 
   RESTRequest1.Method:=TRESTRequestMethod.rmPOST; 
   RESTRequest1.AddBody(VJSONObject.ToJSON, ContentTypeFromString('application/json'));
   //...
   RESTRequest1.Execute;
   //...
end;

Open in new window



[First question]
When I send this JSON:
         {"name":"John","surname":"Ace","mytext":""}
i don't want to have:
"mytext":""
in the JSON.

[Second question]
I don't know a way to insert a JSON array like this:
{"name":"John","file": [{"name_file":"myfile1.txt","dir_file":"C:\mydir"},{"name_file":"myfile2.txt","dir_file":"C:\mydir2"},...]}

[Third question]
I am looking for a method to manipulate the:

VJSONObject.ToString

before insert in the:

RESTRequest1.AddBody(VJSONObject.ToJSON,...

but I couldn't find it. I search something like:

  VJSONObject := Json.StringToJsonObject(VJSONObject.ToString);

I have a lot of problems because there is no documentation on this part.
Does anyone have a solution?


Working with RAD Studio Tokyo 10.2.3
0
Hello,
I want to show a series in the chart. In the legend, the series should not be displayed.

I have the following plan. You can use the checkboxes to display one or more series in the legend.
If only one series has been selected, I add more series to shown in the chart,  but the new series should not be displayed in the legend.
The data for the series comes from a table.

Is that possible?
I did not find anything in the documentation:


http://www.teechart.net/docs/teechar...als/index.html
0
Hello,
in my form is a scrollbox.
Within the scrollbox I have a TImage.

1) The scrollbox should have only a scrollbar if the generated content does not fit on the image. Contents are drawings of rectangles.
2) The scrollbox should only be as high as the generated content, but should be at least X pixels high.
3) When I draw a rectangle out of the view, then the rectangle should be visible, when scrolling.

How can I implement this?
These questions are so important.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    Image1: TImage;
    procedure FormActivate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
  left:=5;
  top:=10;
  form1.Width:=Screen.Width-15;
  form1.Height:=Screen.Height-50;
  ScrollBox1.Align:=alClient;
  image1.Left:=0;
  image1.Top:=0;
  image1.Width:=ScrollBox1.Width;
  image1.Height:=ScrollBox1.Height;
  image1.Canvas.Rectangle(1400,50,2000,100);
end;

end.

Open in new window


Unbenannt.PNG

Thank you
0
Hello,
I have to know something urgent.
Is there a simple and reliable way around to  scroll automatically on scrollbox2 when scrollbox1 is scrolled.
I mean, when I scroll on scrollbox1 30px to the right, then  scrollbox2 should scroll 30px to the right, too.
When I scroll on scrollbox2 30px to the right, then  scrollbox1 should scroll 30px to the right

Thank you
0
Why Diversity in Tech Matters
LVL 13
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.


hi expert
I want to change the color of the top row of stringgrid.
I want to change the white color to gray.

ı want to increase the size of stringgrid line from left to right
thanks a lot.

I shared the features I want as pictures.

Ads-z.png
Adsiz2.png
0
Hello,
I would like to represent a DBChart depending on the values ​​in different colors.
I get the values ​​from the database.
The change of color I have managed.
How can I assign multiple values ​​to a series and graph them?


query1.open('select * from artikel');
  query1.First;
  while not query1.Eof do
  begin
    if query1.FieldByName('preis').Value < query1.FieldByName('minimum').Value then
      DBChart1.Series[1].Color:=clred;

    else
      DBChart1.Series[1].Color:=clblue; 

Open in new window

0
I am using an Indy 10 UDP client component with Embarcadero C++ builder EX 10.1 Berlin

I need to determine the IP address of the local PC that received the broadcast packet (not the peer IP). there are two network cards.
The UDP client is bound to 0.0.0.0 port 13580

How do I determine the IP address of the Ethernet port that generated the event ?

void __fastcall TForm1::IdSystatUDPServer1UDPRead(TIdUDPListenerThread *AThread, const TIdBytes AData,
          TIdSocketHandle *ABinding)
{
	UnicodeString u;


	u = ABinding->IP; // this is the binding which is 0.0.0.0
 	u = AThread->Binding->IP; // I was expecting this to give what I want but it returns .0.0.0.0

	if(u == u"10.41.0.20")  // only use specified local ethernet port
{
.....
}
else
{ // handle differently if another network adapter received the data

}

Open in new window

1
Hello,
I want to create 4 panels of the same size in a form. If you enlarge / reduce the form, then the panels should scale with.
The form always has 4 panels of the same size (even when resizing the form).
I already played with align left, right, bottom, top. However, the desired result did not come out.
The whole thing should look something like this:

1.PNG
Thank you very much.
0
Hello,
I have the following problem:

If I want to draw a rectangle on the paintbox in the lower right corner, then the rectangle will not be displayed completely after scrolling. What do I have to change to make the rectangle completely visible after scrolling down?

Here is a video of the problem (20s):
https://youtu.be/EETK1P1oG8g

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    PaintBox1: TPaintBox;
    procedure PaintBox1Paint(Sender: TObject);
    procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  protected
    procedure Paint; override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Paint;
begin
  inherited;
    //paintbox1.Canvas.Rectangle(5,5,300,200);
end;

procedure TForm1.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  paintbox1.Canvas.Rectangle(X,Y,X+200,Y+300);
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  paint;
end;

end. 

Open in new window


Thank you
Unit1.dfm
Unit1.pas
0
I would like to see any examples of QuickReport 6.0 professional BarChart code for Embarcadero C++ Builder XE 10.1 berlin please ?
0
Hello,

I need to capture the name of the application that is in foreground during a certain moment at the user's Windows session. I'm trying the following approach in order to get that:

function ProcessName(AID: Cardinal): String;
var
  Snapshot: THandle;
  ProcessEntry: TProcessEntry32;
begin
  Result := '';
  Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  try
    ProcessEntry.dwSize := SizeOf(TProcessEntry32);

    if not Process32First(Snapshot, ProcessEntry) then
      Exit;

    repeat
      if (ProcessEntry.th32ProcessID = AID) then
      begin
        Result := ProcessEntry.szExeFile;
        break;
      end;
    until not Process32Next(Snapshot, ProcessEntry);
  finally
    CloseHandle(Snapshot);
  end;
end;

Open in new window


What happens is when the foreground application is a Windows 10 app, this function always return 'ApplicationFrameHost.exe' as the captured process name. Doing some Google search I found the following web page that has a C code that solves that problem:

Process name for the active window in Windows 8/10

I'm trying to rewrite the presented code in Delphi (Object Pascal), but without success. The LPARAM argument at the 'EnumChildWindowsCallback' function is always being filled with invalid data. Its a shame, but I admmit that I do not have enough knowledge about Object Pascal Pointers. What I'm trying to do is:


Open in new window

0
Hi, I've used RAD studio Tokyo/Delphi to create a program for Android. I have this program working and looking good on my Amazon Fire. It occurred to me that a nice embellishment for this program would be a click sound for when the user presses a button...feedback. I remember about 35 years ago when Casio came out with calculators that could beep for each keypress. I found this useful and missed it when they stopped including sound a couple of years later.
I started to research this and found that Android prefers .3GP audio files. There don't seem to be any audio files on the fire.
What I am thinking is I would produce four very short audio files and save or convert them to .3GP. They would be tied into buttons as part of an on-click event. I would use a TMediaPlayer. There would be a tick, a tock, and two other similar sounds.
My questions are: Should I use one Media player, or four ? Are there no built-in sounds I can use, or a different way to generate sounds ? Or is this all a bad idea perhaps because it would be too much for the Fire ? Should these files be stereo ? What sampling rate and bit depth ?
0
Hello Guys,

What is wrong with my DLL creation? I got an error when I try to use it:

Dll code:

library knPassServer;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

{$R *.res}

function PassCript(servidor, usuario: ShortString):ShortString; stdcall;
var
  resultado: ShortString;
begin
      if usuario =  'externo.khan'  then resultado :=  'xx@xxxx'
 else if usuario =  'dsv.principal' then resultado :=  'xxxxx'
 else if usuario =  'sa'            then resultado :=  'xxxxxxxx'
 else resultado :=  '' ;
 result := resultado;

end;

exports PassCript;

end.

Open in new window



My simple form where I call the dll function

function checklogon(): ShortString;
Type
  TPassCript = function(servidor, usuario: ShortString): ShortString;
  
var
  LibHandle : THandle;
  PassCript : TPassCript;
begin
  try
    LibHandle :=  LoadLibrary('knPassServer.dll');
    if  LibHandle <=  HINSTANCE_ERROR then begin
        result := '';
        Exit;
    end;
    @PassCript  :=  GetProcAddress (LibHandle,'PassCript');
    if  @PassCript  = nil then
        ShowMessage('Entrypoint Download não encontrado na Dll');

    result := PassCript('','sa');
  finally
    FreeLibrary (LibHandle);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   edit1.text :=  checklogon
end;

Open in new window


thanks a lot for your help
0
Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Hi, I've a strange behaviour of an app written in Delphi (10.3.2) that must access to a Firebird x32 (3.0.4) database under Windows 7.

When the app runs a query, it appears to hang. During the execution of the query I show a waiting window, if I click on the close button immediately the control returns to the application.
On windows 10 everything works correctly, even on Windows 7 before an unidentified update.

it is not a problem of the waiting window (I have eliminated it) but on windows 7 the query takes too long to execute.

Firebird is on a remote server and the connection is made via tcp.

I'm going mad to understand where is the problem.
0
I need by following help:

1) It should not be possible to increase or decrease the form.
2) In addition, the form should not be able to be moved  
3) Form should not be closable

How can I do that?

Thank you
0
How do I manage to place 4 equal sized panels on the form(top left, top right, bottom left, bottom right) without specifying fixed pixel data?
If the size of the form changes, the panels should still be the same size.
I've tried it with the align property, but it seems that this isn't the right solution.
0
I am looking for a Delphi 7 example of an RDC Virtual Channel implementation.  

The need is for Topaz digital signatures that use SigSock.exe.  Sigsock.exe takes a command linek parameter that has to be the public ip of the RDP server, and Topaz does not support an RDP server cluster.  We use RemoteApp to deliver a Delphi 7 application to our end users from Azure, and we are building in redundancy.  The RemoteApp.rdp file points to a DNS A record that points to our traffic-manager(Load balancer), so we do not kow the ip of the actual server that the session will be on.

Sigsock.exe is used to capture the digital signature and send it to their OCX control that is running on the RDP server.  

The virtual channel's server executable will send the servers IP back to the client side channel dll, and the dll will spawn sigsock.exe with the correct parameters.  I can write this, but a shell that has already been tested would save a lot of time learning the ins and outs.

IT_Saige sent me some code, but it is in C# and I would rather not install VS.
0
Hello,
I have asked a similar question without code today. I am trying to code my problem based on this example
http://www.delphipages.com/forum/showthread.php?p=37440


The form "Form1" contains a panel. On this panel we want to embed a second form "Form2". But not only the components should be embedded, but also the functionality. I am using a VCL form.

What am I doing wrong?
Here is my code:

unit parent;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, child;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1 := TForm1.Create(Panel1);
  with Form1 do
    Name := 'MyForm';
    Parent := Panel1;
    Width := 100;
    Height := 100;
    Top := 10;
    Left := 10;
    Show;
end;

end.

Open in new window



unit child;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    btnCalc: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    procedure btnCalcClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.btnCalcClick(Sender: TObject);
begin
edit3.Text:=edit1.Text+edit2.Text;
end;

end.

Open in new window

0
I wrote custom component TMyComponent (see uExampleUnit.pas), which includes several complex properties, e. g. TScale = class(tPersistent). The problem is that I create TScale instance in TMyComponent constructor. This is not good, because I would like TScale behave like ordinary property - if I change it in design time it should retain new property. I should be able to read and write property values. But I don't know how to store them. One way it could be that I use ReadComponent and WriteComponent for TMyComponent (save it to disc with TMemoryStreauExampleUnit.pasm for example) and parse values for each complex property.

But where should I do this, in TScale.Assign ? Or is there some other way ?
0

Delphi

59K

Solutions

17K

Contributors

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.