w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » DELPHI » Page 1
how to fill a stringgrid in delphi between two given numbers
How do I generate a random number between the values given by the user? The Random function has two overloads. The variant with no parameters returns real values between 0 and 1. The other variant accepts an integer parameter N and returns integers i such that 0 <= i < N. So you can use some arithmetic to produce values in the range a to b. function RandInRange(const a, b: Integer): In

Categories : Delphi

Delphi focus controlling
Your code should be something like: label1.Visible := edit1.Focused; You can't test if something is "SetFocus" since SetFocus is a procedure that actually FOCUS some control, so you need to test if the control is FOCUSED.

Categories : Delphi

Delphi Rbuilder: Calculate value across multiple pages of data not just first and last page
Ok, so I kept working at this and eventually found the problem. At the report level I changed the report from TwoPass to OnePass. That ended up giving me very close to what I wanted. I ended up having to write some more code to get exactly what I wanted but changing the number of passes worked. I was trying to display a running total page by page. And as I changed pages it would updat

Categories : Delphi

Delphi Service Application TStringList LoadFromFile Memory Leak
Before looking for leaks in code, you first need to understand if you really have a leak or not. Task Manager shows what Windows knows about your application, and its number needs to be understood in the context of how Windows manages memory - then you have to understand how Delphi manages memory within an application. To learn how to read Task Manager numbers, I'd suggest you the excellent Mark

Categories : Delphi

Is it possible to draw a line between points on a TChart "point" chart
Attempting to paint lines yourself is not the way to proceed. The design basis of charting controls is that you define the chart in logical terms and let the control deal with painting it. So, the way to proceed is to add some line series that represent the lines you wish to be drawn. You can perfectly well add these line series in addition to the other series of your chart. Regarding your c

Categories : Delphi

Is there any way through which I can lock the XML file while I am writing into it using Delphi?
When you create a file, create it with exclusive rights, or at least with write access sharing disabled, then write to it as needed. Nobody else will be able to open the file for writing until you close it first. In fact, NativeXML already does exactly that when saving XML to a file via its SaveToFile() method. It uses a TFileStream, and that is the default behavior of TFileSteam when creating a

Categories : Delphi

Displaying images from db on the go
"Unknown number" sounds like there may be a huge number of images. So pre-rendered thumbnails would be very helpful. If your application can create thumbnails for all images and keep them in a separate database this would reduce the CPU resource usage for shrinking them. And you could reference the thumbnail database from your master database. One thing I would check if RAM could be a limitation

Categories : Delphi

TMultiView on Frame causes AV
There is workaround that will enable you to view and edit that frame, but it involves some manual handling of both .pas and .fmx files Let's say you have created frame with TMultiView component on it. Your .pas file looks like: unit Unit3; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.D

Categories : Delphi

How to define and use precompiled variable in delphi directives
You requirement may be better satisfied by the proper use of a VCS system. You need "branches" for every customer where customer-specific files contains customer-specific data. This will avoid to litter your code with complex directive to manage each customer - file names stays the same, just their content is different in each branch. Adding a new customer just requires to create a new branch and

Categories : Delphi

How to get image binary data using XMLHTTPRequest in Delphi
responseStream is IStream. You need to convert it using TOleStream (AxCtrls): uses AxCtrls, ComObj, ActiveX; procedure TForm1.Button1Click(Sender: TObject); var oXMLHTTP: OleVariant; MemoryStream: TMemoryStream; Stream: IStream; OleStream: TOleStream; begin oXMLHTTP := CreateOleObject('MSXML2.XMLHTTP.3.0'); oXMLHTTP.open('GET', 'https://www.google.com/images/srpr/logo11w.png', False)

Categories : Delphi

Installing Indy - which folders should be added to Delphi's Library list?
Nearly every component package I install I touch the project options for the runtime package(s) to get a clean install. Project Options General Configuration Output directory {componentpath}libXE4$(platform)$(config) Release Configuration Output directory {componentpath}libXE4$(platform) After that I compile the whole package for all target platforms in release and debug mode. Using a Bu

Categories : Delphi

Delphi - AnsiString Not Equal but dont know why
Both variables are AnsiStrings, both are the same value, and there are no spaces. You would appear to be mistaken, CompareStr says otherwise. The two strings are not equal. It is always best in a situation like this to doubt yourself rather than suspecting the library function to be incorrect. Step 1 here will be to add some debugging code. Output the two strings when interpreted as binary.

Categories : Delphi

Missing bytes on IdUDPServer.OnRead event in buffer array - Delphi XE3
The OnUDPRead event passes everything the socket receives from the OS. UDP operates on messages. Unlike TCP, a UDP read is an all-or-nothing operation, either a whole UDP message is read or an error occurs, there is no in-between. If you are missing data, then either the OS is not providing it (such as if it belongs to the UDP and/or IP headers), or you are not reading data from the AData parame

Categories : Delphi

