Delphi Generic factory

suppose I have a TModel: TModelClass = class of TModel; TModel = class procedure DoSomeStuff; end; and 2 descendants: TModel_A = class(TModel); TModel_B = class(TModel); and a factory : TModelFactory = class class function CreateModel_A: TModel_A; class function CreateModel_B: TModel_B; end; Now I want to refactor a bit : TModelFactory = class class function CreateGenericModel(Model: TModelClass) : TModel end; class function TModelFactory.CreateGenericModel(Model: TModelClass)

delphi 2010 IDE 'error insight' error

when I open concrete projects the error insight mark with red lines incorrect areas of the screen. Also when I compile It, error messages are shown, but the line number displayed in the message window points to a wrong line in the code window. When I double click over a error message the ide goes to another line. how do i correct this problem? Regards, Francis

Delphi Not enough storage error on CGI app under Win64

I have a Delphi (hence 32-bit) CGI app running on a Windows 2008 64-bit server that has 24 Gb RAM with IIS7. The web service runs fine for a few days at a time (sometimes a few weeks) and then suddenly starts reporting "Not enough storage available to process this command." Now I've seen this before in regular Windows apps and it normally means that the machine ran out of memory. In this instance, the server shows that only 10% of physical RAM is in use. On top of that, TaskManager shows only

Delphi Split a string into an array of strings based on a delimiter

I'm trying to find a Delphi function that will split an input string into an array of strings based on a delimiter. I've found a lot on Google, but all seem to have their own issues and I haven't been able to get any of them to work. I just need to split a string like: "word:doc,txt,docx" into an array based on ':'. The result would be ['word', 'doc,txt,docx']. Does anyone have a function that they know works? Thank you

How to Make a exe files with Delphi?

I want to make a "Setup Maker" App with Delphi. How can I create a exe files? for example : Delphi Itself Compiler. Tanks to All. ....NiliDelphi....

Which of the actively developed Delphi components still support Kylix?

I've been reading about CrossKylix recently, but for most uses one has to consider 3rd party components. So I would like to know which of the actively developed components still support Kylix. Many added partial or complete Kylix support back in the day, but I'm affraid some never kept updating, and the IFDEF-ed parts that compile with Kylix might not be tested. So, ideally, I'd like a report from those with real apps and practical experience. This might be of interest for users that are look

How to use TBBMM in Delphi IDE and compiled application

I learned that TBBMM seems to have better performance than FastMM. FastMM is default memory manager in recent release of Delphi IDE. However, I find not much information regarding the deployment of TBBMM for Delphi users. How may I replace the default memory manager in Delphi IDE and the compiled application?

How to write an EXE which is also a COM Server in Delphi

I have a Delphi (2007) application which is just a standard exe, and I would like to add a COM interface to it. I already have a COM dll which exports several COM objects and this is working perfectly. However when I attempted to insert the COM logic from the dll (ie the "exports" and "{$R *.TLB}" and the relevant uses) into the EXE's dpr file it all compiles perfectly but refuses to register when I call regsvr32 myname.exe I also tried creating an completely new VCLForms application and adding

Send data to PDF with Delphi

Is there a way I can send data to my PDF file, (fill in the fields/blanks), either manually or by a third party component, the PDF files have certain fields that can be modified by user, entering numbers.. checkboxes etc etc how can I achieve this goal, an if it will require some third party component, which is the best, and what are the prices? our Development IDE is delphi 2010 / Delphi 2011 XE thanks :)

Delphi Unmarshalling Error

I get an error whenever I try do a request to a SOAP service: Unmarshalling Error: unexpected element (uri:"http://www.domain.com/ws/servicename/", local:"dummyArg"). Expected elements are <{}dummyArg> The method that I'm calling has is defined as: function GetTxServer(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): TxServer; I have little experience with SOAP, and I couldn't find any useful information on this. Feel free to ask any question that might speed up the process in fin

Delphi Make a TFindDialog and TReplaceDialog Modal?

I am using some TFindDialog and TReplace Dialogs in my Application. How can I show the Dialogs Modally, like the Open and Save Dialogs do? I dont want any user to be able to select any controls in the Application when the Find and Replace Dialog is open.

Delphi Problem with Generics and As Cast

