Delphi

How to pass the address of a thread function as a callback to winapi?

戏子无情 提交于 2019-12-30 12:47:09
问题 I have a simple thread and inside the execute I try to call EnumWindows() with the address of one of the functions defined in the thread. So I'm trying to do this: EnumWindows(@cbEnumWindowsClickOK, 0); where cbEnumWindowsClickOK is an EnumWindowProc defined inside the thread class, like so: TAutoClickOKThread = class(TThread) private fExitEvent : THandle; function cbEnumWindowsClickOK(Wnd: HWND; Info: Pointer): BOOL; public constructor Create(ExitEvent : Thandle); procedure Execute();

TMemo cannot handle Unix text (LF as line ending) correctly

左心房为你撑大大i 提交于 2019-12-30 11:56:06
问题 TMemo cannot handle Unix enters (LF) correctly. Two lines separated with a LF are shown and treated as one line. I want to handle all possible text formating (Mac, Win, Unix). Obviously I could check the text and replace the LF with CRLF every time I: load text form file paste text use the Add() function use the Insert() function use the Appen() function change the content via Text property But this won't be an elegant solution. Lazarus solved this problem with the Lines.TextLineBreakStyle

Use UIDocumentInteractionController in Delphi XE

人走茶凉 提交于 2019-12-30 11:49:09
问题 I have a Delphi XE5 app which downloads and stores PDFs locally on the device. I have a TWebBrowser on the form to view the PDFs and it works perfectly. I now wish to share the PDF with other applications (eg Safari, Mail, etc) but am really struggling! I have looked at the TShowShareAction action (on the Action List control) but this caters for a Bitmap (photo) to be shared. I have seen a lot of posts explaining that one should use UIDocumentInteractionController but I cannot find examples

MySql and Delphi direct connection

陌路散爱 提交于 2019-12-30 11:40:08
问题 I am looking into a free solution to connect delphi with a mysql database but without using ODBC.Is there such a component ? Thanks. 回答1: You can use either: TmySQL latest version released on 2002. mysql.pas which works with recent Delphi version (D3 through DXE2) / MySQL version 3.23, 4.0, 4.1, 5.0, 5.1. 回答2: i have been looking and using for years many tools, free and paid. 1st free is weak or difficult, at least u need too much code to do simple tasks which can be done in one or two

How to copy the properties of one class instance to another instance of the same class?

こ雲淡風輕ζ 提交于 2019-12-30 11:39:17
问题 I want to duplicate a class. It is sufficient that I copy all properties of that class. Is it possible to: loop thru all properties of a class? assign each property to the other property, like a.prop := b.prop ? The getters and setters should take care of the underlying implementation details. EDIT: As Francois pointed out I did not word my question carefully enough. I hope the new wording of the question is better SOLUTION: Linas got the right solution. Find a small demo program below.

Change text size in Firemonkey StringGrid

一世执手 提交于 2019-12-30 11:38:28
问题 How to change text size in stringgrid header? 回答1: You could write an OnApplyStyleLookup event handler similar to this: procedure TForm1.StringGrid1ApplyStyleLookup(Sender: TObject); var Header: THeader; I: Integer; begin Header := THeader((Sender as TStringGrid).FindStyleResource('header')); if Assigned(Header) then begin for I := 0 to Header.Count - 1 do with Header.Items[I].Font do begin Size := 32; Style := [TFontStyle.fsBold]; end; Header.Height := 48; end; TStringGrid(Sender).Realign;

How to make PBear's THtmlViewer load & show a unicode HTML file?

霸气de小男生 提交于 2019-12-30 11:37:29
问题 I have some unicode .html files that I want to display inside a THtmlViewer component, in Delphi. I can't seem to persuade the code to work just doing '.LoadFromFile' - do I firstly need to load the unicode file into a stream and then somehow convert it? Delphi 2007, THtmlViewer v9.45 I've not done anything with unicode files, or THtmlViewer, before. 回答1: FYI, THTMLViewer is actively maintained on google code (last commit couple minutes ago): http://code.google.com/p/thtmlviewer/ D6-DXE2 and

Binding a second instance of a form to a second instance of a data module?

久未见 提交于 2019-12-30 11:24:05
问题 I have a Form which has data aware controls bound to datasets in a datamodule. I need to create additional instances of both the form and datamodule in the same application. I deleted the global variable that was automatically created when the data module was first added to the project. To my delight, controls in the designer could still be bound to datasets in the data module without this global variable. I'm assuming the IDE is parsing the dfm of the datamodule so the designer can still

Upload file to DataSnap REST server via TStream

只愿长相守 提交于 2019-12-30 11:12:44
问题 I've built a DataSnap REST server using Delphi XE2 and I've added a server method for uploading files via TStream : function TServerMethods.updateUploadFile(sFilename: string; UploadStream: TStream): string; I want to be able to call this from a number of different clients (Android, iOS etc) and I've been testing the method using various REST clients such as Postman (Chrome plugin). However so far I cannot get it to accept the content for the HTTP POST body. Whenever I send the POST command I

Delphi XE ISAPI WebBroker file upload

大憨熊 提交于 2019-12-30 11:09:15
问题 I need some help accepting file uploads on an ISAPI in Delphi XE2. In Delphi 2007 I use Shiv's TMsMultipartParser and it works 100%. Trying to use this in XE2 doenst work. From what I can tell the contents length is read incorrectly and then the buffer's lenght is set incorrectly. My testes between 2007 and XE2 shows that the length on XE2 is 3 bytes larger for the same file. Unfortunately I dont know how to fix this, nor can I find anything else on how to accept the files from the upload