freepascal

FreePascal: how do I change the colour of a TPaint object on Mouseover

寵の児 提交于 2019-12-24 10:49:35
问题 My Custom menu is coming along nicely and can detect when the mouse is within the boundaries of the link rectangles and respond to mouseup events. What I would now like for it to do is change the colours of the link rectangles when the user hovers the mouse within their boundaries. I've set colour properties this way before but manually and not dynamically. Basically, nothing happens. Debugging shows that the mouse position routine is working perfectly but the rectangles stay the same colour.

Reading String from a text file into Array in Pascal

可紊 提交于 2019-12-24 07:38:45
问题 With this program, I am trying to read a file and randomly print it to console. I am wondering If I have to use arrays for that. For example, I could assign my strings into an array, and randomly print from my array. But, I'm not sure how to approach to that. Also another problem is that, my current program does not read the first line from my file. I have a text file text.txt that contains 1. ABC 2. ABC ... 6. ABC And below is my code. type arr = record end; var x: text; s: string; SpacePos:

Does Pascal support passing parameters to functions?

北城以北 提交于 2019-12-24 05:08:05
问题 I'm new to Pascal and I am trying to write a simple program, but an having trouble passing values between functions. This is a small piece of what I have: program numberConverter; const maxValue = 4999; minValue = 1; var num: integer; function convertNumeral(number: integer):string; var j: integer; begin if ((number < minValue) OR (number > maxValue)) then begin writeln(number); writeln('The number you enter must be between 1 and 4999. Please try again:'); read(j); convertNumeral :=

Linking FPC .o files into Delphi

▼魔方 西西 提交于 2019-12-22 07:57:10
问题 How can I link a FPC .o from a library to a Delphi executable. When I try to link the following code I get a bunch of unsatisfied forward or external declarations. library project1; {$mode objfpc}{$H+} uses Classes { you can add units after this }; function Test: Integer; begin Result := -1; end; begin end. [dcc64 Error] Project2.dpr(170): E2065 Unsatisfied forward or external declaration: 'INIT$_$SYSTEM' [dcc64 Error] Project2.dpr(170): E2065 Unsatisfied forward or external declaration:

What are the differences between implementation of Interfaces in Delphi and Lazarus (FPC)?

血红的双手。 提交于 2019-12-21 12:05:09
问题 We have a project full of custom components that today is working in Lazarus and Delphi. I'm thinking in code interfaces on it, but I am not much familiar with them. What I would like to know is: What are the implementation nuances from Delphi and Lazarus interfaces? There is something that I should be specially aware? Will I have to code really different things? Background explanation: I think the components could benefit from interfaces, or at least, I will learn more from them. For example

How to get Windows user privileges information with Lazarus/Free Pascal

不羁岁月 提交于 2019-12-21 06:00:57
问题 Using Lazarus/Free Pascal, how can I get the user privileges of the user running my program (whether he's an Administrator, Regular user, or Guest)? 回答1: As David says in a comment you can use the CheckTokenMembership function to determine the membership of an user account. check this sample which runs on FPC and Delphi. program Test; {$IFDEF FPC} {$mode objfpc}{$H+} {$ELSE} {$APPTYPE CONSOLE} {$ENDIF} uses SysUtils, Windows, Classes; Const SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority =

How do install OmniPascal into vscode

我是研究僧i 提交于 2019-12-21 05:36:39
问题 From the OmniPascal page on Visual Studio Marketplace: How to install Install Visual Studio Code and open it. Open View -> Command Palette... and type ext install OmniPascal Restart Visual Studio Code and open File -> Preferences -> User Settings Add the key "objectpascal.delphiInstallationPath" to the right editor and set its value to the Delphi installation path. Don't forget to escape the backslashes! Example: "objectpascal.delphiInstallationPath" = "C:\\Program Files (x86)\\Embarcadero\

Timer Queue in Windows Service

♀尐吖头ヾ 提交于 2019-12-19 09:44:01
问题 For a Windows Service, I need a timer to perform a certain task regularly. Of course, there are many options that seem superior to a timer (multithreading, calling method directly from the service's main thread), but they all have their disadvantages in this particular situation. However, for obvious reasons, SetTimer() does not work without the message queue of a GUI. What I have done (in Free Pascal) is the following: Create the timer: MyTimerID := SetTimer(0, 0, 3333, @MyTimerProc); In the

Is there a SAX Parser for Delphi and Free Pascal? [closed]

十年热恋 提交于 2019-12-18 08:54:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Besides MSXML and SAX for Pascal, can you recommend a SAX parser for Delphi? It would be great if it could be used in cross-platform applications with Free Pascal. 回答1: The open-source libxml2 engine supports SAX, and has a Pascal binding available. 回答2: OXML also provides support for SAX and outperforms most

What is wrong with my if-statement?

不羁岁月 提交于 2019-12-17 14:49:29
问题 I am now trying to explore pascal. And I ran into some compiler errors. I wrote a if else if statement like this: if ((input = 'y') or (input = 'Y')) then begin writeln ('blah blah'); end; else if ((input = 'n') or (input = 'N')) then begin writeln ('blah'); end; else begin writeln ('Input invalid!'); end; And it gives me an error at the first else : ";" expected but "ELSE" found I looked for a lot of tutorials about if statements and they just do it like me: if(boolean_expression 1)then S1 (