Re: [Lazarus] Detect that component selected in OI.
On 21/05/16 18:48, Vojtěch Čihák wrote: is there some event (message or method) triggered when component is selected in OI? It's just like PageControl and its TabSheets. When you select TabSheet in OI, component is repainted in form designer. I oberved the code but I didn't find solution. TObjectInspectorDlg has several public properties that may help: Selection: TPersistentSelectionList OnSelectionChange: TNotifyEvent OnSelectPersistentsInOI: TNotifyEvent also a boolean property EnableHookGetSelection which gives you access to protected get/set selection handlers. There are possibly other relevant methods too, it is a complex class. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 20/01/16 17:30, Péter Gábor wrote: Width of the designed menu must be calculated using the length of captions including the lenght of actual translation of "Add menuitem"... Otherwise if the menu captions are too short the command's caption will not fit. See the attached screenshot. Yes, in the original code the minimum length was based on the (English) resourcestring length. I don't know anything about the translation process, or at what stage in the IDE initialization captions are replaced with translated resourcestrings. Is there a standard notification, or other means to respond to a different-length translated string and force a repaint? Ondrej introduced an overridden TextChanged method, but this seems not to be called at the moment it is needed for the translated strings, because for this it clearly has no effect. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 21/01/16 13:29, Mattias Gaertner wrote: On Thu, 21 Jan 2016 13:21:57 + Howard Page-Clark <h...@talktalk.net> wrote: [...] I don't know anything about the translation process, or at what stage in the IDE initialization captions are replaced with translated resourcestrings. Is there a standard notification, or other means to respond to a different-length translated string and force a repaint? It is not only translated strings, but other themes as well. In general all labels should use AutoSize:=true. See here: http://wiki.lazarus.freepascal.org/LCL_AutoSizing Mattias OK. I've submitted a small patch (29468) which I hope will resolve this particular issue. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 17/01/16 23:22, Maxim Ganetsky wrote: 16.01.2016 1:19, Howard пишет: I have submitted a patch (29411) which I hope addresses these issues, except for the issue: 'String "composing" is still present ... in main menu creation form in "add menu item" fields captions' I am not clear about which string(s) you are identifying here. Can you give a specific line number in the source that exemplifies the problem you see? Please see attached screenshots. I think a recent revision by Ondrej resolved this. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 17/01/2016 12:33, Péter Gábor wrote: I found some Format calls that seems to be unneded: the first parameter for them contains only formatting symbols and the second an array of resourcestrings. If no one else is currently working on the resourcestrings issue I will try to finish my patch and post it on mantis... This is more simpler than writing a lot of letter about what and how to fix to be translation friendly. Do you agree? 2016-01-15 23:19 keltezéssel, Howard írta: On 14/01/2016 23:27, Maxim Ganetsky wrote: String "composing" is still present e. g. in "Insert from template" dialog ("Choose template to ..." groupbox caption) and in main menu creation form in "add menu item" fields captions. Also lismenueditororclickheadertosortbythatcolumn string looks suspicious from this POV. As for lismenueditormoveseparatedeleteinsertitems: you shouldn't try to align text with buttons this way. It won't work with other than Windows' fonts/font sizes (e.g. on Linux) and other languages. Better change this string to regular caption like "Menu Item actions". Also I noticed that e. g. "Insert from template" dialog is not resizable. It is better to have resizable dialogs in order to fit longer translation captions (e. g. combobox caption in this case). I have submitted a patch (29411) which I hope addresses these issues, except for the issue: 'String "composing" is still present ... in main menu creation form in "add menu item" fields captions' I am not clear about which string(s) you are identifying here. Can you give a specific line number in the source that exemplifies the problem you see? Howard Sure, fine by me. Go ahead. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 17/01/2016 13:00, Juha Manninen wrote: ... Howard, for curiosity, your patch has: LCLVersion = '1.6.0.2' The menu editor is developed in trunk 1.7. Are you using a fixex_1_6 version for editing? Juha Yes, the code I worked on was the latest trunk (well perhaps it was from the day before). The IDE I used was 1.6.0. Does this matter? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 17/01/2016 18:40, Péter Gábor wrote: I think we can use one resourcestring ('') instead of three: ''; ''; ''; Yes or No? Yes, I agree with you. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 16/01/2016 21:08, Ondrej Pokorny wrote: On 15.01.2016 23:30, Howard wrote: Sorry, my apologies - I missed that you didn't try it. Yes working fine for me (Windows 7 32bit and Linux 64 bit). I'm relieved that such a simple change has had such a good effect, and that no further tinkering with TShadowMenu size and positioning code was required; and that my poorly implemented scrolling code can therefore be dumped entirely. Yes, you must have wasted a lot of time on the extra scrolling code :( + Could you take a look also at this one?: http://mantis.freepascal.org/view.php?id=29399 Basically you should use a simple parented TEdit and not a modal dialog. Take a look at grids in-place editor. I'll have a look later next week. To me it seems that you have taken hard and complicated routes at a lot of places in the new menu editor, which are very bug-prone, hard to maintain and hard to understand - instead of using easy and simple ways. As a result, you wasted your time and also mine and others that tried to understand what's going wrong in the unnecessary code and tried to fix it. This is also the case of resource strings. Take a look e.g. at r51249 and r51305. Why was the dialog so complicated with duplicate strings? Yes and No as answers are clear enough. It stated: "Deleting this item will delete all subitems too. Delete this item and its subitems?" You use the word delete three times, (sub)items 2+2 times. Why? (And I don't count the dialog title and former buttons.) Why not only the second line?: "Delete this item and its subitems?" -> again it is clear enough. Furthermore, using the same words and phrases over and over again is stylistically wrong. In this particular instance of deleting a submenu (not just a single item) my motivation was not to make it overly complicated (though I appreciate it may seem so). It is quite possible a user may have spent 10 minutes designing a submenu with half a dozen items, and then hits the delete key accidentally. With a simple Yes/No dialog (especially if the the default button is Yes) it is all to easy to hit the wrong button and lose the last few minutes' work; and there is no undo facility implemented. I may have written that dialog clumsily, but I wanted to avoid the possibility of an 'automatic' response which was disastrous. I quite agree a straightforward Yes/No dialog is simpler and more elegant, but it may not give a hurried user sufficient 'pause' to avoid accidentally losing valuable work. Honestly, the new menu editor is a translator's nightmare. Although I do like what the new designer does, I don't really like how it is written :( I tried to fix some code but I am somehow already tired to go through all the issues. Please don't get me wrong - I don't want to offend you in any way. I just want to explain that you should use the KISS-principle whereever possible. It will not only save everybody's time but also lead to better code. (I know, I also have hard time to apply KISS.) Ondrej PS: Just for comparison: BEFORE: AFTER: Even as a user, I need much more time to understand what's going on in the first dialog... No offence taken. I appreciate you taking the time to give constructive feedback, as well as tracing through code you find poorly written in order to improve it. You'll realise I'm on a learning curve. This is my first significant code contribution to an open source project. I actually never thought I had the skill to offer a new menueditor. It was a forum comment by the late BigChimp some years ago about the previous menueditor which first got me thinking about its shortcomings, why it was so difficult to improve/maintain, and how a replacement might be designed to be better in that respect; and several developers said a complete rewrite was the only way forward. Months became years and no one as far as I could see was working on a replacement. So I decided to bite the bullet, and started to look at relevant bits of the IDE code (much of which I still don't understand). I've been learning on the job, as you plainly see... Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 14/01/2016 23:27, Maxim Ganetsky wrote: String "composing" is still present e. g. in "Insert from template" dialog ("Choose template to ..." groupbox caption) and in main menu creation form in "add menu item" fields captions. Also lismenueditororclickheadertosortbythatcolumn string looks suspicious from this POV. As for lismenueditormoveseparatedeleteinsertitems: you shouldn't try to align text with buttons this way. It won't work with other than Windows' fonts/font sizes (e.g. on Linux) and other languages. Better change this string to regular caption like "Menu Item actions". Also I noticed that e. g. "Insert from template" dialog is not resizable. It is better to have resizable dialogs in order to fit longer translation captions (e. g. combobox caption in this case). I have submitted a patch (29411) which I hope addresses these issues, except for the issue: 'String "composing" is still present ... in main menu creation form in "add menu item" fields captions' I am not clear about which string(s) you are identifying here. Can you give a specific line number in the source that exemplifies the problem you see? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 15/01/2016 11:04, Ondrej Pokorny wrote: On 15.01.2016 11:32, Ondrej Pokorny wrote: I did not try making TShadowMenu a TScrollingWinControl descendant. Perhaps that would be a better option. What would others advise? What were your problems? In r51298 I removed all the Scroller code and simply used TScrollBox for TShadowMenu and it works without any problems - much better than your Scroller experiment. I tested win32 and Linux+Gtk2. Sorry, my apologies - I missed that you didn't try it. Yes working fine for me (Windows 7 32bit and Linux 64 bit). I'm relieved that such a simple change has had such a good effect, and that no further tinkering with TShadowMenu size and positioning code was required; and that my poorly implemented scrolling code can therefore be dumped entirely. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 11/01/2016 21:51, Anthony Walter wrote: Howard, good job on the new menu designer. It's working very nicely right now. I'll take a look at modifying TShadowMenu to be a scrolling control without the need for a TScrollBox. Thanks. Yes, Ondrej's introduction of TSiblingFake and TFirstFake are a neat improvement. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 12/01/2016 13:44, Péter Gábor wrote: Please use complete sentences as much as possible and avoid storing > of partial sentences in resourcestrings. I mean don't compose > complete sentences in run/compile time from words or partial > sentences. Such resourcestrings makes localization harder or > completely impossible in languages that have different grammar: word > order, system of prefixes/suffixes, agglutination, inflection, and > other things that I can't imagine. > An example of how NOT to fragment sentences: msgid " conflicts%s" msgid " remain>" msgid " to resolve>" Also fragments can > have different meaning and translations depending on that they are > used combined or not. OK, point taken. I will amend the offending resourcestrings in a patch. I'm not a linguist nor a translator, so did not appreciate that this would cause difficulty. My motive was simply to reduce the overall number of resourcestrings required by reuse of phrase "atoms", which I see now works satisfactorily only if a single language is ever employed. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 12/01/2016 14:37, Péter Gábor wrote: 2016-01-12 15:26 keltezéssel, Howard írta: OK, point taken. I will amend the offending resourcestrings in a patch. I'm not a linguist nor a translator, so did not appreciate that this would cause difficulty. My motive was simply to reduce the overall number of resourcestrings required I know :) and thanks for your work! I have attached a third small patch to issue 29205, to address the infelicity in some menu editor resourcestrings identified by Péter. Could Ondrej or Juha review this? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 11/01/2016 16:07, Anthony Walter wrote: Very nice. I like the new design. Side note: Who wrote that FScroller for the new menu editor? It acts very erratic for me on Gtk2. I don't know about on other widget sets. See issue 29369. Why not use TScrollBox or make TShadowMenu a TScrollingWinControl? I wrote it. It is definitely the weakest part of the new designer. I hate to reinvent the wheel. However, I could not get a TScrollBox container to work correctly for TShadowMenu, perhaps because its size calculation and painting is rather non-standard. Whatever the reason I was unable to get a TScrollBox container to respond correctly to TShadowMenu size changes when there were more than a screenful of menuitems. I'm honestly not sure if the best approach to sorting it out is to mend (or rewrite) FScroller, or to figure out a way for TScrollBox to parent TShadowMenu correctly. I did not try making TShadowMenu a TScrollingWinControl descendant. Perhaps that would be a better option. What would others advise? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 11/01/2016 12:35, Ondrej Pokorny wrote: On 11.01.2016 13:31, Howard wrote: The latest trunk accepts a patch which adopts Bart's suggestion of identifying the purpose of the dummy menuitem by displaying a self-descriptive text. The background is no longer patterned. Of course this can be further changed. Where is the patch? It is the second patch submitted on issue 29205 Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer. which style do you prefer?
On 11/01/2016 09:34, Anthony Walter wrote: The point is, on a TPopupMenu if the pattern to the right is always alias arrows, and the pattern below is always check board, then it's entirely superfluous, nonessential, redundant, and unneeded. The latest trunk accepts a patch which adopts Bart's suggestion of identifying the purpose of the dummy menuitem by displaying a self-descriptive text. The background is no longer patterned. Of course this can be further changed. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 04/01/2016 14:24, Bart wrote: On 12/22/15, Juha Manninen <juha.mannine...@gmail.com> wrote: Hello I committed a new Menu Designer by Howard Page-Clark in r50992. See: http://bugs.freepascal.org/view.php?id=29205 Can we implement it so that adding a sumnenu to a Separator (a menuItem with '-' as caption) will either be disallowed, or a warning will be shown because several widgetsets crash on that. (Same for setting Caption to '-' of an existing item with a submenu.) In the new menu editor adding a submenu to a separator is already disallowed (popup menu option/toolbutton is disabled if a separator is highlighted). Do you not find this? However, the rename Caption function presently ignores this loophole. I will close this loophole in the patch I am working on (and hope to submit later this week). Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Design issues with the new menu editor
On 04-Jan-16 0:49, Anthony Walter wrote: Ondrej has been rapidly fixing issues in mantis and noted that there are problems with the new menu designer and the docked form designer. http://mantis.freepascal.org/view.php?id=29328 While testing I noticed a few design issues with the new menu editor which apparently isn't working nicely with the docked form designer. Could whomever wrote or is working on the new menu editor take a look at it while the docked form designer is installed and perhaps help resolve some of these issues? I will do my best on this. Actually, blush, I never tested the new menu editor with the docked form designer (I'm old school and never use it myself; I'm just aware that it has taken many months of hard work by several skilled minds to get the docking reasonably stable). Continual interaction with the OI by a non-modal window in relation to an arbitrary selection of components is rather tricky to manage... Perhaps this is the origin of the instability Kostas mentioned earlier. Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 26/12/2015 23:27, Juha Manninen wrote: Howard, as the author you also have voting power over the GUI. Besides GUI design is difficult, there is never a "right" solution that everybody would agree upon. Yes, dictatorship is far more efficient than democracy. Yet I feel some things should be changed. All settings that duplicate OI properties should either be moved to a bottom section of a popup menu, or they should be removed completely. Then the remaing GroupIndex feature from "Checkmark and radioitem properties" dialog could be moved to the main window of menu designer and the dialog then removed completely. OK, I will work on a suitable patch that addresses these and the other issues that e.g. Péter and Maxim raised. There are other usability issues, too. Namely...? From Kostas: Since the menu editor is redesigned, why not do it like in Windows Forms and NetBeans with the "inline editor" which is part of the form editor? Good idea but how to implement it? It may not be a trivial task. We can plan a future third iteration of menu designer to be an "inline editor". I'm not familiar either with Windows Forms or Netbeans. I'll do some research on this idea next year. Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 27/12/2015 13:25, Ondrej Pokorny wrote: On 27.12.2015 14:21, Juha Manninen wrote: On Sun, Dec 27, 2015 at 2:46 PM, Ondrej Pokorny<laza...@kluug.net> wrote: >Highlighting works fine on Windows. It doesn't work on Linux. I haven't >checked OSX. Strange. I have tested with GTK2 and QT on Linux and the Windows version using Wine. They all behave identically in this respect. Don't forget that Linux+Wine is not Windows+win32 :) The LCL implementation of themes (based on the work of Mike Lischke) for mainmenu highlighting in GTK2 and QT appears to work differently from the Windows implementation. I will work on providing a custom-drawn mainmenu highlight across the board, and not depend on themeservices to display this, whether the needed highlight is for a main menu or a popupmenu, as a workaround in this case of the menu editor. A better long term solution would be to make the highlight theming for TMainMenu and TPopupMenu fully consistent across all widgetsets. However, that is a task beyond me. Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] New menu designer
On 26/12/2015 19:06, Juha Manninen wrote: On Sat, Dec 26, 2015 at 1:09 PM, Péter Gábor <p...@freemail.hu> wrote: Some examples of resourcestrings that can/must be merged No, my idea was to replace the old menu designer with a new one. Something is wrong with the design of the old one. Everybody who has modified and improved it says the same. Some improvements just feel impossible without a complete rewrite. So, this was the rewrite we were asking for. I was hoping the author Howard Page-Clark would participate in the discussion and improve his designer based on feedback. Maintenance is always an important part of any code. I have not studied details of the code yet but I plan to do it soon. In any case, if I will be a sole maintainer of this code then I am disappointed. I was hoping for a shared effort. I was waiting for more feedback about the design/functionality, and for responses to settle into some sort of consensus about what needs to be changed/improved/removed. (I had nothing to add to the fsStayOnTop discussion). I am perfectly happy to amend the code in line with what is agreed here. The resourcestrings, for instance, need the attention Peter indicated, plus more. This was a clear oversight on my part. However, if functionality is to be removed, the pruning of the resourcestrings would be more drastic. Is it agreed to remove the RadioItem/CheckMark dialog? Is the left panel not needed at all? The redundancy of duplicated items in that panel was part of the design, a bit of hand-holding for beginners, but perhaps it out of place. The opening mini-wizard-style question when dropping a new menu on a form could be handled differently, or additionally have a section in the main IDE Options dialog, for instance that provided a default, and a choice of whether the wizard were ever shown. I certainly expect to share in the maintainance of anything I contribute. However, you will realize that I am a hobbyist, not a professional programmer, and so my skills are limited compared to most of those who read this list, and I am hampered by little experience of operating systems other than Windows variants. If there are reproducible crashes arising from the new editor, that certainly requires diagnosis and attention. I don't get them here, but if others do... yours Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] *** SPAM *** How to pass function method to TList.Sort?
On 09/12/2015 20:11, Donald Ziesig wrote: Is there any way to pass a method function as the Compare parameter to a TList or is there a work around for it? As in: type TMyClass = object fIndex : Integer; List : array of TList; function Compare( Item1, Item2 : Pointer) : Longint; // needs access to fIndex procedure Sort; end; implementation function TMyClass.Compare( Item1, Item2 : Pointer ) : Longint; begin case fIndex of 0: Result := some compare of Item1, Item2;// These compares are implemented in an object from another unit 1: Result := another compare of Item1, Item2 end; end; procedure TMyClass.Sort; begin fIndex := 0; List[fIndex].Sort( @Compare ); // Compilation error, doesn't like Compare being "of object" end; It's a dreadful hack, but you could try something like: type TClassListSortCompare = function (Item1, Item2: Pointer): Integer of object; procedure TMyClass.Sort; var objectFunction: TClassListSortCompare; regularFunction: TListSortCompare; begin fIndex := 0; objectFunction:=@Compare; regularFunction:=TListSortCompare(TMethod(objectFunction).Code); List[fIndex].Sort( regularFunction ); end; --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Which method is called at the very end of TWinControl creation?
On 08/11/2015 17:05, Krzysztof wrote: What I'm looking is virtual method like "ThisIsCalledWhenControlIsCompletelyAdjustedAndReadyWithAllChildrens" . Tried other methods like VisibleChanged, ChildHandlesCreated etc but without success Possible methods to try include: Loaded FormEndUpdated -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Editor loses focus on Compile
On 12/10/2015 15:37, Ondrej Pokorny wrote: When I compile a project in the IDE with Ctrl+F9 the editor window loses focus. Instead the message window is focused. When compiling is done, message window is still focused (even after a successful compile). In the IDE Options dialog under Environment->Messages Window node make sure the checkbox "Focus messages after compilation" is not checked. --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TEdit: Find character at caret position
On 02/08/2015 18:33, Jürgen Hestermann wrote: In a TEdit component, how do I find out which character is at the caret/cursor position? Or in other words: At which (string) position will the next typed character be inserted? I want to insert text at just that position myself but cannot find out where this (character) position would be. Edit1.SelStart gives the character position of the caret/cursor. The next typed character is inserted at Succ(Edit1.SelStart). Howard --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Owner of a TCanvas
On 27/07/2015 10:31, Xiangrong Fang wrote: Hi There, Can I somehow get the object which owns a Canvas? e.g.: function GetCanvasOwner(ACanvas: TCanvas): TObject; begin Result := ACanvas.Owner; end; pb := TPaintBox(GetCanvasOwner(pb.Canvas); A TCanvas does not have a built-in Owner property. It descends from TPersistent, but not from TComponent, the class that introduces Owner and ownership. --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Adding data field to a child node in a treeview
On 04/07/2015 09:46, Susie Nicol wrote: Hi - me again I have a Lazarus treeview, which I am populating from several sql queries. I add child nodes in this way, setting them to one of the fields returned from the query while Not SQLQuery1.EOF do Begin treeview1.items.addchild(treeview1.selected, SQLQuery1.fields[0].AsString); SQLQuery1.Next end; That works of course. I want to modify the newly added node by setting its data property to another field in the loop - something like treeview1.SOMETHING.data := Pointer(SQLQuery1.fields[1].AsInteger); but the problem is that I can't work out how to identify the newly-added child node. Is it possible? var node: TTreeNode; begin node:=TreeView1.Items.AddChild(TreeView1.Selected,SQLQuery1.Fileds[0].AsString); node.Data:=pointer(SQLQuery1.Fields[0].AsInteger); SQLQuery1.Next; end; --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Fugue icons for LHelp?
On 13/05/2015 23:38, Juha Manninen wrote: Please give opinions about new proposed icons for LHelp. See issue : http://bugs.freepascal.org/view.php?id=28072 There is a screenshot. I'm perhaps just rather dense - but I don't find any of these icons enhances my use of LHelp, because I don't know what any of the icons means, and to me they are not self-explanatory. Why do any of them have a ? Does this mean that the content they mark is incomplete (possible, but unlikely)? Or is it just a generic marker for help content (totally pointless, if that is the case)... or does it signify something else entirely? The small triangular chevron icons already indicate when a chapter is opened/closed. So a second icon to indicate this is redundant, if that is the case. When travelling, the better maps I use include a legend somewhere to explain what each map symbol indicates (in case it is not clear, or not self-evident). To me, information of that sort is far more important than which colour(s) are best, a question on which there can be little objectivity, only a multitude of differing personal preferences. For someone (like me) with poor eyesight, icons that are subtly different (e.g. a faint blue question mark as opposed to a very faint blue question mark) are almost indistinguishable, and rather annoying, since if I have to rely on identifying the right one to pick (say) the right line, it gives me a headache. I wish I could be more positive, and I do genuinely welcome people's efforts to improve aspects of the user interface. So I'm just trying to offer honest feedback. Apologies if you wanted this posted on Mantis. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How do I change properties for GUI-components from another unit?
On 11/05/2015 22:41, Anders Eriksson wrote: How do I change properties for GUI-components from another unit? e.g. hide a button or change a label text from a different unit. Two example units that inter-communicate might be as follows: unit Unit1; {$mode objfpc}{$H+} interface uses Forms, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Label1: TLabel; procedure FormShow(Sender: TObject); end; var Form1: TForm1; implementation uses unit2; {$R *.lfm} { TForm1 } procedure TForm1.FormShow(Sender: TObject); begin Form2.Show; end; end. unit Unit2; {$mode objfpc}{$H+} interface uses Forms, StdCtrls; type TForm2 = class(TForm) BChange: TButton; procedure BChangeClick(Sender: TObject); end; var Form2: TForm2; implementation uses Unit1; {$R *.lfm} procedure TForm2.BChangeClick(Sender: TObject); begin Form1.Button1.Hide; Form1.Label1.Caption:='Changed'; end; end. == The uses clauses are the critical feature. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] howto change the order the components of a Form are created?
On 09/04/2015 18:30, John Landmesser wrote: from Delphi i know there is a editor to change the order in which objects of the Application are created: I have a IniPropStorage and that has to be created before a FileListView. Searched the IDE, i know its there, but i can't find it! Project Options lets you order the creation of auto-created forms, but it does not handle other objects. Can you not dynamically create these two objects in order like this? procedure TForm1.FormCreate(Sender: TObject); begin FIniPropStorage:=TIniPropStorage.Create(Self); // with FIniPropStorage do ... etc. FFilelistbox:=TFileListBox.Create(Self); // with FFilelistbox do ... end; Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TComboBox.DropDownCount has no effect.
On 04/04/2015 19:04, Donald Ziesig wrote: Hi All! I have several apps that use combo boxes for (e.g.) Minutes. For Minutes, the items range from 0 to 59. The Object Inspector shows that the DropDownCount is 8, but no matter what I put in there, I get the entirety of the items. This seems to be a Linux bug, since DropDownCount restricts the entries listed correctly on Windows (win32). Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Is this RC2 issue or my unknowledge?
On 27/03/2015 20:40, JuuS wrote: Happy Friday, Before I put on RC1, then RC2, I would find that adding a procedure gave something like this in body: procedure TfrmJuuRSync.EditButton1Change(Sender: TObject); begin end; I would then realize I don't want this procedure. If I left it blank, no code lines added, and recompiled the program the IDE took out the empty proc as well as the declaration in the class. I really liked this. This is controlled from the Tools- Options menu In the IDE Options dialog select the Editor-Completion and Hints page Make sure to check Auto remove empty methods Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Oscilliscope Control
On 21/03/2015 20:56, Michael Thompson wrote: The (dead) link is http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/%7CISA This link is dead from my location also. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TShortcut properties
On 07/03/2015 10:15, Mattias Gaertner wrote: On Tue, 03 Mar 2015 16:31:59 + Howard Page-Clark h...@talktalk.net wrote: Descendants of TCustomCheckbox and TCustomButton have public Shortcut and ShortcutKey2 properties which cannot be set since they are read-only. What is the purpose of these properties? The first is extracted from the Caption. The second was apparently only started by someone, but not finished. Is it now realistic to expect whatever 'someone' planned as new functionality to be finished? If not, should the code associated with these properties be removed to lighten the LCL by a few bytes? Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TShortcut properties
Descendants of TCustomCheckbox and TCustomButton have public Shortcut and ShortcutKey2 properties which cannot be set since they are read-only. What is the purpose of these properties? Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus Release Candidate 1 of 1.4
On 16/02/2015 22:38, Mattias Gaertner wrote: The Lazarus team would like to announce the first release candidate for the upcoming Version 1.4. ... Huge thanks to the team who have laboured to produce this latest marvel. It installed flawlessly (on my Windows 7 machine) in about 40 seconds, and was ready to roll! I've never seen such a snappy install for a full-featured development environment before. Recompiled the last three projects I worked on (chewing its way through scores of files) without any problems. No bugs to report yet. Thanks again. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Filling ListBox without triggering OnSelectionChange
On 07/01/2015 06:49, Marc Santhoff wrote: Hi, it has been a very long time since I've programmed GUIs. I have forgotten how to fill a ListBox without having the event handler OnSelectionChange executed. How can it be done? ListBox1.Items.Assign(someStringlist); does not trigger the OnSelectionChange event. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTIGrid crashed after calling ListObject.Add
On 09/12/2014 10:41, John Landmesser wrote: no crash on a 32bit Windows XP with For me it sometimes crashes, and sometimes does not (Win7 32-bit). The problem is not with adding an item to TCollection (which is fine as far as I can see), but probably some hard to find bug in the LCL which TTIGrid exposes unpredictably. Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] No halp entry for FindDialog ...
On 08/11/2014 00:35, Bob B. wrote: and my Delphi 3 code for OnFind does not work in Lazarus, at least not in Laz 1.2.4 for Win32. Could some kind person please offer an example that works? Drop a TFindDialog, TMemo, TPopupMenu on the main form of a new default Lazarus project, and code unit1.pas thus: unit Unit1; {$mode objfpc}{$H+} interface uses Forms, Controls, Dialogs, StdCtrls, Menus; type TForm1 = class(TForm) FindDialog1: TFindDialog; MTextToSearch: TMemo; PopupMenu1: TPopupMenu; procedure FormCreate(Sender: TObject); private procedure DoSearch(Sender: TObject); procedure DoSearchFromPopup(Sender: TObject); function Located(const aText: string): boolean; end; var Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject); var mi: TMenuItem; begin mi:=TMenuItem.Create(PopupMenu1); mi.Caption:='Search unit1.pas'; mi.OnClick:=@DoSearchFromPopup; PopupMenu1.Items.Add(mi); MTextToSearch.PopupMenu:=PopupMenu1; FindDialog1.Title:='Find text in unit1.pas'; FindDialog1.OnFind:=@DoSearch; MTextToSearch.Align:=alClient; MTextToSearch.ScrollBars:=ssAutoBoth; MTextToSearch.Lines.LoadFromFile('unit1.pas'); FindDialog1.Execute; end; procedure TForm1.DoSearch(Sender: TObject); begin FindDialog1.CloseDialog; if not Located(FindDialog1.FindText) then ShowMessageFmt('Text %s not found in unit1.pas',[FindDialog1.FindText]); end; procedure TForm1.DoSearchFromPopup(Sender: TObject); begin FindDialog1.Execute; end; function TForm1.Located(const aText: string): boolean; var p: integer; begin p:=Pos(aText, MTextToSearch.Text); Result:=p0; if Result then begin MTextToSearch.SelStart:=p-1; MTextToSearch.SelLength:=Length(aText); end; end; end. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Having more than 32 elements in a set (TGridOptions of TCustomGrid)
On 05/11/2014 18:58, Rik van Kekem wrote: So it should be something like this (with my limited English): *Error: Property can't have a default value* Set properties or indexed properties cannot have a default value if the upper and lower bounds of the set's base type have ordinal values between 0 and 31. I think you meant: ... cannot have a default value if the upper or lower bounds of the set's (or array's) base type have ordinal values *outside* the range 0..31. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Redundant text on project buttons
On 16/10/2014 12:54, Kostas Michalopoulos wrote: On Wed, Oct 15, 2014 at 6:34 PM, Jürgen Hestermann juergen.hesterm...@gmx.de mailto:juergen.hesterm...@gmx.de wrote: But IMO the majority of icons is meaningless. Some even look very similar although they mean complete different things. Therefore I don't like them. I was talking about the general idea for icons. Lazarus' icons aren't the best though. The most immediate problem - IMO - is the use of color: which is none... What a very constructive contribution to this discussion. Thanks. What Lazarus has lacked (for the most part, so far) is a contributor who has your eye for good GUI analysis, design and consistency, combined with the graphic skills needed to implement elegant icons appropriately. My prayer is that this conversation which included a tirade against icons (and poor icons are indeed rather useless space-wasters) might result in someone(s) with the necessary skills and motivation offering improvements along the lines you suggest. Good application visual design is part of what a RAD IDE is meant to enhance, and it would be great if the IDE itself were an exemplary model of such excellence in GUI design which could stand the test of time in the way that most things Mac have justifiably become classics (without needing to slavishly follow every passing design fad). Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Fuzzy translations ignored
On 18/09/2014 17:41, Giuliano Colla wrote: Canvas.RadalPie on GTK2 and Windows works only clockwise, but provides a very poor image (more like a portion of an octagon that a portion of a circle). Counterclockwise it generates the image of my previous e-mail. On Windows here, Pie (RadialPie) works counterclockwise well, using the following code example. I'm sure if you added anitaliasing to improve the rendering quality this would be welcomed. Howard == code == unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics; type { TForm1 } TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormPaint(Sender: TObject); private end; TPieRec = record percentage: integer; // give pie segments as percentag of whole pie color: TColor; end; TPieArray = array of TPieRec; procedure DrawPie(aCanvas: TCanvas; aCircleRect: TRect; pa: TPieArray); var Form1: TForm1; implementation procedure DrawPie(aCanvas: TCanvas; aCircleRect: TRect; pa: TPieArray); var angles: array of integer; lastAngle: integer = 0; i: Integer; begin SetLength(angles, Length(pa)); for i:=0 to High(pa) do begin angles[i]:=trunc(pa[i].percentage * 57.60); aCanvas.Brush.Color:=pa[i].color; aCanvas.RadialPie(aCircleRect.Left, aCircleRect.Top, aCircleRect.Right, aCircleRect.Bottom, lastAngle, angles[i]); Inc(lastAngle, angles[i]); end; end; {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin end; procedure TForm1.FormPaint(Sender: TObject); var example: TPieArray; circleRect: TRect; begin circleRect:=Rect(10,10,110,110); SetLength(example, 4); example[0].percentage:=30; example[0].color:=clBlue; example[1].percentage:=10; example[1].color:=clRed; example[2].percentage:=20; example[2].color:=clYellow; example[3].percentage:=40; example[3].color:=clMoneyGreen; DrawPie(Canvas, circleRect, example); end; end. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Displaying a Listview entry in bold and a different colour
On 15/09/2014 13:10, Richard Mace wrote: Hi All, I just want to make sure that I am not doing anything wrong here, please can somebody give me a little code example of how to correctly set the font to bold and a differnet colour in a listview entry? I wouldn't claim the following is 'correct', but it works on Windows using TListView's OnCustomDrawItem() event. Howard ==code== unit mainListviewOwnerDraw; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Graphics, ComCtrls, LCLType, StdCtrls; type TForm1 = class(TForm) ListView1: TListView; procedure FormCreate(Sender: TObject); procedure ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); end; var Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject); var li: TListItem; lc: TListColumn; i: Integer; begin ListView1.ViewStyle:=vsReport; ListView1.OwnerDraw:=True; lc:=TListColumn.Create(ListView1.Columns); lc.Caption:='Select an item to show custom draw:'; lc.Width:=ListView1.Canvas.TextWidth(lc.Caption) + 20; for i:=0 to 4 do begin li:=TListItem.Create(ListView1.Items); li.Caption:=Format('Item number %d',[i]); ListView1.Items.AddItem(li); end; end; procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); var rct: TRect; begin DefaultDraw:=False; if (cdsSelected in State) then begin Sender.Canvas.Font.Style:=[fsBold]; Sender.Canvas.Font.Color:=clRed; end else begin Sender.Canvas.Font.Style:=[]; Sender.Canvas.Font.Color:=clBlack; end; rct:=Item.DisplayRect(drLabel); Sender.Canvas.FillRect(rct); //paint background with default brush colour Sender.Canvas.TextOut(rct.Left, rct.Top, Item.Caption); end; end. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] StrToDate and DefaultFormatSettings
On 12/09/2014 13:04, Henry Vermaak wrote: On Fri, Sep 12, 2014 at 08:18:36AM -0300, Leonardo M. Ramé wrote: Hi, I need to convert strings with format d-mmm-y to TDateTime. For example: '12-Sep-14' This will accomplish the task. function DatestrToDateTime(const aDate: string): TDateTime; const sep = '-'; var el, p, im, id, iy: integer; d, m, y: word; dt: string; function FindMatch(const aMon: string): integer; var i: integer; begin DebugLn(['aMon=',aMon]); Result:=-1; for i:=Low(TMonthNameArray) to High(TMonthNameArray) do if SameText(aMon, DefaultFormatSettings.ShortMonthNames[i]) then begin Result:=i; Break; end; end; begin dt:=Trim(aDate); el:=Length(dt); if (el 7) or (el 11) then Exit(0.0); p:=Pos(sep, aDate); if (p=0) or (not TryStrToInt(Copy(dt, 1, p-1), id)) then Exit(0.0); Delete(dt, 1, p); p:=Pos(sep, dt); if (p=0) then Exit(0.0); im:=FindMatch(Copy(dt, 1, p-1)); if (im 1) then Exit(0.0) else m:=im; Delete(dt, 1, p); if not TryStrToInt(dt, iy) then Exit(0.0); d:=id; if (iy 2000) then Inc(iy, 2000); y:=iy; if not TryEncodeDate(y, m, d, Result) then Result:=0.0; end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Code completion problems with Graph units
On 09/09/2014 21:17, Sven Barth wrote: Hello together! I'm currently working on a project that uses the good old Graph units (or PtcGraph to be more precise) and I have the problem that code completion is erratic if (Ptc)Graph is in the uses-clause, because the IDE can not find the graphh.inc include file which is at the top of all Graph units. This include file is located in $fpc/packages/graph/src/inc whereas the full Graph units are located in other directories of $fpc/packages/graph/src/. I've also tried adding the path of the include directory to the Other source files or the Include directories path. The IDE then either complains that it still can not find the file or it complains that it could not find the end of the file with the cursor still getting positioned at the $include directive. Any ideas I could try? (besides commenting out the include directive :P) I think you can use the Codetools Defines Editor (4th item in the Tools menu) to add the include path. However, I have never figured out exactly how to do that for FPC and Lazarus sources which the Codetools treats specially (even though there is a wiki page that ought to help: http://wiki.lazarus.freepascal.org/IDE_Window:_Codetools_Defines_Editor). Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Is this normal or bug ?
On 02/08/2014 10:41, FreeMan wrote: Tmy_Form = class(TForm) private { private declarations } v1:integer; v2:string; public { public declarations } function exmple(v1:integer;v2:string):boolean; end; when compile: xx.pas(8,21) Error: Duplicate identifier v1 xx.pas(8,32) Error: Duplicate identifier v2 first definition main class's variable, compiler error in function parameter Duplicate identifier is it normal or bug? It is a feature of {$mode objfpc}, not a bug. If you don't like the feature, use {$mode delphi} which allows such duplicate identifiers (and some other Delphi sloppiness). -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] how to set two memos for parallel text editing ?
On 28/05/2014 00:46, Etienne Leblois wrote: how to manage that scrolling or arrowing up in one memo will also scroll up the other one ? The following Windows example shows how to synchronise scrolling between two memos (Memo1, Memo2) using scrollbar movement. Responding to memo caret movement in addition would require more code based on the same message-interception ideas. //== code == unit mainScrollMemo; {$mode objfpc}{$H+} interface uses Classes, Forms, Controls, LMessages, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private FOrgMemoWndProc: TWndMethod; procedure MemoWndMethod(var theMessage: TLMessage); end; var Form1: TForm1; implementation uses windows; {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject); begin FOrgMemoWndProc:=Memo1.WindowProc; Memo1.WindowProc:=@MemoWndMethod; memo1.Lines.LoadFromFile('..\..\mainscrollmemo.pp'); memo2.Lines.LoadFromFile('..\..\mainscrollmemo.pp'); end; procedure TForm1.MemoWndMethod(var theMessage: TLMessage); begin FOrgMemoWndProc(theMessage); if theMessage.msg=LM_VSCROLL then SendMessage(Memo2.Handle, WM_VSCROLL, theMessage.wParam , theMessage.lParam); if theMessage.wParamlo=SB_THUMBTRACK then SetScrollPos(Memo2.Handle, SB_VERT, theMessage.wParamhi, True); end; end. //== code end == You should be able to adapt this to your needs. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GetFormImage bug
On 13/05/2014 16:49, Chris Crori wrote: I have a thumbnail section in my main program form. In the forms, I use GetFormImage to make an image and send it to the mainform. The bug is that some components are not visible in this image. TDBGrid is one and a custom component derived from TBitBtn is another. I use the latest stable Lazarus 1.2.2 with FPC 2.6.4 on windows7, both 32 and 64 bit This method //- procedure TForm1.Button1Click(Sender: TObject); var bmp: TBitmap; begin form2.Show; bmp:=form2.GetFormImage; try Image1.Canvas.StretchDraw(Image1.ClientRect, bmp); finally bmp.Free; end; end; //- shows a DBGrid (and everything else I dropped on form2) nicely on my Win7 32bit setup. Perhaps you need to share the code that drops parts of the bitmap (and perhaps the lfm of the imaged form as well). -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Forcing TMemo to dislplay last entry
On 25/04/2014 18:30, Richard Mace wrote: I have some code that populates a TMemo via TMemo.Text := 'lots of lines of text..' and need a cross platform way of programatically forcing the TMemo to display the last entry as if the user has had manually scrolled to the bottom. You can also use Memo1.SelStart:=Length(Memo1.Text); Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] OnBeforeSelection
On 19/04/2014 02:03, Eric Kom wrote: Hi Dear; Please I'm looking for the *OnBeforeSelection *Event on the TDBGrid? I can only see the OnSelectEditor. It is a protected property, so to use it you must declare a descendant and make it public (or published). Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to minimize application showing modal form(s)
On 12/04/2014 23:02, Frank Poretzky wrote: Apart from FindComponent, which makes an application with lots of modal windows very complex, I tried various versions of ... with a corresponding AppOnMinimize() procedure. None of them worked well, especially with the modal sub-sub-form scenario described above. As Zeljko pointed out, you have uncovered a bug. If it is not addressed in trunk, you should raise the issue in the Mantis bugtracker so it gets nailed. Then unsatisfactory workarounds would not be needed. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to minimize application showing modal form(s)
On 12/04/2014 17:06, Frank Poretzky wrote: Is there a way to modify my modal form to get it minimized as well? Create your modal form with the main form as its owner, and give it a unique Name at creation. In your main form's declaration set up two Application handlers, OnMinimize and OnRestore (of type TNotifyEvent), and hook them up in your main form's OnCreate code. In the OnMinimize and OnRestore handler implementations use FindComponent (or some other means) to locate your previously named modal form, and either Hide it or Show it as appropriate. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Scroll Wheel
On 11/04/2014 19:33, Timothy Groves wrote: No; I am unsure as to how to do that. Would I need to create a descendant class, or does Lazarus support overriding without doing so? The following should give you an idea how to develop the hint Mattias gave: ===code=== unit testIntWheelEdit; {$mode objfpc}{$H+} interface uses SysUtils, Forms, StdCtrls, LMessages, Spin, Classes; type { TIntWheelEdit } TIntWheelEdit=class(TCustomEdit) private function GetAsInteger: integer; protected procedure WMMouseWheel(var Message: TLMMouseEvent); message LM_MOUSEWHEEL; procedure KeyPress(var Key: char); override; public property AsInteger: integer read GetAsInteger; end; { TForm1 } TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private intEdit: TIntWheelEdit; spinEdit: TSpinEdit; procedure IntEditChange(Sender: TObject); end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin intEdit:=TIntWheelEdit.Create(Self); intEdit.Left:=10; intEdit.Top:=10; intEdit.OnChange:=@IntEditChange; intEdit.TabOrder:=0; intEdit.Parent:=Self; spinEdit:=TSpinEdit.Create(Self); spinEdit.Top:=10; spinEdit.Left:=100; spinEdit.MinValue:=-1000; spinEdit.MaxValue:=1000; spinEdit.ReadOnly:=True; spinEdit.Parent:=Self; end; procedure TForm1.IntEditChange(Sender: TObject); begin if Sender is TIntWheelEdit then spinEdit.Value:=TIntWheelEdit(Sender).AsInteger; end; { TIntWheelEdit } function TIntWheelEdit.GetAsInteger: integer; begin Result:=StrToIntDef(Text, 0); end; procedure TIntWheelEdit.WMMouseWheel(var Message: TLMMouseEvent); var i: integer; begin i:=StrToIntDef(Text, 0); if Message.WheelDelta =0 then Inc(i) else Dec(i); Text:=IntToStr(i); Message.Result:=1; end; procedure TIntWheelEdit.KeyPress(var Key: char); begin case Length(Text)=0 of False: if Key in [#8,'0'..'9'] then inherited KeyPress(Key) else Key:=#0; True: if Key in [#8,'-','0'..'9'] then inherited KeyPress(Key) else Key := #0; end; end; end. ===code end=== -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTimer woes (newbie)
On 01/04/2014 09:44, Michael Schnell wrote: In fact Bob is not doing this (eating up CPU Cycles), but he uses wait(), which only hampers it's own project. Actually Bob's wait uses his own TTimer-based code, and is not well designed. As Flavio wrote, he would be best to replace all his waits with a Sleep, and remove his timer altogether. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTimer woes (newbie)
On 31/03/2014 10:25, Michael Schnell wrote: On 03/31/2014 01:44 AM, Bob Axtell wrote: can someone show a newbie how to use the two system timers? What do you mean by system timers ? I think he means the TTimer and TIdleTimer found on the System page of the Component Palette. If you drop one of each on the main form of a new project with a label and a memo, and add this code, it should give you an idea of how to use them. -- code begin -- unit Unit1; {$mode objfpc}{$H+} interface uses SysUtils, Forms, ExtCtrls, StdCtrls; type { TForm1 } TForm1 = class(TForm) IdleTimer1: TIdleTimer; LAverageSoFar: TLabel; MNumbers: TMemo; Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure IdleTimer1Timer(Sender: TObject); procedure Timer1Timer(Sender: TObject); private FNumber: integer; FRunningTotal: integer; FCount: integer; end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin Randomize; MNumbers.Clear; Timer1.Interval:=500; Timer1.OnTimer:=@Timer1Timer; Timer1.Enabled:=True; IdleTimer1.Interval:=1000; IdleTimer1.OnTimer:=@IdleTimer1Timer; IdleTimer1.Enabled:=True; end; procedure TForm1.IdleTimer1Timer(Sender: TObject); begin LAverageSoFar.Caption:= Format('Average of random numbers so far is %n',[FRunningTotal/FCount]); end; procedure TForm1.Timer1Timer(Sender: TObject); begin FNumber:=Random(101); MNumbers.Lines.Add(IntToStr(FNumber)); Inc(FCount); Inc(FRunningTotal, FNumber); end; end. -- code end -- Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Codetools include search path(s)
I've been experimenting with the codetools example finddeclaration project, using the codetools outside the IDE, and feeding FPC and Lazarus source directory information via environment variables to the CodeToolBoss constructor, which works OK for simple source files. However, when looking for, say, the declaration of TLabel in StdCtrls the linkscanner barfs over an include file it cannot find. TCodeToolManager.HandleException: include file not found lcl_defines.inc at Line=21 Col=5 in c:\lazarus\lcl\std ctrls.pp How should I pass the location of lcl\include\ when initializing the codetools? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Setting TStringGrid row/col border styles
On 24/03/2014 18:19, Gary Randall wrote: If someone can tell me how to post a .png image to the forum I can show you the stringgrid format I need. Once logged in, go to the appropriate forum board (say Lazarus General) and click the [New Topic] button. As well as filling in the subject field and content edit box you'll see an [+ Attachments and other options] link below the edit box. That brings up a dialog which lets you locate a file somewhere on your disk to add to the new topic as an attachment. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Setting TStringGrid row/col border styles
On 22/03/2014 20:53, Gary Randall wrote: ... Specifically, I need to change the penstyle and weight of row/col borders. The public properties: GridLineColor GridLineStyle and published property GridLineWidth may be all you need, without custom drawing. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Checking characters in a string
On 12/03/2014 13:53, Richard Mace wrote: Hi, I am trying to check to make sure the a string contains at least 1 uppercase character, 1 lowercase character and 1 number. Any ideas as of the best way of coding this? If you restrict yourself to Latin ansi encoding and 'number' means a numeric digit which does not have to be a whole word, the code is fairly simple since almost no parsing is required. Other cases and encodings require more complex string parsing. For example: -- code begin -- function Valid(const s: string): boolean; function HasLowerUpperNumeric: boolean; var c: Char; lower: boolean=False; upper: boolean=False; numeric: boolean=False; begin Result:=False; for c in s do begin if c in ['a'..'z'] then lower:=True else if c in ['A'..'Z'] then upper:=True else if c in ['0'..'9'] then numeric:=True; if lower and upper and numeric then Exit(True); end; end; begin if Length(s) 3 then Exit(False); Result:=HasLowerUpperNumeric; end; -- code end --- -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting and setting the x numbered word in a sentence
On 07/01/2014 18:04, Richard Mace wrote: Hi, Is there an existing routine in Lazarus that will get and set effectively the x numbered word in a sentence without actually knowing what the actual word is? E.g with the string the cat sat on the mat If word delimiters are consistently all the same character (as in your example) you can press a stringlist into service: function ReplaceNthWord(const aPhrase: string; const aReplacement: string; aWordIndex: integer): string; var sl: TStringList; begin Result:=''; if Length(aPhrase)=0 then Exit; sl:=TStringList.Create; try sl.Delimiter:=' '; sl.DelimitedText:=aPhrase; if (aWordIndex 0) and (aWordIndex = sl.Count) then sl[Pred(aWordIndex)]:=aReplacement; Result:=sl.DelimitedText; finally sl.Free; end; end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] how about a HasProperty() property?
On 05/01/2014 23:50, Alejandro Gonzalo wrote: For example, if you want to loop though components and set the dbNavigator's DataSource property to that of the component if it has a DataSource property (and of course is not a dbNavigator itself). It seems you can't do that by using the component's hierarchy. Is there someway else to do that? Components do seem to have HasHelp and HasParent properties already. Something like this: uses typinfo; function ComponentHasProperty(aComponent: TComponent; aProperty: string): boolean; begin if not Assigned(aComponent) or (aProperty='') then Exit(False); Result:=GetPropInfo(aComponent, aProperty)nil; end; function ClassHasProperty(aClass: TClass; aProperty: string): boolean; begin if (aProperty='') then Exit(False); Result:=GetPropInfo(aClass, aProperty)nil; end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Adding shapes to TShape
On 26/12/2013 12:03, Frederic Da Vitoria wrote: Should I forget about deriving TShape and should I directly modify TShape's code? For a project that needed something similar I found that TShape with its fixed TShapeType enumeration was too inflexible (though it is Delphi-compatible, hence its presence). Trying to stuff too much shape-drawing code variety into one gloriously polymorphic control becomes increasingly complex and difficult to maintain. I ended up writing a simple (isosceles only) triangle control which you are welcome to adapt as suits you, attached here. unit triangles; {$mode objfpc}{$H+} interface uses Classes, Controls, types, Graphics, LCLProc; type {$M+} TBaseAlign=(baBottom, baTop, baLeft, baRight); {$M+} { TTriangle } TTriangle=class(TGraphicControl) private FPen: TPen; FBaseAlign: TBaseAlign; FBrush: TBrush; procedure SetBrush(Value: TBrush); procedure SetPen(Value: TPen); procedure SetBaseAlign(aValue: TBaseAlign); protected class function GetControlClassDefaultSize: TSize; override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; procedure Paint; override; procedure ParamsChanged(Sender: TObject); published property Align; property Anchors; property BaseAlign: TBaseAlign read FBaseAlign write SetBaseAlign default baBottom; property BorderSpacing; property Brush: TBrush read FBrush write SetBrush; property Constraints; property DragCursor; property DragKind; property DragMode; property Enabled; property ParentShowHint; property Pen: TPen read FPen write SetPen; property OnChangeBounds; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnPaint; property OnResize; property OnStartDock; property OnStartDrag; property ShowHint; property Visible; end; implementation { TTriangle } procedure TTriangle.SetBrush(Value: TBrush); begin if Value Brush then FBrush.Assign(Value); end; procedure TTriangle.SetPen(Value: TPen); begin if Value Pen then FPen.Assign(Value); end; procedure TTriangle.SetBaseAlign(aValue: TBaseAlign); begin if aValueFBaseAlign then begin FBaseAlign:=aValue; ParamsChanged(Self); end; end; class function TTriangle.GetControlClassDefaultSize: TSize; begin Result.cx:=65; Result.cy:=65; end; constructor TTriangle.Create(TheOwner: TComponent); begin inherited Create(TheOwner); with GetControlClassDefaultSize do SetInitialBounds(0, 0, CX, CY); ControlStyle := ControlStyle + [csReplicatable]; FPen := TPen.Create; FPen.OnChange := @ParamsChanged; FBrush := TBrush.Create; FBrush.OnChange := @ParamsChanged; FBaseAlign:=baBottom; end; destructor TTriangle.Destroy; begin FreeThenNil(FPen); FreeThenNil(FBrush); inherited Destroy; end; procedure TTriangle.Paint; var PaintRect: TRect; P: array[1..3] of TPoint; PenInc, PenDec: Integer; procedure CalcPoints(aBaseAlign: TBaseAlign); begin case aBaseAlign of baBottom: begin P[1].x := (Width - 1) div 2; P[1].y := PenInc; P[2].x := Width - PenInc - 1; P[2].y := Height - PenInc - 1; P[3].x := PenInc; P[3].y := Height - PenInc - 1; end; baTop: begin P[3].x := (Width - 1) div 2; P[1].x := PenInc; P[2].x := Width - PenInc - 1; P[3].y := Height - PenInc - 1; P[1].y := PenInc; P[2].y := PenInc; end; baLeft: begin P[1].x := PenInc; P[1].y := PenInc; P[2].x := Width - PenInc - 1; P[2].y := (Height - 1) div 2; P[3].x := PenInc; P[3].y := Height - PenInc - 1; end; baRight: begin P[1].y := (Height - 1) div 2; P[1].x := PenInc; P[2].x := Width - PenInc - 1; P[2].y := PenInc; P[3].x := Width - PenInc - 1; P[3].y := Height - PenInc - 1; end; end; end; begin Canvas.Pen:=FPen; Canvas.Brush:=FBrush; PenInc := Pen.Width div 2; PenDec := (Pen.Width - 1) div 2; PaintRect := Rect(PenInc, PenInc, Self.Width - PenDec, Self.Height - PenDec); if PaintRect.Left = PaintRect.Right then PaintRect.Right := PaintRect.Right + 1; if PaintRect.Top = PaintRect.Bottom then PaintRect.Bottom := PaintRect.Bottom + 1; CalcPoints(FBaseAlign); Canvas.Polygon(P); inherited Paint; end; procedure TTriangle.ParamsChanged(Sender: TObject); begin if (Parent nil) and (Visible or (csDesigning in ComponentState)) and Parent.HandleAllocated then Invalidate; end; end. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Souce listing on Mac
On 25/12/2013 13:20, Tom Backer Johnsen wrote: I have a small problem with Lazarus on a Mac. If I use the print option on a source element, it is printed out, but ... The file to fiddle with is lazarus\components\printers\design\sourceprinter.pas Perhaps a horrid hack such as changing line 101 of the PrintPage method to Printer.Canvas.TextOut(Margin, 50 + Round(LineHeight * l), s); (to increase the y offset by 50 - or some other value that suits your printer's dpi) and recompiling Lazarus would work for you. I think that TPrinterSetupDialog is not supported on Carbon. However, I don't know what is actually causing the loss of your first line. Finding the cause would lead to a more intelligent remedy than the shot-in-the-dark suggested above. There are several enhancements (some suggested by the author in a txt file in the source directory ...\printers\design\ ) that you might feel able to contribute if you come up with worthwhile improvements to the existing code. I'm sure patches to improve the functionality would be welcome. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TSpinEdit and TFloatSpinEdit
On 18/11/2013 16:00, Avishai wrote: Why do we have both TSpinEdit and TFloatSpinEdit? It seems like TFloatSpinEdit is enough. TFloatSpinEdit has property DecimalPlaces and when set to 0, it displays an Integer (although it's a Float). It's easy enough to get the Integer Value, but it could have Property FloatValue and Property IntValue. I presume for Delphi compatibility. It is then possible to convert a Delphi project to a Lazarus project without rewriting source code that involves spinedits. (The Delphi TSpinEdit has a Value property that is a longint). Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Inserting new pages into a TPageControl
On 11/10/2013 22:00, Mark Morgan Lloyd wrote: Given a TPageControl with several existing pages, how does one insert a page at a specified position rather than at the end? This function should do it: uses ComCtrls; function InsertAt(ExistingIndex: integer; aPageControl: TPageControl): TTabSheet; begin Result:=nil; if (ExistingIndex0) or (ExistingIndexaPageControl.PageCount-1) then Exit; Result:= aPageControl.AddTabSheet; if aPageControl.IndexOf(Result) ExistingIndex then TNBPages(TCustomTabControl(aPageControl).Pages).Move( aPageControl.IndexOf(Result), ExistingIndex); end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How do you remove form caption area?
On 05/10/2013 16:25, Graeme Geldenhuys wrote: Does LCL not have a TPopupWindow class? eg: like you would use for Hint Windows, Splash Screens etc? Weird. There is THintWindow in the Forms unit, but AFAIK it does not allow the kind of border the OP wants without resorting to calls such as SetWindowPos of which silvio gave an example. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTreenode.data
On 11/09/2013 09:24, Antonio Fortuny wrote: Le 11/09/2013 07:51, Richard Mace a écrit : procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin ShowMessage('Node ' + IntToStr(Integer(Node.Data))); change to: ShowMessage('Node ' + IntToStr(*PtrInt***(Node.Data))); Also unless you want the treeview to behave as if it were fully initialised with Data integer values of zero, you would need to add: procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin if Assigned(Node) then ShowMessage('Node ' + IntToStr(PtrInt(Node.Data))); -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TTreenode.data
On 11/09/2013 18:03, Flávio Etrusco wrote: On Wed, Sep 11, 2013 at 5:41 AM, Howard Page-Clark h...@talktalk.net wrote: Also unless you want the treeview to behave as if it were fully initialised with Data integer values of zero, you would need to add: procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin if Assigned(Node) then ShowMessage('Node ' + IntToStr(PtrInt(Node.Data))); I guess you mean if Assigned(Node.Data) then ? Indeed that is what I meant, not what I wrote! -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Positioning entries on main menu
On 30/08/2013 21:43, Mark Morgan Lloyd wrote: What I'm considering is something like a » symbol to control whether an extra pane is shown to the right of a text editor. You might get some ideas from the SelComponentPageButton which has been added in recent Lazarus commits (1.1). See ..\ide\main.pp, lines 2045-2055, and 5104-5121 (it's evidently copied from CodeTyphon). -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Anders Hejlsberg interview
People may be interested to listen to this 20 minute interview with Anders (and a MS colleague named Steve Lucco) in which they discuss Java, Javascript, C#, Typescript, XMl... http://www.codeproject.com/Articles/619759/CodeProject-interviews-Anders-Hejlsberg-and-Steve They also mention Microsoft's interest in outreach to the broader development community (i. e. non-Windows), and their view that Javascript is the only real cross-platform language. (Anders was the original architect of Delphi, now the chief architect of C#). -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WindowsVersion
On 10/07/2013 06:33, Richard Mace wrote: Hi, Could someone let me know what until WindowsVersion is in please? The unit is win32proc. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] libSANE.dll for winfows
On 28/05/2013 12:51, amin ibrahime wrote: Hi I try to uses scanner by lazarus application to multiplateform i found SANE demomain i compiled and run under liunx but when run under widows i need*libsane.dll * where i can find this dll or its pascle source code to compile and use Scanning support on Windows is provided via the Windows Image Acquisition Library v2.0, which comes as standard with Vista, 7 and 8 (wiaaut.dll, which should be found in the \Windows\System32 folder). AFAIK the Sane packages are Linux only. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] porting delphi project code
On 15/05/2013 19:19, waldo kitty wrote: can someone please give me the steps, in simple layman's terms, that are needed to convert a delphi project or application code to Lazarus/FPC? i have never run delphi and have not the first clue other than there is some sort of convertor available... where it is and how to use it are completely unknown to myself... Open the Lazarus IDE and you'll see the Tools menu has four conversion menu options relating to Delphi. Looks like you want the second Delphi conversion option: Convert Delphi project to Lazarus project... For simple projects the converter works well if you just accept all the defaults the wizard provides. Your Delphi code is saved unchanged, and the new Lazarus project ends up in a new directory with appropriate new .lpi, .lpr and .lfm files, .pas files adapted to use the LCL and probably substitutions for some Delphi components with their (approximately) equivalent LCL counterparts. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TextHeight in Console App
On 14/05/2013 15:32, Graeme Geldenhuys wrote: On 2013-05-14 14:07, Edilson Vieira wrote: The project is an Image Generation Program, a console program. The error ocurr when I call the method TextHeight of the Canvas property of TBitmap. You do realize that if you pull in the 'Graphics' unit of LCL, you don't have a console app any more, but a GUI app. I don't really know what you app does, but I would instead use FPImage (from Free Pascal's FCL packages), and use freetype (also included with fcl-image code). This will mean your app is not LCL dependent, and a real console application. Or create a Lazarus GUI app and implement Form1's OnCreate handler thus: procedure TForm1.FormCreate(Sender: TObject); var bmp: TBitmap; begin bmp := TBitmap.Create; try bmp.Canvas.Font.Name := 'Tahoma'; bmp.Canvas.Font.Size := 20; bmp.Canvas.Font.Style := [fsBold, fsItalic]; ShowMessageFmt('Text height is %d',[bmp.Canvas.TextHeight('T')]); finally bmp.Free; end; end; For a GUI app Lazarus sets up paths to LCL units such as Graphics (and its dependent units) correctly, and includes several such commonly used units in your uses clause automatically. Console apps usually require you to manually include the units you use, and specify their paths explicitly. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TMemo flicker
On 29/04/13 5:47, Jürgen Hestermann wrote: Am 2013-04-29 18:38, schrieb K. P.: Have you tried wrapping your writes in memo1.Lines.BeginUpdate and memo1.Lines.BeginUpdate? I have tried it now but it doesn't change anything. In addition to wrapping the writes within BeginUpdate/EndUpdate simply remove the Application.ProcessMessages call that is repeated within your loop. It is completely unnecessary and serves only to produce the flicker. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to create a listbox that can be shifted
On 23/04/13 5:20, Jürgen Hestermann wrote: I am stuck again. How can I make long (wide) text visible in a restricted window? Use a TMemo, and set its ScrollBars property to ssAutoBoth? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Is the site http://forum.lazarus.freepascal.org dead?
On 19/04/13 7:16, GREP wrote: I don't even know how to add a hostfile and your command on Windos XP sp3 dowsnot work ipconfig Try opening a command prompt in the directory c:\windows\system32 and type ipconfig /flushdns Enter (note that an h was missed off the parameter in a previous post) -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] PAnsiChar to UTF8 issues
On 09/04/13 6:35, Leonardo M. Ramé wrote: Well, I can live with the debugger problem, but is there a solution for the ? sign end displaying in my app?. If you get an ansi string, you must convert it to utf8 before giving it to the LCL need to find the exact function label.caption :- ansitoutf8(s) // assuming it is ansi in the system codepage Yes, I've tried that, but it shows a box with an X inside where the ñ should appear... My codepage is es_AR.UTF-8. u:unicodestring; u:=Putf8Char(buf); // or PAnsiChar depends on what your C DLL returns label.caption:=u; // implicit cast No, I've tried all kinds of combinations of ansitoutf8, unicodestring, etc, but nothing works, all returns ? or the box with the X in the place of ñ or accents. Impertinent question really, but do you know for certain that the font assigned to your label has glyphs corresponding to each unicode entity your string contains? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Event generator
On 02/04/13 2:47, Antonio Fortuny wrote: BUT: on the form of an application (btw, multi-threaded + Indy 10) drop a common TButton on the main (and only) form: OK. When trying to assign an event to it: BOUM :o the LCLClasses unit is displayed and the next error is displayed in the errors window: No way to assign an event to a new TButton. Same behaviour in both machines. What happens ? If you view your project in the Project Inspector, is the LCL shown as a required dependency? If not, it should be added. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] some number manipulation
On 09/03/13 11:12, appjaws wrote: Hi all, I have a series of results, for each day of the month I have 10 numbers ranging from 1 to 20. i.e. Day11,3,4,5,7,9,12,16,17,20 Day23,4,5,6,8,9,15,17,18,19 etc. Question 1 how can I find the number of 1's 2's 3's 4's etc. for the whole month series? Question 2 How can I test for 3 or more consecutive numbers in each day? Q1 for such a small dataset a brute force approach of iterating over all values and counting each occurrence of 1, 2, 3 etc. in 20 distinct counters seems best. Q2 Your data is ordered by value, so a function along these lines ought to work: type TNumber = 1..20; TDayData = array[1..10] of TNumber; function ThreeOrMoreConsecutiveNos(dd: TDayData): boolean; var i: integer=1; begin Result:= False; while i =8 do begin if ( dd[i]=Pred(dd[i+1]) ) and ( dd[i+1]=Pred(dd[i+2]) ) then Exit(True); Inc(i); end; end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] some number manipulation
On 09/03/13 3:06, appjaws wrote: I have a series of results, for each day of the month I have 10 numbers ranging from 1 to 20. i.e. Day11,3,4,5,7,9,12,16,17,20 Day23,4,5,6,8,9,15,17,18,19 ... I just realised that I need to sort the numbers because they are not like my example above. So where and how would I sort the array for each Day and then call ThreeOrMore? If you have any programming books you'll almost certainly find they include a chapter on sorting algorithms (bubble sort, quicksort etc.). One FPC/Lazarus tutorial implementation is at http://www.pp4s.co.uk/main/tu-ss-sort-quick-demo1a.html and Lazarus also has several integer quicksort implementations in its own code such as at ...\lazarus\lcl\grids.pas, line 2850 Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] exception handling in constructor
On 02/03/13 10:51, Michael Van Canneyt wrote: This will definitely cause a memory leak, because the FPC code does not know that an exception occurred in the constructor (you catch it with Except), and hence will not call the destructor. Thanks for the correction and explanation. Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to rename a Form
On 20/02/13 9:05, Frédéric Loyer wrote: When I create a new application project, my program start with a Unit1 (I can easily rename), associated with a Form1 I can't rename. How can I change the name of this form ? In the Lazarus IDE, make sure the form is selected by clicking it, move focus to the Object Inspector (F12), scroll down to the Name property (first column) and change the Form1 entry (second column) to whatever you prefer. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Code Completion Templates
On 12/02/13 6:58, Donald Ziesig wrote: The following code from my TemplateExpander unit fails at compilation: uses CodeToolOptions; because the compiler can't find the file. Assuming CodeTools has been added as a dependency for your project, I think you also need to add in the Project Options dialog in the Compiler Options | Paths page, in the dropdown field labelled Other unit files(-Fu) (delimiter is semicolon) the following macro $(LazarusDir)\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType) -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Project Options dialog
This is a suggestion for improving the Project Options UI. The Application (settings) page now sports several platform-specific options. I think it would be better to group these by platform, and have the list of settings identified by platform. Something like: Cross-platform settings --- Title: ... Icon: ... Darwin application settings --- [ ] Use Application Bundle for running and debugging [Create Application Bundle (button)] Windows application settings [ ] Use an external manifest to enable themes (XP and above) [ ] Enable DPI awareness (Vista and above) [ ] Enable UI access via manifest (uiAccess=True) Execution level [dropdown combo] It would also help if some knowledgeable developer could add a few sentences in the wiki to document the newer platform-specific options. I know just enough to be dangerous if I wrote about them. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Problem growing an array
On 25/1/13 3:55, appjaws wrote: Hi, Could one of you experts look at my code please. My program crashes after the first set of strings are added because -- I think -- the length is not updating. The following is just a snipet. It's hard to tell from a snippet, but I don't see anywhere that you are initialising the values of your array indices x and y. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Problem growing an array
On 25/1/13 6:38, appjaws wrote: On 25/01/13 18:26, Howard Page-Clark wrote: On 25/1/13 3:55, appjaws wrote: Hi, Could one of you experts look at my code please. My program crashes after the first set of strings are added because -- I think -- the length is not updating. You're not initialising the array of array correctly. Try this: if Length(collection) (y+1)then begin SetLength(collection, y+1); SetLength(information[0],y+1); SetLength(information[1],y+1); SetLength(information[2],y+1); SetLength(information[3],y+1); SetLength(information[4],y+1); SetLength(information[5],y+1); SetLength(information[6],y+1); SetLength(information[7],y+1); end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus books
On 24/1/13 6:51, appjaws wrote: I need a book or site that can explain these details and provide working examples that I can use as practise. I know what I want to achieve with a gui program but not the best way to to complete an operation. Have you looked at Lazarus the Complete Guide (available in German or English)? http://www.blaisepascal.eu/index.php?actie=./subscribers/lazarusbookinfoEnglish There is a free online book by Motaz Azeem at http://code.sd/startprog/index.html (in Arabic or English) -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Dynamic library dependency error
On 22/1/13 2:22, xrfang wrote: I try to make a dynamic library and get this error: paintrect.pas(0,0) Fatal: Can not find unit Controls used by paintrect. Check if package LCLBase is in the dependencies. You need to add LCLBase as a project dependency. Use the Project Inspector's Add button to show the Add to Project dialog. Project - Project Inspector, then in the Project Inspector click the middle tab to open the New Requirement page, and in the Package Name combo dropdown choose LCLBase from the long list presented. Then click the [Create New Requirement] button, and you're done - the new package requirement will be listed under Required Packages node in the Project Inspector. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Got Pointer, expected Open Array Of Char
On 13/1/13 1:58, Dave Coventry wrote: On 13 January 2013 14:56, leledumbo leledumbo_c...@yahoo.co.id wrote: Or const since it's meant to be read only Hmmm. Doesn't help. Still getting the same error. I've tried passing the src parameter as a Pointer and then casting it as an array of Char. procedure Copybytes(var dst: Pointer; src: Pointer; len: integer); var i: integer; data_in,data_out: Array of Char; begin data_in:=@src; data_out:=@dst; for i:=0 to len-1 do begin data_out[i]:=data_in[i]; end; end; Calling the procedure: Copybytes(@dst[dloc],@src[sloc],16); I get the error Error: Can't assign values to an address One source of confusion arises because your parameter declaration array of char in procedure Copybytes(var dst: array of Char ... means something different from your variable declaration var data_in, data_out: Array of Char; where Array of Char denotes a dynamic array - rather different from the parameter-passing declaration. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Got Pointer, expected Open Array Of Char
On 12/1/13 6:10, Dave Coventry wrote: dst and src are passed to the function that calls Copybytes(); function copy_compressed_bytes(var dst: array of Char; var dloc, sloc: integer; src: array of Char; len: integer): integer; begin Copybytes(@dst[dloc],@src[sloc],16); return 0; end; I think making src also a var parameter and structuring the signatures for the routines without @ as follows will work: procedure Copybytes(var dst, src: array of Char; len: integer); ... function copy_compressed_bytes(var dst: array of Char; var dloc, sloc:integer; src: array of Char; len: integer): integer; begin Copybytes(dst[dloc],src[sloc],16); Exit(0); end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] record literal in FPC?
On 08/1/13 3:30, xrfang wrote: I would like to use literal directly, such as: Edit1.CaretPos := (X: 0, Y: 0); You can use a typed constant thus: const Origin: TPoint = (x:0; y:0); begin ... Edit1.CaretPos := Origin; ... -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] My Lazarus logo using Inkscape
On 08/1/13 3:14, Zaher Dirkey wrote: We need the declaration for reproduce word, i don't think it is make a similar to it, i need a lawyer :P IANAL but reproduce here means produce a copy of, which you are not doing. Rather you are adapting the image (or taking inspiration from the image, or whatever) i.e. producing a different image. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Difference between Delphi 2010 / Lazarus
On 13/12/12 9:45, Jorge Gonçalves wrote: Hi, I'm translating one application from delphi to lazarus, and I'm having some problems with the way lazarus and delphi stores calculate fields in the dfm. The delphi store one more property :Calculated. This property is public and are stored using the procedure DefineProperties at TField level. dfm example : Delphi : object DetailsTOTAL: TFloatField FieldKind = fkCalculated FieldName = 'TOTAL' DisplayFormat = '0.00' * Calculated = True* end Lazarus : object DetailsTOTAL: TFloatField FieldKind = fkCalculated FieldName = 'TOTAL' DisplayFormat = '0.00' end Any easy way to solve the problem ? Bit of a hack, but you could use the Tag property as a boolean on Lazarus. Its published, so is stored in the .lfm. But obviously this would require {$IFDEF } to compile on Delphi too. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Converting pence into pounds and then to string
How's the best way of converting an integer number 208 (that is pence) into a string value that is in pounds (2.08) Here's another variant that provides an optional $, £ or € uses math; function PenceToString(pennies: integer; precision: integer=2; currency: string=''): string; begin Result:= Format(Format(currency+'%%.%df',[precision]), [pennies/(10**precision)]); end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] from hfiandor 11 dic 2012
On 12/12/12 1:40, Héctor F. Fiandor Rosario wrote: Dear fellows: I am using SQLite3 for an application and I have a problem. I need to use a table in an unit that don´t has a form -is a unit for ReadWrite procedures- and I can´t place the DataAccess for SQLite icom. Please, in this cases, what to do? Please do two things: 1 As has been requested of you several times, find out how to use your email client so that you can start a new thread for your questions, and not interrupt another thread every time. 2 Use a TDataModule for your table (File - New - Data Module), or create it in code by calling its constructor. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TDataModule accepts some visual controls
I discovered that a datamodule will let you drop a TMainMenu or a TPopupMenu on it. Is this by design, or an oversight? Should I report this as a bug? Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Beta testers needed / Lazarus with Editor-Macro-Script
On 30/11/12 1:21, Martin wrote: Hi, I need some testers for all the different available platforms. Because, unfortunately, I do not have every available hardware/OS myself :( ?xml version=1.0 encoding=utf-8? TestResults !-- Generated using FPCUnit on 2012-11-30 10:59:13-- TestListing TestSuite Name= ElapsedTime=00:00:51.230 NumberOfErrors=0 NumberOfFailures=0 NumberOfRunTests=3 NumberOfIgnoredTests=0 TestSuite Name=TTestCase1 ElapsedTime=00:00:51.230 NumberOfErrors=0 NumberOfFailures=0 NumberOfRunTests=3 NumberOfIgnoredTests=0 Test Name=TestBasics Result=OK ElapsedTime=00:00:00.124/ Test Name=TestSynProcs Result=OK ElapsedTime=00:00:00.281/ Test Name=TestInteractiv Result=OK ElapsedTime=00:00:50.825/ /TestSuite /TestSuite /TestListing NumberOfRunTests3/NumberOfRunTests NumberOfErrors0/NumberOfErrors NumberOfFailures0/NumberOfFailures NumberOfIgnoredTests0/NumberOfIgnoredTests TotalElapsedTime00:00:51.246/TotalElapsedTime DateTimeRan2012-11-30 11:00:04/DateTimeRan /TestResults This is on a Win 7 (Home Premium) 64 bit dual core processor running 32-bit Lazarus, FPC 2.6.1 -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Why doesn't this work?
On 28/11/12 10:15, Erwin van den Bosch wrote: procedure TForm1.Button1Click(Sender: TObject); var iLastError: integer; begin iLastError:=10053; if iLastError in [10053, 10054] then Label1.Caption:='Yes, it works!' else Label1.Caption:='No, it doesn''t work!'; // Output : No, it doesn''t work! end; You may be thinking of how in is used in a for..in..do loop like this procedure TForm1.Button1Click(Sender: TObject); var iLastError, j: integer; intArray: array[0..1] of integer = (10053,10054); begin iLastError:=10053; for j in intArray do if j=iLastError then begin Label1.Caption:='iLastError present'; Break; end else label1.Caption:= 'iLastError not found'; end; -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Where is the System Unit source?
On 14/11/12 4:19, Curt Carpenter wrote: Could anyone tell me where I'll find the system unit source? I have the source for FPC, but can's seem to find system.pas anywhere. Look in fpc/rtl/inc/system.inc Howard -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus