Menu
  • HOME
  • TAGS

Loop through records on a cxgrid and update a field/column

delphi,devexpress,tcxgrid

What your updated q is asking for is straightforward and as usual with Devex stuff, it's all in the OLH as long as you can find your way into it. A way to find which rows currently match the filter is to use the cxGrid1DBTableView1.DataController.FilteredRecordIndex[] property. You can then find...

See when Delphi Twebbrowser starts loading a page

delphi,twebbrowser

The events that you are searching for are OnDownloadBegin and OnDownloadComplete. OnDownloadBegin fires just before the document starts to being downloaded and is therefore the best event for starting of some loading animation. http://docwiki.embarcadero.com/Libraries/XE8/en/SHDocVw.TWebBrowser.OnDownloadBegin OnDownloadComplete fires after the document was downloaded and even if the downloading of the document fails...

How to get enabled property of a control?

delphi,properties

If you have the window handle for a control, then the IsWindowEnabled function will tell you whether it is enabled. Keep in mind that that is acting on the window at the API level, not the Delphi VCL level. In Delphi, there can be controls that do not have window...

connection refused when I try to connect client with server

delphi,datasnap

You should go to router admin console, find something like "port forwarding" and route the port (8081) to your computer IP - you have to say the router that traffic on this port should go to your computer

Can I pass type parameters to a testcase in DUnitx?

unit-testing,delphi,generics,dunitx

Try to make your test class generic and register your test class with every single concrete type you want to test. [TestFixture] TMyTestObject<T> = class(TObject) public // Sample Methods // Simple single Test [Test] procedure Test1; // Test with TestCase Atribute to supply parameters. [Test] [TestCase('TestA','1,2')] [TestCase('TestB','3,4')] procedure Test2(const AValue1...

Open file manage and get selected file

android,delphi,firemonkey

You can use JFileDialog Check the below link http://bluexmas.tistory.com/427...

Referring to interface versus to an object implemeting it?

delphi

The difference is explained in the documentation: When TXMLDocument is created without an Owner, it behaves like an interfaced object. That is, when all references to its interface are released, the TXMLDocument instance is automatically freed. When TXMLDocument is created with an Owner, however, it behaves like any other component,...

When I load a new image in a TBitmap I must destroy the existing one first?

delphi,bitmap,delphi-2009

No. When LoadFromResourceName executes, it clears any memory and resources used by the previous image, and loads the new one. Your code is fine, modulo the missing try/finally. It should be: Bitmap := TBitmap.Create; try .... finally Bitmap.Free; end; Without that, should an exception be raised in between assigning to...

Issues with AES Encryption using SynCrypto

delphi,encryption,cryptography,aes

AES is a block cipher algorithm. It means that it works by blocks that are 16 bytes in size for AES. So you need to use padding if your data does not fit in 16 bytes blocks (which is the case for your text). Instead of trying to re-invent the...

Delphi Bug in Indy FTP List method?

delphi,ftp,indy

This is not a bug in TIdFTP. It is more an omission in the Indy documentation. EIdReplyRFCError means the FTP server itself is reporting an error in response to the command that TIdFTP.List() is sending. Depending on the values of the ADetails parameter and TIdFTP's UseMLIS+CanUseMLS properties, List() can send...

How can I send data between 2 applications using SendMessage?

delphi,winapi

As noted in comments, you must use SendMessage with WM_COPYDATA. The primary reason for this is that the message sender is responsible for cleaning up the resources used for the transfer. As noted in the documentation : The receiving application should consider the data read-only. The lParam parameter is valid...

How to catch WM_DEVICECHANGE in a control other than TForm?

delphi,delphi-2009,windows-messages

The OS sends wm_DeviceChange messages to all top-level windows. The application's main form is a top-level window, but your control is not, which is why the form receives the messages and your control does not. For arbitrary device types, you have two alternatives: Use AllocateHWnd to create a message-only top-level...

Preventing component creation - Delphi

delphi,components

If you include components in the designer, then they will be created when the form is created. Nothing you can do to stop that. The logical conclusion is that you need to create the components at run time. One obvious way to make that easier is to put the components...

Get list of process

delphi,winapi

