lazarus

Why am I losing transparency when calling BitBlt or CopyRect?

心不动则不痛 提交于 2019-12-05 10:39:48
Problem I am trying to copy 32x32 tiles from a TBitmap into a TPaintbox which is my map editor, but I cannot seem to get the transparency working correctly. See the image below: Note: For the purpose of the demo and testing, I have placed a TImage underneath the TPaintbox which would help see if the transparency is working or not. As you can see, regular tiles draw correctly, but the tiles that should be transparent are drawn with a white background. I am now using proper classes to manage my maps and tiles, and below is two ways I have tried drawing: CopyRect: procedure TMap.DrawTile(Tileset:

Best way for read and write a text file

廉价感情. 提交于 2019-12-05 08:24:45
I am using the latest version of Lazarus IDE and I have a Memo1 on my TForm1. I have to load a text file in Memo1 and then edit every line of the Memo (I use Memo1.Lines.Strings[i] := ... ). At the end I must save the edited memo at a particular path. Question : I am looking for the faster way between: Load the whole text inside the memo, edit its content and save into a new file (load all -> edit all -> write all) Do a while loop (until the end of my *.txt file) that reads the file line by line, edit the content and save it in the new file. (load line -> edit -> write | load -> edit -> write

How to Format a DBGrid Column to Display Two Decimal Places? [duplicate]

感情迁移 提交于 2019-12-05 04:16:20
This question already has answers here : Setting a DBGrid column format in Delphi (3 answers) Closed 4 years ago . I would like to format specific cells to force two decimal places. The data is coming from an ElevateDB stored procedure and hooked into a TDataSource. EDIT: SQL Programming Note: I wasn't sure if this was just an ElevateDB issue or not. Before knowing about the Fields Editor , I attempted to format the data at the SQL level by using a CAST (NumericField as varchar(10)) statement inside the stored procedure. By doing so, it did not expose the DisplayFormat property inside the

Sorting 20GB of data

强颜欢笑 提交于 2019-12-04 20:30:50
问题 In the past I had to work with big files, somewhere about in the 0.1-3GB range. Not all the 'columns' were needed so it was ok to fit the remaining data in RAM. Now I have to work with files in 1-20GB range, and they will probably grow as the time will pass. That is totally different because you cannot fit the data in RAM anymore. My file contains several millions of 'entries' (I have found one with 30 mil entries). On entry consists in about 10 'columns': one string (50-1000 unicode chars)

Lazarus & Free Pascal - How to recursively copy a source directory of files to another directory?

≡放荡痞女 提交于 2019-12-04 19:12:42
I need to add some functionality to my Lazarus & Free Pascal GUI program - I need it to also copy files from a users chosen dir to another dir. I have a "Choose Source" TSelectDirectoryDialog button onclick event for the source directory and a "Choose Destination" TSelectDirectoryDialog button onclick event for the destination dir. I have a 3rd button to do the copying from Source to Destination. So far, I have found CopyFile that copies the files and the original date attributes, but it doesn't recreate the subdirectory structure of any subdirectories of the users chosen source directory. I

Problem compiling a WebLaz project under Lazarus

旧巷老猫 提交于 2019-12-04 18:26:29
My specs: OS: Ubuntu 10.04 LTS amd64 fpc: 2.4.0 lazarus: 0.9.28 I'm trying to compile a WebLaz project just by creating one and then compiling. Somehow the compiler gets all lost when determinig witch httpd and fpapache Units to use. I've found similar problems in the forums: mod_helloworld.lpr Can't find fpapache Unit ... I NEED HELP with fpweb ... After trying some of the solutions provided there I'm still at this point: Project compiles fine if I only have httpd22 under the Compiled units and the Source for the packages. Alas it then completely fails to link. With the original fpc/lazarus

How to Invalidate only part of a paintbox/bitmap to optimise its performance?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 14:45:48
The question relates to: Drawing on a paintbox - How to keep up with mouse movements without delay? I was going to at some point ask the question of how to repaint only part of a paintbox without invalidating the whole paintbox, which is slow when there is a lot of drawing going on or in my case when there are a lot of tiles drawn on screen. From the link above Peter Kostov did touch on the subject briefly in one of his comments: you can partly BitBlt the offscreen bitmap (only regions where it is changed). This will improve the performance dramatically. I have limited graphic skills and have

Saving and Loading Treeview using XML

余生颓废 提交于 2019-12-04 10:50:48
Note Sorry in advance for the long post, I though it would be best to put as much information on as possible rather than fill the gaps when needed. Note although I have tagged this as Delphi as well and do own and still use Delphi XE I am now using Lazarus as my primary IDE, I simply cannot afford to purchase the newer Delphi versions and now Lazarus is becoming more stable it makes sense to me to make the switch to Lazarus. For this question I have included a zip attachment with project source, although written in Lazarus it will really help with the question I have, hence the comments in the

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

瘦欲@ 提交于 2019-12-04 05:12:51
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, one of the components make communication to many different hardwares using serial port. But user

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

做~自己de王妃 提交于 2019-12-03 20:42:07
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)? 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 = (Value: (0, 0, 0, 0, 0, 5)); SECURITY_BUILTIN_DOMAIN_RID = $00000020; DOMAIN_ALIAS_RID_ADMINS = $00000220;