lazarus

Can a Windows GUI program written in Lazarus create a console and write to it at runtime?

こ雲淡風輕ζ 提交于 2019-12-11 08:29:08
问题 When writing a Lazarus program, you have the option of using $APPTYPE console or deselecting the Win32 GUI Application ( -WG option) in the Project Options . I noticed that without these options DebugLn and WriteLn raise exceptions. Is there a way to create a console even if the program is not compiled above mentioned options and output to it with DebugLn and WriteLn afterwards? 回答1: In windows it is a little more tricky compared to Delphi. In Delphi all you need to do is to call AllocConsole

Why does the TDBGrid take up more space at run-time?

China☆狼群 提交于 2019-12-11 05:05:24
问题 I have bumped into a pretty confusing problem. At design time, I clearly indicate the size of columns (width and Max width) for the TDBGrid. Here's the problem... As you see, the design time and run-time grids are different in size. And also note that the form is the same size. Please ignore the rest of the screen. My only concern is the window with the grid :) Is there any way I can fix this? BTW, I'm working on Ubuntu with Lazarus but the software may be on Ubuntu or Windows. I'd really

How to prevent TRichMemo from resetting text attributes when you add new text

筅森魡賤 提交于 2019-12-11 04:47:32
问题 I have a TRichMemo object which I create and populate with text at runtime. I have a timer that triggers a function each 10 seconds. The function looks something like this: procedure TServerSideForm.NewLineTimerTimer(Sender: TObject); var timeForward: TDateTime; timerText: wideString; startRange, endRange: longInt; begin timeForward := Time; timeForward := IncSecond(timeForward, ServerSideForm.NewLineTimer.Interval div 1000); //... timerText := TimeToStr(Time) + ' - ' + TimeToStr(timeForward)

Using event listeners in a non-gui environment (DLL) (Delphi)

梦想与她 提交于 2019-12-11 04:46:45
问题 I am attempting to convert a GUI application that I made in Delphi (actually, its Lazarus) to a library(DLL). In the GUI application I used a OnDataChange event listener, but I cannot seem to figure out how to do the same thing for the library. Here is what it looks like in the GUI App: procedure TForm1.Datasource2DataChange(Sender: TObject; Field: TField); begin ZMakeRankedTable.Close; GetNN; end; And in the unit's LFM file: object Datasource2: TDatasource DataSet = ZMakeRankedTable

Why does a valid constructor in Delphi fail in Lazarus?

梦想的初衷 提交于 2019-12-11 02:32:25
问题 I'm working through tutorials in both Delphi and Lazarus. I'm using Delphi 10.1 Berlin Update 2 and Lazarus 1.6.2. The following constructors work in Delphi, but the constructor in the TDog class fails in Lazarus with a "duplicate identifier" error. All tutorials and forums I have searched look like this shouldn't be a problem. unit Animal; interface uses classes; type TAnimal = class private FName: String; FBrain: Integer; FBody: Integer; FSize: Integer; FWeight: Integer; public constructor

How do you escape a reserved word in Free-Pascal?

心已入冬 提交于 2019-12-11 02:31:59
问题 Actually i'am working on translate some librarys to free-pascal. so the problem is which in delphi can use the ampersand (&) symbol to escape a reserved word, but in free-pascal does not work. the compiler complains with this message ForLibDx.pas(72,13) Fatal: illegal character "'&'" ($26) when include an ampersand symbol. actually i am using the {$MODE DELPHI} to compile my units under free-pascal FPC 2.2.4 Lazarus 0.9.28.2 thanks in advance. 回答1: From what I recollect, the FPC compiler does

How to know that a form was created?

坚强是说给别人听的谎言 提交于 2019-12-11 02:13:53
问题 I want to find a way to know that a form was created at run time (or destroyed). This for Delphi or fpc. Many thanks PS : Is there a way to retrieve that info for all objects ? 回答1: I want to have a event that tells me that a new object was just created at run time (or destroyed). There are no built in events that fire whenever an object is created or destroyed. Because I like writing code hooks, I offer the following unit. This hooks the _AfterConstruction method in the System unit. Ideally

Pascal passing a listview from mainform to a nonmodal form

♀尐吖头ヾ 提交于 2019-12-11 00:44:14
问题 I have a listview in my mainform that I want another nonmodal form to be able to add things to. How would I pass the listview to the nonmodal form? The form I want to be able to modify it is shown by the MainForm on a button click, just with Form.Show. I should also clarify that I want the form to not use the mainform to avoid circular reference. 回答1: The simplest and best way would be to add a method to the receiving form - that is, the form with the ListView on it -- that says

Using a indentifier or reserved word in a automation object under FPC

大兔子大兔子 提交于 2019-12-10 19:51:28
问题 Actually i am using OLE automation under Free Pascal , but some objects have properties which uses reserverd words as names, so i cannot compile the code. check this sample MyObj : OleVariant; begin MyObj := CrealeOleObject('AObject'); MyObj.Descriptor := Param1; MyObj.Type := Param2; //this line generates a error this is the error StdOleAux.pas(783,15) Fatal: Syntax error, "identifier" expected but "TYPE" found so the question is how i can access this properties in FPC when they have a name

FPC : RTTI on records

会有一股神秘感。 提交于 2019-12-10 14:37:18
问题 This is my first time on this site. Usually, I have no problem to found replies in the old posts but I don't success with my actual problem. I would like to know how use RTTI functions to know at running time the properties/members of a record under Lazarus/FPC? I know how to do it for a class (Tpersistent descendant and published properties) but not for FPC. Some links indicates how to do it under Delphi (From D2010), but I don't know how to transpose it under Lazarus. Thanks in advance for