Indy 10 Synchronize TIdTCPServer.onExecute with TIdSync
You are using a virtual ListView, but I see two mistakes you are making with it: You are calling AddItem() and Clear() on it. Do not do that. The whole point of a virtual ListView is to not put any real data in it at all. After you add or remove objects in your FActiveItems list, all you have to do is update the TListView.Items.Count property to reflect the new item count. It will invalidate

Categories : Delphi

Accessing camera(web cam) in Delphi and using it with VCL controls
FMX cleans up resources (e.g. bitmaps) in its main thread, which is missing in your case. There are (unofficial) ways to mix FMX and VCL (like MonkeyMixer) and they'll probably take care of this issue, but don't expect anything near the quality you had when using VCL with DirectShow: FMX is not thread safe and you'll have to synchronise all grabbed bitmaps with the FMX main thread before passing t

Categories : Delphi

Testing Somesite CRLF Bugs Hole Using Indy IdMappedPortTCP
NetData contains whatever raw data was available on the socket at the moment the OnExecute event was fired. There is no guarantee of the content of NetData on any given triggering of the event. So every time the event is triggered, you need to store that data to your own per-connection buffer somewhere, then you can parse that buffer looking for complete lines and tweaking them as needed, then u

Categories : Delphi

Cant seem to recive a reply vir com port
Here are several open questions in the air, so I have to make some assumptions that might be wrong, but let's see. I don't know what comm port library you are using, so I'm assuming it is the CPort library from SourceForge. I have never used it myself, but I have read that it is made Unicode aware, such that you can call the write methods with a unicodestring parameter which will be converted by

Categories : Delphi

Drop down menu for any TControl
Requirements If I understand you correctly, then the requirements are: At the first left mouse button click on a Control, a PopupMenu should be shown beneath the Control. At the second left mouse button click an that same Control, the shown PopupMenu should be closed. Realize that, disregarding the implementation of requirement 1 for the moment, requirement 2 happens automatically: when you c

Categories : Delphi

Simulating virtual methods in Delphi
You want to implement something that looks like virtual methods but does not use virtual methods or interfaces for performance reasons. You need to add some indirection. Create a record that holds procedural variables. For illustration: type TAddFunc = function(a, b: Double): Double; TMyRecord = record AddFunc: TAddFunc; end; Then declare two instances of the record. One populated

Categories : Delphi

how do i prevent adding duplicates items in listview in delphi
Just write your own procedure which does all the work for you. Also helps with your sub items, except I'm not sure what you were trying to do in your code (This is what I'm assuming you were attempting to do)... procedure TForm1.Add(const Caption, Sub: String); var I: TListItem; X: Integer; begin for X := 0 to ListView1.Items.Count-1 do if SameText(ListView1.Items[X].Caption, Caption) t

Categories : Delphi

TLabel Partly Font Size
Standard TLabel doesn't allow using different fonts. There are some such components in third-party component packs (arbitrary example - TRTFLabel from TMS). But you can use, for example, small TImage, and draw text on it's Canvas with different styles (losing some TLabel possibilities like autosize). var w, h: Integer; begin Image1.Canvas.Font.Size := 12; h := Image1.Canvas.Font.Height; /

Categories : Delphi

It is possible to display the windows context menu for multiple files using DisplayContextMenu form JEDI JCL library?
To show the context menu of several items, you must modify the code a little bit. First you must allocate an array of PItemIDList and fill each element of the array and finally pass to the GetUIObjectOf method the array with the number of elements. Try this sample uses JclShell, ShlObj; function MenuCallback(Wnd: THandle; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; var

Categories : Delphi

How to insert records with DataSnap
I don't know what you use as database connection, for my own convenience I have slightly modified for dbGO (parameters passed by variant). Also I have made a function from the server method, like this the client can be notified that there has been a problem (with the query, connection,...). Here is the server method: //server function TServerMethods1.NuevoCheque(idcliente, numero, cuenta, idban

Categories : Delphi

Pascal Pointers changing their pointing value
There are 2 things that could cause this kind of unexpected behaviour: If you have array-type properties for waypoints[0] and pathRefs[0] backed by getter methods: then there could be the possibility of those methods having side-effects which would cause the problem. (Obviously that's not the case here). If your pointers are referecing "invalid memory" locations: then memory overwrites by other

Categories : Delphi

Do I need to free dynamically created forms?
The parameter you passed to CreateNew is the owner of the component. When a component's owner is destroyed, it destroys all the components that it owns. So, the application object is the owner of your form. When the application closes, the application object is destroyed. And so it destroys all of its owned components. Including your dynamically created form.

Categories : Delphi

Implementing OnExpand/OnCollapse events for TTreeViewItem in Firemonkey
I missed the fact that in XE6 and later there is SetIsExpanded method, that is virtual. So my solution is somewhat trivial: TTreeViewItem = class(FMX.TreeView.TTreeViewItem) private FOnChangeExpanded, FOnChangeCollapsed: TNotifyEvent; protected procedure SetIsExpanded(const Value: Boolean); override; published property OnChangeExpanded: TNotifyEvent read FOnChangeExpanded wr

Categories : Delphi

Playing PCM Wav File in Delphi
Funny you post this when you did, because I just yesterday wrote a working WAV player using Microsoft's waveOut... API. You are not reading through the RIFF chunks effectively/correctly. I strongly suggest you use Microsoft's Multimedia functions (mmioOpen(), mmioDescend(), mmioAscend() and mmioRead()) instead of using AssignFile() and BlockRead(). WAV files are more complicated than you think,

Categories : Delphi

Is it possible to drag a TPanel to outside the TForm?
I've always thought the DockEx demo was over-complicated for learning the basics of docking. The following is the simplest example I know of: Add a TPanel to a blank form and set its DragKind property to dkDock, DragMode to dmAutomatic and its Align property to alTop. Drop a TButton on the TPanel Add the code below to the form: Run the project and manually drag the panel off the form. Click But

Categories : Delphi

What is the best practice for checking if the edit not empty
Reading the Text property loads the Edit's current content into memory as a temporary String . If you just want to check if the Edit is empty, there is a more efficient way to do that: if edt1.GetTextLen > 0 then // not empty else // empty Of course, the length will be > 0 if the Edit contains any characters at all, even if just whitespace. If you need to ignore leading/trailing whi

Categories : Delphi

What is the correct way to store record pointers in a Tqueue in Delphi
You get the "Abstract Error" because you use an astract object (TStrings)! In the TFrmSendEmail.CreateNewEmailRec method replace TStrings with TStringList: function TFrmSendEmail.CreateNewEmailRec: TPtrEmailData; begin new(result); //make a new record Result^.Body := TStringList.Create ; Result^.attachments := TStringList.create; end; Also, you can't free records using FreeAndNil! So your

Categories : Delphi

Indy SMTPServer send error message in OnConnect event
You have no control over how clients handle errors from the server. It is the client's responsibility to detect errors from the server and act accordingly, but they are not obligated to report the server's error messages to the user, they are free to do whatever they want. There is nothing you can do about that on the server side. All you can do is send out your error message, and hope the clients

Categories : Delphi

Move a TabSheet between PageControls
Move all controls to a separate Frame. Set Frame.DragKind to dkDock. Set Frame.DragMode to dmAutomatic. Set Form.PageControl.DockSite to True. Et voilá. See the sample in C:Program FilesBorlandDemosDocking for inspiration on how to customize this further.

Categories : Delphi

Delphi XE compiler fatal error after it mistakenly warns it had reached end of code
It is usually the first error that points to the actual problem. The rest of the errors and warnings may well be because of the parser getting out of sync, due to the first error. Check and double check the method at and around line 1752. Post it here if you can't see the error in your code.

Categories : Delphi

Record as procedure
Your only hope to make this syntax compile and function would be operator overloading. The operators that can be overloaded are listed here: http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading_(Delphi) Function call is not among the list of operators that can be overloaded. Thus your desired syntax cannot be achieved.

Categories : Delphi

Does Delphi support ARMv5 and ARMv6 CPU's?
As far as I know (and what embarcadero tells on the RAD studio road shows), for Android at least ARM v7 with NEON support is required. Edit: The (German) data sheet states "Android-Smartphones und –Tablet-Computer: ARMv7-Geräte mit NEON-Unterstützung," on the bottom of the last page.

Categories : Delphi

How to Choose Sharemem vs SimpleSharemem in 64-bit XE2
Sharemem is the old way of sharing memory managers. It relies on a DLL being deployed alongside your application. SimpleSharemem is designed to work with FastMM which handles sharing in a different way from Sharemem. So for modern versions of Delphi that use FastMM as their memory manager, use SimpleSharemem. Shared memory managers allow you to allocate memory in one module and deallocate in a

Categories : Delphi

How to trigger a method from a custom control which inherits from another custom control?
constructor TMyListBox.Create(AOwner: TComponent); begin inherited Create(AOwner); OnAddition := Addition; // shouldn't this call Addition procedure below? end; This assignment should work just fine. And no, it does not call Addition(), it assigns the address of Addition() to the OnAddition event. When the event is triggered, it will then call Addition(). However, that being said, this

Categories : Delphi

Converting UnicodeString to AnsiString
I think that returning a RawByteString is probably as good as you'll get. You could do it using AnsiString as you outlined but RawByteString captures the intent better. In this scenario a RawByteString morally counts as a parameter in the sense of the official Embarcadero advice. It is just an output rather than an input. The real key is not to use it as a variable. You could code it like this:

Categories : Delphi

Trigger Hotkey / Shortcut Event only once
Here is an example of how to solve this using Timer so that it doesent block users from using multiple different actions in a row. The speed for using of the same action depends on your configuration but is limited by system Key Autorepeat delay interval. See in code comments. const //Interval after which the action can be fired again //This needs to be greater than system key autorepeat dela

Categories : Delphi




© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.