delphi-2010

Unicode problems with Delphi 2009 / 2010 and windows API calls

馋奶兔 提交于 2019-12-21 17:28:50
问题 Hi I have been using this function in Delphi 2006, but now with D2010 it throws an error. I think it is related to the switch to Unicode. Function TWinUtils.GetTempFile(Const Extension: STRING): STRING; Var Buffer: ARRAY [0 .. MAX_PATH] OF char; Begin Repeat GetTempPath(SizeOf(Buffer) - 1, Buffer); GetTempFileName(Buffer, '~~', 0, Buffer); Result := ChangeFileExt(Buffer, Extension); Until not FileExists(Result); End; What should I do to make it work? EDIT I get an 'access violation' when the

Move project from Delphi 3 to Delphi 2010

橙三吉。 提交于 2019-12-21 17:02:05
问题 I've been asked to re-open a project I wrote in 1998/99 in Delphi 3 and which has been running stably since then. I have the Delphi 3 code base on an aging Windows 98 machine which exists only to keep this project alive. Obviously, I'd like to bring the source code base into the 21st century before undertaking any major revisions. I note happily that Delphi 2010 (I'm currently on 2007) claims to be able to import projects from Delphi 2 on. Does anyone have any experience importing large

(Delphi THintWindow) How to draw a transparent PNG?

爷,独闯天下 提交于 2019-12-21 06:39:33
问题 I have this delphi 2010 code: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math, ExtCtrls, pngimage; type TMyHintWindow = class(THintWindow) private FBitmap : TBitmap; ThePNG : TPngImage; FRegion : THandle; procedure FreeRegion; protected procedure CreateParams(var Params : TCreateParams); override; procedure Paint; override; procedure Erase(var Message : TMessage); message WM_ERASEBKGND; public constructor Create

Binary version of StringReplace

不打扰是莪最后的温柔 提交于 2019-12-21 05:28:11
问题 I'm trying to run AnsiStrings.StringReplace on a RawByteString holding a blob of data, some of which needs to be replaced. It would work, except that inside StringReplace it converts my string to a PAnsiChar, and so the search ends up bailing out as soon as it hits the first #0 byte inside the blob. I'm looking for a routine that works just like StringReplace, but is safe to use on blobs that may contain null bytes. Does anyone know of one? 回答1: I'd guess the "Offending" function in

Delphi dbgrid continuous scrolling

a 夏天 提交于 2019-12-21 04:54:08
问题 I'm making an application that holds orders and prints invoices. I have some labels, tedits, tmemos, buttons, a datasource, an adotable, a popupmenu, and a dbgrid on my form. When I build the program and scroll down the dbgrid scrollbar, it scrolls after I release mouse button. But i want continuous scrolling. Greetings 回答1: That's called thumb tracking. Derive a new class to override scrolling behavior. Example of using an interposer class: type TDBGrid = class(DBGrids.TDBGrid) private

How do I read a UTF8 encoded INI file?

左心房为你撑大大i 提交于 2019-12-21 03:50:24
问题 I have an INI file in UTF-8 format. I am using Delphi 2010 to read the INI file and populate a TStringGrid with the values in the INI file. var ctr : Integer; AppIni : TIniFile; begin AppIni := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'test.ini'); for ctr := 1 to StringGrid1.RowCount do begin StringGrid1.Cells[0,ctr] := AppIni.ReadString('Column1','Row'+IntToStr(ctr),''); StringGrid1.Cells[1,ctr] := AppIni.ReadString('Column2','Row'+IntToStr(ctr),''); end; AppIni.Free; The

Unused interface reference is not destroyed

泪湿孤枕 提交于 2019-12-21 02:29:06
问题 i had another bug in my app caused by careless usage of Delphi interfaces. When i pass an interface to a procedure which ignores that argument, the instance is never freed. See the following simple example: ITest = interface procedure Test; end; Tester = class(TInterfacedObject, ITest) public procedure Test; end; Base = class public procedure UseTestOrNot(test : ITest); virtual; abstract; end; A = class(Base) public procedure UseTestOrNot(test : ITest); override; end; B = class(Base) public

Is there a way to trace through only project source in Delphi?

喜欢而已 提交于 2019-12-20 19:24:34
问题 I'm using Delphi 2010 and I'm wondering if there's a way to trace through code which is in the project without tracing through calls to included VCLs. For example - you put in a breakpoint and then use Shift + F7 to trace through line-by-line. Now you run into a call to some lengthy procedure in a VCL - in my case it's often a Measurement Studio or other component that draws the doodads for a bunch of I/O, OPC, or other bits. At any rate, what happens is that the debugger hops out of the

Is there a way to trace through only project source in Delphi?

随声附和 提交于 2019-12-20 19:24:21
问题 I'm using Delphi 2010 and I'm wondering if there's a way to trace through code which is in the project without tracing through calls to included VCLs. For example - you put in a breakpoint and then use Shift + F7 to trace through line-by-line. Now you run into a call to some lengthy procedure in a VCL - in my case it's often a Measurement Studio or other component that draws the doodads for a bunch of I/O, OPC, or other bits. At any rate, what happens is that the debugger hops out of the

use shell execute to run cmd as Admin

江枫思渺然 提交于 2019-12-20 17:29:14
问题 I need to run cmd on a button click as admin. It works. but I need to run it as an admin. How is this done? ShellExecute(Handle, 'open', 'c:\Windows\system32\cmd.exe', nil, nil, SW_SHOWNORMAL) 回答1: Replace the open verb with the runas as shown below. Anyway, try to avoid path hardcoding: uses ShellAPI; procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(Handle, 'runas', 'cmd.exe', nil, nil, SW_SHOWNORMAL); end; You can also add to your button the shield icon by setting the