Delphi

delphi textrect wordwrap

萝らか妹 提交于 2020-01-03 20:48:09
问题 I am using Canvas.TextRect in Delphi 7 to output something on the screen. I need my text to be word wrapped in the rectangle. 回答1: You need to use DrawText (or DrawTextEx) with the DT_WORDBREAK flag. See the sample in this thread. 回答2: Use DrawText( hdc, pchar(s), length(s), rcRect, DT_NOPREFIX or DT_WORDBREAK); where s : string to print rcRect : TRect the rect wherein the string should be printed. 来源: https://stackoverflow.com/questions/1648277/delphi-textrect-wordwrap

MadExcept triggers on try finally

守給你的承諾、 提交于 2020-01-03 19:55:10
问题 I am using MadExcept to debug my applications. It's an excelent framework though when a exception ocurrs on a try finally block it still displays that ugly box and the user thinks the app has crashed. How can i remove that ? Is there a way ? 回答1: Sounds like it's working as designed. A try/finally block does not catch exceptions; it ensures that proper cleanup can be done even if an exception is raised. If you want to handle an exception, you need to use a try/except block instead. 来源: https:

Does Delphi's conditional compilation allow the defined symbols to contain values?

做~自己de王妃 提交于 2020-01-03 18:03:14
问题 In Delphi, you can define symbols, just like in C/C++. Delphi: {$DEFINE MY_SYMBOL} C/C++: #define MY_SYMBOL This allows you to check whether the symbol is defined by using {$IFDEF MY_SYMBOL} in Delphi, or #ifdef MY_SYMBOL in C/C++. This is a boolean value - either the symbol is defined during pre-processing or not. However, C/C++ also allows you to assign values to preprocessor symbols. E.g.: #ifdef DEBUG #define DB_HOST "127.0.0.1" #else #define DB_HOST "123.456.789.123" #endif Database

Modify requestHeaders in “custom” browser in delphi

左心房为你撑大大i 提交于 2020-01-03 17:35:56
问题 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 . 回答1: You can modify the headers with the OnBeforeNavigate2 event: procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject; const pDisp:

Modifying VCL Component CODE

a 夏天 提交于 2020-01-03 17:32:08
问题 I need to change the functionality in a component. What do you do when you get a "you can't override this" message, or you need to change the code in a private method ("method does not exist in base class" message), rendering it impossible to descend the component? 回答1: If I face that problem, I first try to inherit from the component, or its CustomXXX ancestor and see if that fixes the problem. If that doesn't, I go deeper, i.e. try to intercept the messages that come in. That can be done

How to set button's anchor property dynamically?

 ̄綄美尐妖づ 提交于 2020-01-03 17:21:27
问题 I want to set TBitBtn 's anchor property dynamically. First I have set the button's anchor as top right in design time. In that button click event I set form's BorderStyle as bsDialog . Then there should be a gap as shown in image. I want the button should be beside close button. So I need to set button's left and its anchor as top right after assigning border style as bsDialog . Is it correct? I don't know the way to change anchor property dynamically Thanks, Rakesh 回答1: I don't know if I

Delphi Passing Dynamic array of Records to function

烂漫一生 提交于 2020-01-03 17:17:13
问题 I have a Dynamc array of Records and I wish to pass one of the items in the array to a function by reference So for example one of the array items - AArray[1].arecorditem is a string of 6 characters String[6] the function would be - function dosomething(var AStringVal:string):Integer; So I would execute Aresult:= dosomething(AArray[1].arecorditem); however when I try to compile I get the Error Type of actual and formal var parameters must be identical. Is this possible to do or should I

Is there a way to obtain IExplorerBrowser interface of running or newly open explorer window for subsequent BrowseToXXX call?

孤街醉人 提交于 2020-01-03 16:49:47
问题 Asking because in the previous question i was pointer to IExplorerBrowser, however it creates a child window, while Explorer's "Find Target..."behaviour i want to simulate (see previous) exhibits some level of control over newly open or existing Explorer window (i believe that right term is folder view, feel free to correct). Also looking for other API(s) to accomplish BrowsingTo or similar behaviour. 回答1: This isn't possible. See Raymond Chen's blog post on the subject. 来源: https:/

Delphi Form Restored State Position and Size

霸气de小男生 提交于 2020-01-03 16:43:34
问题 In a maximized delphi form, how to get form's restored state position and size? I know in .NET we use RestoreBounds and DesktopBound . 回答1: This is not exposed by the VCL framework. Instead you need to dip into the Win32 API. The function you need is GetWindowPlacement. var WindowPlacement: TWindowPlacement; .... WindowPlacement.length := SizeOf(WindowPlacement); Win32Check(GetWindowPlacement(Form.Handle, WindowPlacement)); The information you need can be found in the WindowPlacement struct.

PostgreSQL 9.X bytea representation in 'hex' or 'escape' for thumbnail images

怎甘沉沦 提交于 2020-01-03 16:37:28
问题 My application (developed in Delphi and ZEOS components) uses PostgreSQL 8.4 and stores some thumbnail images into a bytea column. I want to migrate to PostgreSQL 9.2 and have restored the dump and everything works fine except when I try to retrieve those images: Postgres 9.2 uses hex for output representation instead of escape used in Postgres 8.4. There are two possible solutions: Change the Postgres 9.2 settings for escape representation or change the hex string in binary data via