This is very platform-specific, and as such there is nothing in FireMonkey or VCL to help you with it. You have to use platform APIs directly. For instance, on Windows you can use CreateToolhelp32Snapshot(), Process32First() and Process32Next(): Taking a Snapshot and Viewing Processes Or you can use EnumProcesses(): Enumerating All...

Undeclared identifier in Code Insight?

delphi

Looks like some another unit declares TSite type that is used instead; Try declare the var awith the fully qualified name unit main; uses .. lc, ...; var Site: lc.TSite; Also it would make sense to reference the var via FQ-name too, just I ncase some other unit or procedure...

Multiple instances of the same service in Delphi

delphi,service,delphi-xe

It's fairly simple. You just have to set the name different for each service. You now have: Name := ParamStr(2); DisplayName := ParamStr(3); and just have to change it to: Name := baseServiceName + '-' + GetLastDirName; DisplayName := baseServiceDisplayName + ' (' + GetLastDirName + ')'; where baseServiceName is...

HasValidFileNameChars fails for UNC files

delphi,delphi-xe,delphi-xe7

The function behaves correctly because a \ is not a valid character for a file name. It is the path separator. The distinction here is between file names and paths. Using your example, \\ETA-PC\tests\test.ini is a path, but the file name is test.ini. I suspect that you are looking for...

Unable to read final few Kb of logical drives on Windows 7 64-bit

delphi,wmi,freepascal,lazarus

Probably, it is a boundary check error. Quote from MSDN (CreateFile, note on opening physical drives and volumes, which you call logical drives): To read or write to the last few sectors of the volume, you must call DeviceIoControl and specify FSCTL_ALLOW_EXTENDED_DASD_IO ...

Setting “Server” programatically with a TFDConnection

mysql,delphi,firedac

Please read the documentation, it tells you exactly how to define a FireDAC connection for MySQL: Working with Connections (FireDAC) Connect to MySQL Server (FireDAC) You would specify the DB server as part of a Connection Definition: Defining Connection (FireDAC) Connection Definitions can be defined in an external .ini file,...

Can I check data in a 3rd party app with just the handle?

delphi

h2 is a window handle, for a window in another process. You can cast it to a TListBox as you did, but that does not make h2 actually be a list box. Hence the runtime error. Essentially you lied to the compiler by claiming that h2 was something that it...

Custom component Convertion from delphi 5 to delphi 7

delphi,delphi-7,delphi-5

The Designer property is of type IDesignerHook and cannot be hard cast to IDesigner. To have any hope of success you would need code of this form: (FFormOwner as TForm).Designer as IDesigner This will perform a runtime query of the IDesignerHook interface Designer, and return an IDesigner interface if that...

Lazarus/FreePascal, Synapse send file to TCPBlockSocket

delphi,freepascal,lazarus,netcat,synapse