Possible Duplicate: “As” operator for constrained generic types The following reduced sample code produces a compiler error when trying to cast to the generic type using the as operator. Strangely enough the combination of the is operator and a hard cast does work as expected. program Project8; {$APPTYPE CONSOLE} uses SysUtils, Controls, StdCtrls; type TControlWrapperBase = class protected FCtrl : TControl; public constructor Create (Ctrl : TControl); en

Set Background Image for a Form in Delphi

I have an old app (Delphi 5) which I want to give it some changes via Res Editor ! I want to set a background image for a Form via RCData in Res Editor, How can I do that? Any help is really appreciated. Thanks :)

Delphi XMLHTTP and "Access denied" error

I'm trying to retrieve a content of HTTP document with MS XMLHTTP COM. I did copied the following sample code but even this does not work and fails with EOLEException error 'Access is denied' at send method call. uses MSXML, ComObj, ActiveX; procedure TForm1.Button1Click(Sender: TObject); var httpDoc: XMLHTTP; // IXMLHTTPRequest begin httpDoc := CreateOleObject('MSXML2.XMLHTTP') as XMLHTTP; try httpDoc.open('GET', 'http://www.google.com/index.html', False, EmptyParam, EmptyParam

Delphi XE2 DataSnap - Access REST connection properties in server methods module

I'm building an XE2 DataSnap server which will serve connections from REST clients. My DSServerClass LifeCycle property is set to 'Invocation'. The REST connection properties will include username and password, which are handled through the DSAuthenticationManager UserAuthenticate() event. What I need to know is how can I access the username and password within the server methods class? I want to be able to know which REST username/password launched the object instance of my server class.

Delphi XE and Winsock

I'm upgrading my application from Delphi 2007 to Delphi XE. I have my personal written Socket component. In the new environment (XE) it is not working properly. The same code works in Delphi 2007. Here's my code fragment: uses WinSock; procedure TForm1.GetProtocolClick(Sender: TObject); var ProtoEnt: PProtoEnt; FProtocol: Integer; begin FProtocol := IPPROTO_TCP; ProtoEnt := getprotobynumber(FProtocol); if Assigned(ProtoEnt) then ShowMessage(ProtoEnt.p_name); end; var WSAData:

Modify requestHeaders in "custom" browser in delphi

I have a browser integrated in my deplhi application (IE). I need to call a certain web app and I need to append a new variable in the header for all the requests that come from my application's browser, like jquery adds to the xhrobj the HTTP_X_REQUESTED_WITH parameter. Any idea on how can I do that? code samples would be great. I am usin TWebBrowser.

Delphi XE3, How to set MSXML MaxElementDepth to allow reading deep XML documents

I have an SVG file that for some reason has over 256 depth nested elements and that is preventing Delphi loading the SVG file, as it violates the MaxElementDepth constraint of MSXML (default is 256). Does anyone know of a way to set the MaxElementDepth value in MSXML higher from within the running program so I can read in the SVG file? I tried the alternative CoDOMDocument40 which has a method (setProperty) for setting properties, but it reports Invalid property name when I try to set MaxEleme

Delphi How can I assign the OnClick event of a ToolButton at runtime?

I have a TToolBar created in design time with no ToolButtons. My idea is to create ToolButtons in runtime and place them there when my forms are created, just to show the user what forms are opened without needing to open a "Windows" menu in the main menu. I have an unit named NavigationUtils.pas that I use to store the procedures / functions about navigation (as the creation of the buttons when my forms are created). The question is: How can I configure the OnClick event when the ToolButtons

Delphi How to select a Menu Item without closing the Menu?

By default when you select an item from a TMainMenu or TPopupMenu etc, the menu closes after it was clicked. I would like to change this behavior so that when I select on a menu item, the menu does not close but remains visible and open at the point it was last clicked, making it easier to select another menu item if desired. Of course, switching focus to another control should hide the menu like normal, but if the focus is still on the menu keep it visible. If this is possible, I would like th

Delphi How to set ExitCode in a VCL Forms Application

I can't get ExitCode to work for a VCL forms application. Here is my test application. It was created from the File / New menu in the Delphi 2007 IDE. The only change is that I added the line ExitCode := 42; at the end. program Test; uses Forms, Unit27 in 'Unit27.pas' {Form27}; {$R *.res} begin Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TForm27, Form27); Application.Run; ExitCode := 42; end. Now, when I run it from the command line,

Delphi, secure and fast access to partial elements of a static array

