Delphi

Using sql-server datetime2 with TADOQuery.open

天涯浪子 提交于 2021-01-27 11:47:29
问题 I want to start using datetime2 fields in SQL Server and I need to insert into the tables via ADO from Delphi XE5. I am using TADOQuery.ExecSQL to insert and everything works fine. However most of my tables have identity columns, e.g. id integer identity(1,1) not null To save round-trips to the server, I usually use Open with two commands in the query text. The first command is the insert the second command is "select scope_identity() as scope_id" so I can retrieve the newly inserted id in

Using sql-server datetime2 with TADOQuery.open

六眼飞鱼酱① 提交于 2021-01-27 11:44:42
问题 I want to start using datetime2 fields in SQL Server and I need to insert into the tables via ADO from Delphi XE5. I am using TADOQuery.ExecSQL to insert and everything works fine. However most of my tables have identity columns, e.g. id integer identity(1,1) not null To save round-trips to the server, I usually use Open with two commands in the query text. The first command is the insert the second command is "select scope_identity() as scope_id" so I can retrieve the newly inserted id in

Understanding Delphi Variable Declarations/Initializations

北慕城南 提交于 2021-01-27 10:20:32
问题 As it pertains to Delphi... When a variable is declare of a certain type, is it initialized to an OBJECT of that type? Or must the variable be assigned an expression which returns an object of that type? I'm coming from a strong Java background. What I mean to ask is this... In Java, say you declare an instance variable of a user defined type named Orange. Which would look like this: private Orange _fruit; The variable _fruit still holds a reference to null until actually assigned an instance

How to know a node is root in Virtual TreeView?

倖福魔咒の 提交于 2021-01-27 07:27:46
问题 I am using Virtual Tree View. Is there a reliable way to know if a node is root or not? I try to use if not Assigned(Node.Parent) then Output('This is root') else Output('This is not root') But does not work. I try to use if Node = tvItems.RootNode then Output('This is root') else Output('This is not root') But does not work either. 回答1: The ultimate root node in VTV (or VST ) is a special invisible node, which acts as parent for all user created root nodes (nodes created with parent = nil ).

Save canvas as an image

烈酒焚心 提交于 2021-01-27 07:15:32
问题 I am writing a program using Delphi XE2. I draw some lines and shapes on a Canvas. I want to save that Canvas as an image file using a save dialog. So I have a save button on my form and by clicking it, it opens the save dialog. How should I proceed to be able to save the Canvas? 回答1: At the moment you most likely have code in an OnPaint event for a TPaintBox or the form itself. That code might look like this: procedure TMyForm.PaintBox1Paint(Sender: TObject); begin with PaintBox1.Canvas do

Save canvas as an image

99封情书 提交于 2021-01-27 07:15:24
问题 I am writing a program using Delphi XE2. I draw some lines and shapes on a Canvas. I want to save that Canvas as an image file using a save dialog. So I have a save button on my form and by clicking it, it opens the save dialog. How should I proceed to be able to save the Canvas? 回答1: At the moment you most likely have code in an OnPaint event for a TPaintBox or the form itself. That code might look like this: procedure TMyForm.PaintBox1Paint(Sender: TObject); begin with PaintBox1.Canvas do

Delphi: invoke constructor raises EInvalidCast

橙三吉。 提交于 2021-01-27 06:53:54
问题 I'm trying to invoke a constructor obtained via RTTI (running D2010 version 14.0.3593.25826). The constructor takes a mixture of strings and objects as its arguments, all of which should be initialized to '' or nil . (Disclaimer: I know that the desired constructor will be the one with maximum number of parameters, hence the weird-looking, although suboptimal design.) The code goes as follows: program sb_rtti; {$APPTYPE CONSOLE} uses RTTI, TypInfo, SysUtils; type TMyClass = class (TObject)

In Delphi, How can I change the color of grid lines in a TDBGrid?

☆樱花仙子☆ 提交于 2021-01-27 06:48:39
问题 I am using a TDBGrid component in a Delphi application, when I change rows colors the grid lines became unclear or almost invisible. So, can any one show us how to change the color of the grid lines? I mean: how to change the color of cells borders(see next picture) The cells borders 回答1: Are you looking for procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const [Ref] Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Var R: TRect; begin R:= Rect; with DBGrid1

In Delphi, How can I change the color of grid lines in a TDBGrid?

妖精的绣舞 提交于 2021-01-27 06:46:24
问题 I am using a TDBGrid component in a Delphi application, when I change rows colors the grid lines became unclear or almost invisible. So, can any one show us how to change the color of the grid lines? I mean: how to change the color of cells borders(see next picture) The cells borders 回答1: Are you looking for procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const [Ref] Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Var R: TRect; begin R:= Rect; with DBGrid1

Delphi communication with C++ dll (parameters)

僤鯓⒐⒋嵵緔 提交于 2021-01-27 06:09:46
问题 Hi I'm having quite some issues with integrating a DLL inside my Delphi 2007 application. i suspect that I'm doing something wrong with the parameters of the calls. At this moment i have 2 issues, but i think they are related to eachother. 1) First call with the DLL: from the .h file: extern "C" { __declspec(dllexport) HRESULT Startup(char* version); } This call should initialize the DLL and give me the version back of the DLL. HRESULT should be 0, and the version pointer should contain the