Well... Hex 00 00 B5 6C (your extra bytes in reverse) is equal to 46444. So my guess is that TFileStream or SendStream sends the number of bytes it wants to send before the actual data. Looking at the code of Synapse there is the function: procedure TBlockSocket.InternalSendStream(const Stream: TStream;...

User defined macro in CnPack

delphi,delphi-ide

You simply define the new macro. Here's an example of doing so. Open the Source Templates Options dialog (CnPack->Source Templates->Options from the IDE main menu). Select the Add button. Fill in the information at the top (Title and Description for now), for instance "TestTemplate" and "Test template with my macro"....

AES encryption differences between php mcrypt and a Delphi component

php,delphi,encryption

MCrypt expects the key to be a binary string, but you pass a hex encoded string into it. Use $key = hex2bin($key); or $key = pack('H*', $key); depending on PHP support. This must be done before calling mcrypt_encrypt(). Security: Don't ever use ECB mode. It's not semantically secure. There is...

Delphi, Lazarus - Listbox out of bound (0) TString

delphi,listbox,indexoutofboundsexception,lazarus,tstringlist

The error is telling you that the list box selectedbox is empty. I would expect that the error is more like this: List index out of bounds (0) That tells you that index 0 is invalid which can only mean that there are no items in the list box. Presumably...

do oncalculate fields in one table using values from another table

delphi

You are not telling us what data access component you are using. The recommended way to do this is using a Query component (TSQLQuery, TADOQuery, TIBQuery,...) , then have the SQL for that query retrieve all necessary information. All the fields that you want access to in you OnCalcFields() should...

Signing certificate error when update apk from XE7 to XE8

android,delphi,firemonkey

can you try Project -> Options -> Provisioning -> New Keystore http://docwiki.embarcadero.com/RADStudio/XE8/en/Creating_a_Keystore_File http://docwiki.embarcadero.com/RADStudio/XE8/en/Create_a_new_Keystore/Alias...

Infinite loop in parsing a string using pointer math

delphi,pointer-arithmetic,delphi-xe8

Your loop runs forever because P will never be nil to begin with, not because of an issue with your pointer math (although I will get to that further below). PChar() will always return a non-nil pointer. If S is not empty, PChar() returns a pointer to the first Char,...

unelevated program starts an elevated updater, updater should wait for finishing of program

delphi,handle,createprocess,waitforsingleobject,shellexecuteex

Your code is not working because the handle table is per process, which means that the second process could have the same handle pointing to another kernel object. Below, there is one of many possible solutions: When creating the process 2, pass the PID of the process 1 as parameter:...

Delphi - extract string between tags (duplicate tags)

delphi

Function sExtractBetweenTagsB(Const s, LastTag, FirstTag: string): string; var pLast,pFirst,pNextFirst : Integer; begin pFirst := Pos(FirstTag,s); pLast := Pos(LastTag,s); while (pLast > 0) and (pFirst > 0) do begin if (pFirst > pLast) then // Find next LastTag pLast := PosEx(LastTag,s,pLast+Length(LastTag)) else begin pNextFirst := PosEx(FirstTag,s,pFirst+Length(FirstTag)); if (pNextFirst = 0) or...

Digital Metaphors Report Builder Surround Group Inside Box

delphi,report,reportbuilder

I'm not sure I have understood your question, but try taking a look at using a region, with all members of the group in it, including the lines/shape used, you can then group the items together.

Opening a project in landscape in iOS doesn't display correctly in Delphi XE8

ios,delphi,firemonkey,delphi-xe8

I am using FXG component ActivityDialog. I used this component in the formCreate method which gave the problem. By removing it from the formCreate and moving it to the formActivate the problem is solved.

How to use TThread.Synchronize() to retrieve the text of a TEdit control?

delphi,c++builder

First, declare a method in your form that retrieves the text. This method can be called both from the main thread and a worker thread: Type TMyGetTextProc = procedure(var s: String) of object; procedure TForm1.GetMyText(var myText: String); begin TThread.Synchronize(nil, procedure begin myText := ATedit.Text; end ); end; Secondly, when you...

PasswordChar in Delphi XE8's TMemo

delphi,delphi-xe8

The VCL memo control is a loose wrapper around the Win32 multiline edit. The password character functionality of the edit control is only available for single line edits. The behaviour is controlled by the ES_PASSWORD style for which the documentation says: Displays an asterisk (*) for each character typed into...

Delphi form inheritance, visual bug

forms,delphi

It sounds like this is what you have done - let me guess at the steps to reproduce this problem: Created a base regular form - Let's call it TForm1 Added a number of controls to TForm1 Created a second regular form - Let's call it TForm2 You then edited...

Function that returns intersection of two TShapes, including TPaths?

delphi,firemonkey

There is no built-in function for this. But what I think you are trying to do is this: Given a polygon (aka TPath) made up for distinct points connected by lines. Return all points in ShapeA that lay inside ShapeB. Point intersection This can be done using PointInObjectLocal. Run a...

FastReport Master/Detail in Delphi XE2

oracle,delphi,fastreport

When creating the preview FastReport does something like this code: while not MasterBand.DataSet.Eof do begin ...Do special FastReport's work :) while not DetailBand.DataSet.eof do begin ...Do special FastReport's work :) DetailBand.DataSet.Next; end; MasterBand.DataSet.Next; end; In your code: while not opr_operatorcount_ods.Eof do begin frxReport1.PrepareReport(false); opr_operatorcount_ods.Next; <-- here opr_operatorcount_ods is in the...

how to connect to a NIC card or network adapter knowing its IP address?

delphi,network-programming,ip-address,windows-10