I have static array with 100 items type of record: TMy_Array:array[1..100] of T; where T is: T = record A: double; B: Date; C: String; end; I have n similar threads modifying their elements in the TMy_Array TMy_Array[n].A; TMy_Array[n].B; TMy_Array[n].C)`. N is close to 100. I also have 10 other threads that selectively modify any field TMy_Array. To achieve this safely should I use critical sections and here comes the question: Does use only one critical section will not ca

Keeping record of save place in Delphi

Well, I'm making a program in Delphi that uses a TValueListEditor object to store Keys and Values and save them to a .txt file. I used this functions to do so: procedure TfrmInserir.FormClose(Sender: TObject; var Action: TCloseAction); begin vlePalavras.Strings.SaveToFile('C:\Users\Felipe Knop\Desktop\Felipe\Algoritmos\Delphi\Projetos\Palavras Japonês\Lista.txt'); end; procedure TfrmInserir.FormCreate(Sender: TObject); begin vlePalavras.Strings.LoadFromFile('C:\Users\Felip

How to turn an Indy UTF-8 response into a native Delphi (Unicode)String?

Using Indy THTTP I obtain a response that has Content-Type: text/html; charset=UTF-8 and store it in a TStringStream. If I then use ReponseStream.ReadString(ResponseStream.Size), the resulting String is not correctly shown. I bet this is due to the fact that Windows uses UTF-16. I tried a few things with TEncoding.UTF8 and TEncoding.Convert that only messed up the result even more (started to look Chinese). Here's the current code: var LHTTP: TIdHTTP; LResponseStream: TStringStream; LRe

Why does Delphi insert nop's in the middle of nowhere?

The following code: while Assigned(p) do begin np:= p^.next; h:= leaf_hash(p^.data); <<-- inline routine h:= h mod nhashprime; p^.next:= nhashtab[h]; nhashtab[h]:= p; p:= np; end; { while } Produces the following assembly: hlife.pas.605: h:= leaf_hash(p^.data); 00000000005D4602 498B4018 mov rax,[r8+$18] 00000000005D4606 48C1E830 shr rax,$30 00000000005D460A 498B5018 mov rdx,[r8+$18] 00000000005D460E 48C1EA20 shr rdx,$20 00000000005D4612 81

Unidac (delphi) macro issue

I have query: select &macro1 from table1 where &macro2 delphi code: macrobyname('macro1').value := 'field1 as test,field2'; macrobyname('macro2').value := 'test=1'; i got an error like this: Unknown column test in where clouse question 2) showmessage(sql.text); Result is "select &macro1 from table1 where &macro2" but I expect "select field1 as test,field2 from table1 where test=1" how can i get sql.text after macro replacing. (Excuse me for bad english). best reg

Why scrolling a TListView calls for an entire form repaint - Delphi Firemonkey

Starting with a blank mobile app, I added a TlistView, a TCircle, and a TMemo. None of the controls had any alignment other than the default and they are all direct children of the main form. In the OnPaint event of the ListView, I put this: Memo1.Lines.Add('ListView paint'), For the circle OnPaint: Memo1.Lines.Add('Circle paint'); When I ran the app the results were that scrolling the listview resulted in lots of "Listview paint" and "Circle paint" getting added to the memo, both item

Delphi FireMonkey - How to set a file to deploy to different locations on Android and iOS?

I am an old-timer to Delphi but only very new to Delphi XE5 and FireMonkey. I am trying to write a cross-platform iOS/Android app to display some videos. From tutorials like this -> http://blogs.embarcadero.com/davidi/2013/11/23/43005/ <- I can deploy a file, and I can play it under both platforms. HOWEVER, this deployment screen is driving me nuts; no matter whether I select 'Android platform' or 'iOS platform' whenever I add a file it shows as being for "[Android,iOSDevice,iOSSimulator]"

Delphi Where can I configure DCC_ExeOutput?

Is it possible to configure DCC_ExeOutput from Delphi? I could only change this by editing the dproj file. I couldn't find where to edit this option even using Delphi IDE Insight. Update 1: This is my Project Options: @TOndrej have suggested me change output directory, but I have already done this, and DCC_ExecOutput didn't change. The only way was editing dproj file. Update 2: My purpose is organize the folder structure of Delphi projects like suggested by Zarco Gajic in his article Ho

Delphi How to use generic TList List property

DelphiXE7 Update1 While trying to work with the TList.List property I noticed an odd behavior. If you look at the following code it seems that the array size returned by MyList1.List is not correct... So, where the bug? Is it in my code/head or within the RTL ;-) var MyList1, MyList2: TList<String>; begin MyList1 := TList<String>.Create; MyList2 := TList<String>.Create; MyList1.Add('A'); MyList1.Add('B'); MyList1.Add('C'); MyList2.AddRange(MyList1.List); //

Capture Device with Delphi (FireMonkey)

I'm using Delphi-FireMonkey (TCaptureDeviceManager.Current.DefaultVideoCaptureDevice) to integrate a capture device to my system and I wonder how can I set TV channels on capture device with FireMonkey. Is there any way to do this? My device is a AverMediaTV HD Pro USB (H868).

ZBar code scanner ntdll.dll error in delphi

I am trying to scan a image using ZBar and I am working from this code example : http://blog.freehand.com.ua/2013/03/zbar-reading-bar-codes-in-delphi.html This is the code I currently have : procedure TForm1.Button1Click(Sender: TObject); var zimage : zbar_image_t; weirdVarArea : SIZE_T; weirdVarBlob : PByte; sym: zbar_symbol_t; begin zimage := zbar_image_create; zbar_image_set_format(zimage, 'Y800'); zbar_image_set_size(zimage, Image1.Picture.Width, Image1.Picture.Height); weirdVarAr

Converting Integer number into hexadecimal number in delphi 7

Write a program to convert an integer number to its hexadecimal representation without using inbuilt functions. Here is my code, but it is not working. Can anyone tell where is the mistake? It is giving an error: "Project raised exception class EAccessViolation with message 'Access violation at address 00453B7B in module 'Project.exe'.Write of address FFFFFFFF'.Process stopped.Use Step or Run to continue." unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes,

Delphi Generic functions for converting an enumeration to string and back

I'm trying to write functions that will convert an enumeration to string and back again. ie: TConversions = class strict private public class function StringToEnumeration<T:class>(x:String):T; class function EnumerationToString<T:class>(x:T):String; end; in the implementation section I have uses System.TypInfo ; class function TConversions.StringToEnumeration<T>(x:String):T; begin Result := T(GetEnumValue(TypeInfo(T), x)); end; class function

Delphi Memo lines to TreeView

Good night friends, I'm currently working on a project that involves enumeration of visible windows and their descendents (also visible). And I can transfer all nodes of TreeView for a Memo (in text format) one by one, but now I'm trying to do the opposite (of necessity of the project). Someone could help me with this here in StackOverflow? Here is all the code that lists the windows on TreeView and after transfers it to one Memo. function GetWindowTitle(hwnd: HWND): string; begin

Need to get event parameters along with their respective types separately at run time in Delphi

I am using Delphi XE5. I have am storing property and event names of provided Delphi VCL component using below code in an excel file. procedure TForm1.Button1Click(Sender: TObject); var PropInfo: PPropInfo; MyPTypeInfo : PTypeInfo; MyPPropList : PPropList; Count, I : Integer; PropOrEvent, PropValue : String; FileName : String; begin FileName := 'C:\MyFile_Delphi.xlsx'; ListBox1.Items.Clear; GetPropList(Button1, MyPPropList); try Count := GetPropList(Button1, MyPPro

Delphi StrUtils.SplitString not working as expected

I use the StrUtils in to split a string into a TStringDynArray, but the output was not as expected. I will try to explain the issue: I have a string str: 'a'; 'b'; 'c' Now I called StrUtils.SplitString(str, '; '); to split the string and I expected an array with three elements: 'a', 'b', 'c' But what I got is an array with five elements: 'a', '', 'b', '', 'c'. When I split with just ';' instead of '; ' I get three elements with a leading blank. So why do I get empty strings in my first

how to store data on Firebase - Delphi XE 10

What is the best way to connect to Google´s Firebase DBaaS from Embarcadero Delphi XE 10 ? I am not sure how to do it from AnyDAC. Or if exists a component out there (i coundnt find one on search) Any help? thank you

How to cast a generic type into an actual type in Delphi

Consider the following code procedure TMyClass.SetParam<T>(Name: string; Value: T); begin if (TypeInfo(T) = TypeInfo(string)) then begin FHashTable.AddString(Name, (Value as string)); end else if (TypeInfo(T) = TypeInfo(Integer)) then begin FHashTable.AddInteger(Name, (Value as Integer)); end ...... I want to have a generic procedure that gets a generic value of type T and according to the actual type of T insert the value to an hashtable. The compiler won't let me

Delphi Accessing Database from FireMonkey app on MAC

According to Embarcadero's docwiki, it is possible to setup unixODBC on a MAC and compile an app that connects to a database and run it on a MAC. The instruction shows how to compile the unixODBC but does not show how to create the required database drivers, which means no database connection can be setup. Has anyone been able to successfully do this? FYI, I am trying to connect to a Sybase ASE database. I can create the 64 bit version of unixODBC and drivers using the instruction found here an

What does "$" in the line "i:= i - $24" on Delphi?

What does "$" in the line "i:= i - $24" on Delphi? I rewrite code to C++. It's use in the simple of bass.dll. // complete the WAV header WaveStream.Position := 4; i := WaveStream.Size - 8; WaveStream.Write(i, 4); i := i - $24; WaveStream.Position := 40; WaveStream.Write(i, 4); WaveStream.Position := 0;

Delphi linux firemonkey GUI

I am going to buy Delphi Tokyo because my company has XE2 and we need a fresh update. I see that Delphi tokyo has Linux support but I have 2 questions: 1) I have seen that I can make apps for linux ubuntu server. Does Delphi allow apps for ubuntu client lts as well? 2) Can delphi produce GUI? I mean firemonkey support for linux so that I can use buttons and so on. If not is it planned? Thanks in advance

FDQuery parametres in Delphi 10 seattle

I have this query : SELECT * FROM Vente WHERE (DatePart ("d", Vente.DateDebut)=01) and (DatePart ("m", Vente.DateDebut)=06) and (DatePart ("yyyy", Vente.DateDebut)=2017); This query is working fine in MS Access 2010 , but when I try to excute it from TFDQuery component , it give me an error : [FireDAC][Phys][ODBC][Microsoft][Pilote ODBC Microsoft Access] Too few parameters. 3 Expected ... What's the problem? How can I fix that? Update: It seems like the problem in the DatePart () fun

Delphi Key press getting lost in menu loop

I want to build a menu form that acts similar to ribbon keytips - you can press and hold Alt, then press and release e. g. d, then release Alt to trigger an action or press and release Alt, then press and release d to trigger the same action I took inspiration at Hidden Main Menu in a delphi program automatically shown using Alt key and came up with the following demo: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, D

How can I save a WhatsApp session using Delphi and Chromium?

I'm using the CEF3 2378.1280 branch and Delphi 10.1. I'm using the following code to save sessions: var CookieManager: ICefCookieManager; FromCreate: CookiesPath := ExtractFilePath(Application.ExeName) + 'cookies'; CookieManager := TCefCookieManagerRef.Global(nil); CookieManager.SetStoragePath(CookiesPath, true, nil); This code work fine with Facebook and a lot of other sites. But for web.whatsapp.com it can't save the session: After restarting the program, I must do tge QR-c

Delphi Monitor current line number while running DWScript?

I'm using the latest DWScript which has a TdwsDebugger component with it. However I'm not necessarily looking to provide debugging tools to the user - just visually show the current line number. In the TdwsDebugger component, in its OnDebug event, expr.ScriptPos seems to provide me with this information. But I'm trying to figure out how to make use of this without actually "debugging". How can I show current DWScript line number without implementing debugging?

Delphi Compress with ZLIB to array of Bytes?

Can I somehow compress with Delphi using ZLIB (Deflate with ZLIB headers) and get an array of Bytes? Right now I am copying from TMemoryStream but it would be nice to not copy back to array (so it's faster overall) PackedStream := TMemoryStream.Create; ZLib := TZCompressionStream.Create(PackedStream); ZLib.WriteBuffer(UnpackedArray[0], UnpackedArrayLen); ZLib.Free; PackedArrayLen := PackedStream.Size; SetLength(PackedArray, PackedArrayLen); PackedStream.Position := 0; PackedSt

Delphi FireMonkey FlowLayout isn't refreshing items based on visible property

How are you? Hope you doing fine. My question: I have a FlowLayout with a lot of layouts inside it, and I need to hide a few based on a radio button selection, in design time it works fine I set the visible property to false and all the other layouts realign the right way, but when I do this at runtime it doesn't work, it keeps a white gap between the layout that has been hidden and the next one. When I do a resize manually (go to the form border and drag a little) it realigns and gets right, bu

  1    2   3   4   5   6  ... 下一页 最后一页 共 151 页