It sounds as though the library that you use requires elevated rights. Nothing significant has changed in Windows 10 regarding UAC. If your program is running elevated it will succeed. It fails when it is not elevated. So your problem would appear to be that you are failing to execute...

How to remove duplicates in ListBox?

delphi,listbox,duplicate-removal

Try NoDuplicate.CaseSensitive := True; ...

How can I convert PNG to GIF keeping the transparency?

delphi,graphics,png,gif

It is possible to transfer an image from a PNG to a GIF. However, I don't recommend that you do so. The GIF format is substantially less capable than PNG. PNG supports RGBA color channels and partial transparency. GIF uses a 256 color palette and no support for partial transparency....

Is it a bug that attempts to compile this code results in IDE terminating or the compiler failing to run?

delphi,delphi-xe3

This is certainly a bug. It occurs in all the IDE versions that I tested, XE3, XE7 and XE8. I honestly don't think there's a lot you can do. For me the IDE terminates on compilation every time. I think you'll just have to write the code in a way...

Remove specific XML element in Delphi

xml,delphi,delphi-7

You can use the IXMLNodeList.Delete() or IXMLNodeList.Remove() method to remove nodes: var Root: IXMLNode; begin Root := XMLDocument1.DocumentElement; Root.ChildNodes.Delete('ElementData'); for I := 0 to Root.ChildNodes.Count-1 do Root.ChildNodes[I].ChildNodes.Delete('ElementData'); end; var Root, Child, Node: IXMLNode; begin Root := XMLDocument1.DocumentElement; Node := Root.ChildNodes.FindNode('ElementData'); if Node <> nil then Root.ChildNodes.Remove(Node); for I := 0...

How to add menu items separators programmatically on Windows?

windows,delphi,drop-down-menu,menuitem

Create a new menu item and set its caption to '-'. var MenuItem: TMenuItem; .... MenuItem := TMenuItem.Create(Menu); // Menu is the menu into which you are adding MenuItem.Caption := '-'; Menu.Items.Add(MenuItem); Instead of Add, which adds to the end of the menu, you can use Insert to insert the...

Why can't I use compiler intrinsics in an asm block?

delphi,assembly

You cannot use compiler intrinsics because they are processed by the Delphi compiler rather than the assembler. Intrinsics are resolved by the Pascal compiler processing and parsing Pascal expressions, and then emitting code. That's the job of a compiler rather than an assembler. At least, that's my mental model. In...

What is the different between “Console target” and “GUI target” in DCC32 option?

delphi

These options control the subsystem of the output file. They only have meaning on Windows. They are equivalent to the $APPTYPE directive. The $APPTYPE directive controls whether to generate a Win32 console or graphical user interface application. In the {$APPTYPE GUI} state, the compiler generates a graphical user interface application....

How to add new online ressources to RAD Studio help system

delphi,delphi-xe2,h2reg

After talking to somebody formerly on the development team of MS Document Explorer and now r2reg, this is not possible. And since MS moved on from MS Help 2 and now uses MS Help Viewer, there will not be any further development to allow for this.

Does “enable runtime themes” affect performance?

delphi,themes,delphi-2007

What "Enable runtime themes" actually does is telling Windows to Enable Visual Styling of the applications via following manifest entry <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> You could also have runtime themes enabled in older Delphi versions using different methods. Delphi 7 included TXPManifest component that...

How to correctly have modeless form appear in taskbar

windows,delphi,windows-7,delphi-xe6,windows-95

It seems to me that the fundamental problem is that your main form is, in the eyes of the VCL, not your main form. Once you fix that, all the problems go away. You should: Call Application.CreateForm exactly once, for the real main form. That is a good rule to...

Is there any Delphi implementation of MurMurHash3?

delphi,murmurhash

I have a murmurhash3 implementation in my FastDefaults unit at https://github.com/JBontes/FastCode Here's the sourcecode for Murmurhash3: {$pointermath on} function MurmurHash3(const [ref] HashData; Len: integer; Seed: integer = 0): integer; const c1 = $CC9E2D51; c2 = $1B873593; r1 = 15; r2 = 13; m = 5; n = $E6546B64; f1 =...

Component event detection in Delphi

delphi,events,components

You can use a virtual method interceptor to intercept the DoAfterOpen virtual call FVirtualIncerceptor := TVirtualMethodInterceptor.Create(TDataSet); FVirtualIncerceptor.OnBefore := procedure(Instance: TObject; Method: TRttiMethod; const Args: TArray<TValue>; out DoInvoke: Boolean; out Result: TValue) begin if Method.Name = 'DoAfterOpen' then ToBeExecutedOnAfterOpen(TDataset(Instance)); end; FVirtualIncerceptor.Proxify(Self.DataSource.DataSet); See this for more info...

SetProcessWorkingSetSize does not work in compiling 64bit

delphi,memory

The documentation tells you to pass high(SIZE_T). You do this when compiling for 32 bit, but not for 64 bit. This is what you mean to write: SetProcessWorkingSetSize(MainHandle, high(SIZE_T), high(SIZE_T)); Do note though that this code won't help performance on your machine. In fact, the only thing it can do...

What would the design look like for a class that implements a threaded email sending queue?

multithreading,delphi,delphi-xe7,omnithreadlibrary

I suggest you to set up OTL. You would most probably have the only SMTP server, so the only mail-sending thread, in case you would later add more notification sending servers ( like sending SMSes to different phone operators ) - you would add more outgoing "sink" threads. Personally I...

How do we improve a MongoDB MapReduce function that takes too long to retrieve data and gives out of memory errors?

performance,mongodb,delphi,mapreduce

Phew what a question! First up: I'm not an expert at MongoDB. I wrote TMongoWire as a way to get to know MongoDB a little. Also I really (really) dislike when wrappers have a plethora of overloads to do the same thing but for all kinds of specific types. A...

Delphi passing Types in parameters

delphi,delphi-xe2

What you are asking for can be done by either: deriving the various Form classes from a common base class that exposes the field you want to access: procedure A(aForm : TBaseForm); begin ShowMessage(aForm.edtUser.Text); end; type TBaseForm = class(TForm) edtUser: TEdit; ... end; TDerivedForm = class(TBaseForm) ... end; ... frm...

Delphi XE4 - TImage is not displayed at runtime

delphi,delphi-xe4

Your version of SynGdiPlus is clearly deprecated. The current revision has a NOTSYNPICTUREREGISTER condition, which is enabled by default: initialization {$ifndef NOTSYNPICTUREREGISTER} Gdip.RegisterPictures; // will initialize the Gdip library if necessary {$endif} Ensure you got the latest revision of the source code tree....

Need help to find FireMonkey equivalent of the VCL TpaintBox.Canvas.Handle in the context of building graph

delphi,firemonkey

In VCL, TPaintBox is a TGraphicControl descendant that draws onto the HDC of its Parent control's HWND. When the Parent control receives a WM_PAINT message, it draws itself onto the provided HDC as needed, and then temporarily gives that same HDC to each child TGraphicControl when drawing them, clipping the...

How to execute a file with a different extension's associated application?

delphi,winapi,shellexecute,file-association

Call ShellExecuteEx and specify the lpClass member of the SHELLEXECUTEINFO struct. Note that you must include SEE_MASK_CLASSNAME in the fMask member. For instance, set lpClass to '.txt' to request that the file be opened with the program associated with the .txt extension. ...

Why Application.OnException never runs?

delphi,exception-handling,delphi-xe2,delphi-7

The only rational explanation is the FormCreate is not executing. You need to assign it to the form's OnCreate event handler. Use the object inspector to do so.

Delphi and sleep function

delphi,timer,sleep

First off, WinExec() has been deprecated since 32bit Windows was first introduced. Use ShellExecuteEx() or CreateProcess() instead. This also provides you with a process handle that you can use to detect when the spawned process terminates, and you can also use it to kill the process if your timeout elapses....

Flush file buffers in on non-Windows platforms

delphi,delphi-xe8

The RTL has no function for flushing a file without closing it. You have to use platform-specific functions instead. On Windows, TFileStream uses the Win32 CreateFile() function to open/create a file, so you can use FlushFileBuffers() to flush it. On other platforms, TFileStream uses the POSIX open() function to open/create...

Delphi 7 - Save to a Specific .INI Files Name

delphi,delphi-7

When you open an ini file, store the filename in a variable as explained in many comments. Example, (FCurrentIniFilename: String; is a private variable in TForm1): In the FormCreate event: FCurrentIniFilename := ExtractFilePath(Application.EXEName)+ 'A.ini'; Read := TINIFile.Create(FCurrentIniFilename); ... In the OpenFile event: if OpenDialog.Execute then begin FCurrentIniFilename := OpenDialog.Filename; Open...

'Session Ended' when lauching app from Delphi to iOS Simulator

delphi,ios-simulator,delphi-xe7,paserver

After a few days, I found out what the problem was, so I'll post the solution here to help others who might have the same problem. Go to Project --> Project Options --> Version Info Under de iOS Simulator configuration, Delphi IDE (XE7) automatically inserted the following key and value:...

Can I compare Real48 using generics.defaults?

delphi,delphi-xe7,delphi-xe8

This defect is present in all versions of the compiler. Since Real48 was deprecated more than a decade ago I would expect that Embarcadero would not change the behaviour, even if you submitted a bug report. Of course, you should still submit a bug report, but I would not hold...

How can I make the main form align correctly after my control height is autosized and then I maximize the form?

delphi,alignment,delphi-2009

First, never have a control handle its own event properties. Event properties are for the consumer of the component, not for the developer. The component developer's hook to the OnResize event is the protected Resize method. Override that if you want to know about OnResize-related events. What I suspect is...

Odd compilation error message

delphi,delphi-xe6

This is the declaration of the InsertRecord method: procedure InsertRecord(const Values: array of const); The parameter is a variant open array. Variant open array parameters are implemented internally by being passed as TVarRec instances. And TVarRec cannot contain records. Since TGUID is a record, it cannot be passed in a...

Delphi Access Violation when moving button on form

delphi,button,access-violation

I am executing the procedure with CreateThread(). That is your problem. VCL code must only be called from the main UI thread. Use TThread.Synchronize to invoke the VCL code on the main thread. That said, a timer might be a more appropriate solution to you problem than a thread....

What is required in Delphi 2007 to use Variant arrays?

delphi,com,delphi-2007,variant

The code is missing a unit from the uses clause. That unit is named Variants and contains all the symbols that the compiler cannot find. Add that unit and the code will compile.

Reduce lines, use case?

delphi,case

Just a simple way to improve the code: var ix: Integer; ... ix := StrToInt(valmes.Text); WebTesta.OleObject.Document.all.Item('expmonth', 0).value := IntToStr(ix-1); You can add some sanity checks using if TryStrToInt(valmes.Text,ix) then .......

Currency Formatting with Delphi

delphi,currency,object-pascal

Make sure the MaxLength of edtZaklad is 0. var Form21: TForm21; Check:string; //to break the loop. function GetCurrency(Num: String):string; var i: Integer ; Str:String; zaklad: Currency; begin Result := ''; for i := 1 to length(Num) do begin if (Num[i] in ['0'..'9']) then Begin Str := Str + Num[i] ;...

Why does my application using OmniThreadLibrary Parallel.Pipeline continue remain running in the background after being closed?

multithreading,delphi,delphi-xe7,omnithreadlibrary

You should call FPipeline.input.CompleteAdding from TEmailQueue.Destroy. Otherwise, SendEmailStage will never stop.

Can I specify the save location for Delphi .dsk file?

git,delphi,ide

The IDE places the file in the root directory of the project. You cannot influence it to do otherwise.

Delphi - converting string back from UTF-8

osx,delphi,utf-8

value = '散汤湡獤杀潯汧浥楡⹬潣m䌴䅓㜭䙇ⵊ䵙㑗㈭呖ⵆ䥉儵䈭呎́'#4 This is indicative of you interpreting 8 bit text, presumably UTF-8 encoded, as if it were UTF-16 encoded. As a broad rule, when you see a UTF-16 string with Chinese characters, either it is a correctly interpreted Chinese text, or it is mis-interpreted 8 bit text....

How cand I include a bitmap in my custom component (if is possible)?

delphi,components,delphi-2009

Change BMP to BITMAP in your RC file, and change HInstance to FindClassHInstance() in your code: FIXED BITMAP "fixed.bmp" Glyph.LoadFromResourceName(FindClassHInstance(MyComponent), 'FIXED'); ...

How to make my custom control be notified when his form or application receives and loses focus?

delphi,focus,delphi-2009

I want to suspend some updates of the control when his form is not active and resume the updates when the form is activated. If those updates are done continuously, or are being triggered by a timer or actions, then you could be done with: type TMyControl = class(TControl)...

Delphi generic frame

delphi,frames

procedure TFrameManagement.CreateGenericFrame(ParentPanel: TPanel; FrameName: TFrame); begin genericFrame := FrameName.Create(ParentPanel); genericFrame.Parent := ParentPanel; end; Here FrameName is an instance and you are calling the constructor of that instance. You are not creating a new instance as you intend to do. You need to use meta classes. type TFrameClass = class of...

Custom component controls keep re-creating

delphi,firemonkey

You need to set the stored property of your sub components to false. paLaterale := TPanel.Create(Self); paLaterale.Stored := false; etc ...

Asynchronous TADOQuery's OnFetchComplete not synchonized to main thread

delphi,asynchronous,delphi-xe4,delphi-xe8,tadoquery

In my experience the easier way is to use either: Synchronize or TThread.Queue This is not a bug or at least not a VCL bug. This behavior is handled by the provider and we cannot say it is not following the specification because there is no specification about how to...

TypeCasting : what is difference between below 2 lines of code?

delphi,delphi-7

IDesigner(TForm(FFormOwner).Designer) This performs a simple reinterpretation cast of Designer. It will fail because Designer is of type IDesignerHook which is not the same as IDesigner. (FFormOwner as TForm).Designer) as IDesigner This performs a runtime query for IDesigner and is resolved with a call to QueryInterface. This is the correct way...

Unable to use apostrophes in a string

delphi,delphi-xe8

My pshychic debugging tells me that you are looking at the string in the debugger. The single quote is the string delimiter. So it needs to be escaped. It is escaped by doubling it. So when the debugger shows a string like this: 'a''b' that is actually three characters long,...

IP*Works! SearchMailbox for IMAPS returns all available emails, even unmatching

delphi,imap,delphi-xe2

Thanks to the answer of @arnt, I figured out a solution that works for me. Yes, for every Message that corresponds to the search criteria, the event OnMessageInfo is fired. Since I need to go through all messages in a loop, I ended up doing this: procedure TReadIMapObjectsFavFktProperty.MessageInfo(Sender: TObject; const...

Strings getting corrupted in ComboBox.AddObject. How to add them the proper way?

delphi,delphi-xe7

There's nothing to keep the string alive. When you write: s := PChar(sl.Values[sl.Names[c]]); an implicit local variable of type string is created to hold whatever sl.Values[sl.Names[c]] evaluates to. That local variable goes out of scope, as far as the compiler is aware, nothing references it, and the string object is...

How to call the original class's code when a class helper is in scope?

delphi,class-helpers

I think that the only way to achieve this with pure Pascal code is to call Sort from a scope in which your class helper is not active. The point being that if your class helper is active, then Sort refers to the method in the helper. For instance like...

Missing operator or semicolon in Delphi 7

delphi,delphi-7

Label6.Caption('rok') Caption is a property which behaves as a variable does. You treat it as though it is a procedure (which it is not) and hence the compilation error. The parser knows that the only thing that can follow a property name is a semicolon, bracket (if the property is...

Firemonkey ListView item indexes not updating

delphi,listview,firemonkey

While the real fix is in Embarcadero's ball court, this seems to be the only work-around: procedure ReindexListView(AListView: TListView); var X: Integer; begin for X := 0 to AListView.Items.Count-1 do AListView.Items[X].Index; end; Behind the scenes, there is a known bug in the generic TList implementation, specifically a mis-hap with the...

Get which capture group matched a result using Delphi's TRegex

regex,delphi

Internally Delphi uses class TPerlRegEx and it has such description for GroupCount property: Number of matched groups stored in the Groups array. This number is the number of the highest-numbered capturing group in your regular expression that actually participated in the last match. It may be less than the number...

How can I extract part of a PChar into a string?

string,delphi,optimization,pchar

Let's consider the corner cases. I think they are: AInput invalid. AStart < 1. AStart > FLength. ASubstringLength < 0. ASubstringLength + (AStart-1) > FLength. We can ignore case 1 in my opinion. The onus should be on the caller to provide a valid PChar. Indeed your check that AInput...

Passing SafeArray from Delphi through to ms-uiautomation libraries

delphi,microsoft-ui-automation

Your GetSelection() implementation is expected to return a SAFEARRAY of IRawElementProviderSimple interface pointers. However, you are creating a SAFEARRAY of VARIANT elements instead, but then populating the elements with TAutomationStringGridItem object pointers. SafeArrayPutElement() requires you to pass it a value that matches the type of the array (which in your...

Expression illegal in evaluator

delphi,delphi-xe2

Delphi's operator precedence rules mean that your expression is evaluated like this: if (qryGeneral.fieldbyname('B_PRIJS').IsNull or qryGeneral.fieldbyname('B_PRIJS').Value) = 0 then Put parentheses around your = expression just like you have around you <> expressions, and you should get closer to the results you expect. However, the Value property is a Variant....

Delphi XE8: problems running an external console application, waiting for its results and capturing its results

delphi,pipe,console-application,createprocess,waitforsingleobject

To summarize: @David Heffernan's code in Execute DOS program and get output dynamically works. The problem is that the console application emits UTF-16.

Delphi - Use a string variable's name in assignfile()

file,delphi,variables,assign

Is it possible to use a variable in the AssignFile command? Yes. The second parameter of AssignFile has type string. The expression cFileDir + '\' + sFile has type string. FWIW, AssignFile is known as a function rather than a command. Getting on top of terminology like this will...

How to draw on a single GLSceneViewer using GLCanvas but not on all viewers?

delphi,opengl,glscene

Ok, after playing around with GLSceneViewer I figured out how to do it: instead of drawing lines on onRender event of GLDirectOpenGL1, you should draw lines on PostRender event of a necessary GLSceneViewer, so code should look like that: procedure TForm1.GLSceneViewerL(Sender: TObject); var glc : TGLCanvas; begin glc:=TGLCanvas.Create(GLSceneViewerL.Width, GLSceneViewerL.Height); with...

How to open and read “/proc/cpuinfo” on Android device in Delphi

android,delphi,cpu,firemonkey

The answer is simple (tested): var FS: TFileStream; ch: Char; RawLine: System.UnicodeString; begin if FileExists('/proc/cpuinfo') then begin try RawLine:= ''; ch := #0; FS:= TFileStream.Create('/proc/cpuinfo', fmOpenRead); while (FS.Read( ch, 1) = 1) and (ch <> #13) do begin RawLine := RawLine + ch end; Memo1.Lines.Append(RawLine); finally FS.Free; end; end; end;...

Saving Excel workbook as PDF gives me an OLE error 800A03EC

excel,delphi,automation,ole

I don´t think that converting to PDF would be a normal SaveAs. You should try exporting it, as said here

It is required to free the IShellFolder interface returned by SHGetDesktopFolder ? and how?

delphi,delphi-2009

COM interfaces are reference counted, and the Delphi compiler generates code to automatically manage the reference counting for you. Each time an interface variable is assigned, Release is called if the variable is not nil, and AddRef is called if the new value is not nil. When the variable goes...

How to use XPath on TXMLDocument which has namespace prefixes?

xml,delphi,soap,xpath

Do not try to include namespaces in your XPath query. If all you want is the text of the SomeResult node, then you can use '//SomeResult' as query. For some reason the default xml implementation (msxml) barfs on the default namespace xmlns="http://someurl" on the SomeResponse parentnode. However, using OmniXML as...

How to make TDBCheckBox update its DataField immediately after click?

delphi,checkbox,event-handling,delphi-xe3,data-aware

A couple of problems with using the DataChange event to do things like this are that It's called a lot more frequently than you actually need, to react to your DBCheckBox being clicked and Doing a .Post to the dataset is going to change its state, which is generally a...

Call Delphi XE6 unicode dll from C# asp.net

c#,delphi,dll

BadImageFormatException typically indicates a bitness mismatch. Your Delphi module is 64 bit and the C# module is 32 bit, or vice versa. You have other problems. At least the following: You cast a UTF-16 UnicodeString string to PAnsiChar. That cast is not correct. You return a the address of a...