Recent Posts

Pages: [1] 2 3 ... 10
General / Re: Using the Mouse Wheel to Zoom
« Last post by bytebites on Today at 02:01:06 pm »
sign(WheelDelta) tells the direction.
General / Re: Binary Tree implementation
« Last post by BrunoK on Today at 01:42:59 pm »
Test application leaks a lot.
Thank's guys...

I'm using lazarus 2.2.2 and fpc 3.2.2 (Windows)

I already said it before, but registering the top level menu like this, worked...

Code: Pascal  [Select][+][-]
  2. procedure Register;
  3. begin
  4.   RegisterIDEMenuCommand(mnuMain, 'mniJFrameworkMainMenu','&Jota Framework', nil, nil);  
  5. end;

Bui I can't register the submenu inside it, the IDE doesn't find it when the application start.

General / Using the Mouse Wheel to Zoom
« Last post by J-G on Today at 12:17:06 pm »
I've not looked at the [OnMouseWheel] event previously and was surprized how easy it was to impliment a [Zoom] facility. I had prevously set up a TTrackBar to deal with the Zoom but the idea of using the MouseWheel seemed to be more 'intuitive' for the end user.

The proc for the TTrackBar is very simple :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ZoomChange(Sender: TObject);
  2. begin
  3.   Mag := Zoom.Position/100;
  4.   if Mag < 0.1 then
  5.     Mag := 0.1;
  6.   Calc(self);
  7. end;
You'll see that it just checks for a minimum size.

For the MouseWheel event it's very similar :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DisplayMouseWheel(Sender: TObject; Shift: TShiftState;
  2.   WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  3. begin
  4.   Mag := Mag*(WheelDelta/100);
  5.   if Mag < 0.1 then
  6.     Mag := 0.1;
  7.   Zoom.Position := Round(Mag*100);
  8.   Calc(self);
  9. end;
It still checks for the Min but also sets the TTrackBar position - just to keep the two 'in sync'.

The (WheelDelta/100) was decided empirically - starting with /1 then /1000  -    /100 seems OK but further tests may change that.

This works as anticipated ---  but only when enlarging  ie. pushing the Wheel forward  -- as soon as I pull the wheel back - just one click - the Magnification becomes the Min (0.1)

Assuming that WheelDelta might become negative, I tried ABS(WheelDelta/100) but that made the 'negative' Zoom maximize.  ???

I can see from the description of the TMouseWheelEvent that WheelDelta is "How many notches the wheel has been turned" but there doesn't appear to be a 'direction' parameter which I might be able to use.

Can anyone shed some light on how I might better determine the level of magnification - specifically in the negative direction?

mnuMain is in
I know, here is the unit I'm using for testing

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  3. {$mode objfpc}{$H+}
  5. interface
  7. uses
  8.   Classes, SysUtils, MenuIntf, Dialogs, Menus;
  10. procedure Register;
  12. procedure MessageClick(Sender:TObject);
  14. implementation
  15. var
  16.   vSect : TIDEMenuSection;
  19. procedure MessageClick(Sender: TObject);
  20. begin
  21.   ShowMessage((Sender as TComponent).Name);
  22. end;
  25. procedure Register;
  26. var
  27.   Path :String;
  28. begin
  29.   //vSect := RegisterIDEMenuRoot('Heavy User',nil);
  30.   //Path := vSect.Name;
  31.   //RegisterIDEMenuCommand(Path, 'mniJotaIdeWizardsMainMenu','&Jota Framework', nil, @MessageClick);
  32.   //RegisterIDEMenuCommand(Path, 'mniJotaIdeWizard','&Jota', nil, @MessageClick);
  34.   //vSect := RegisterIDESubMenu(nil,'HeavyUser','Heavy User');
  35.   //RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizardsMainMenu','&Jota Framework', nil, @MessageClick);
  36.   //RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizard','&Jota', nil, @MessageClick);
  38.   //vSect := RegisterIDESubMenu(mnuMain,'HeavyUser','Heavy User');
  39.   //RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizardsMainMenu','&Jota Framework', nil, @MessageClick);
  40.   //RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizard','&Jota', nil, @MessageClick);
  42.   vSect := RegisterIDESubMenu('','HeavyUser','Heavy User');
  43.   RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizardsMainMenu','&Jota Framework', nil, @MessageClick);
  44.   RegisterIDEMenuCommand(vSect, 'mniJotaIdeWizard','&Jota', nil, @MessageClick);
  45. end;
  47. end.
Already tested it, also with nil instead of mnuMain. I can't see the menu anywhere, I searched all the menus not only the root level.
Lazarus 2.2 on windows 10.
mnuMain is in
General / Re: Binary Tree implementation
« Last post by Thaddy on Today at 12:07:08 pm »
Any comparisons to the other binary trees in the standard distribution?
- ease of use
- speed
- compact
Not tested, but try

Code: Pascal  [Select][+][-]
  1. Section:=RegisterIDESubMenu(mnuMain, 'MenuItemName' ,'MenuItemCaption');
Already tested it, also with nil instead of mnuMain. I can't see the menu anywhere, I searched all the menus not only the root level.
Lazarus 2.2 on windows 10.
I don't have a Windows which is able to access the Internet. So I sent a Windows version of my program to a friend an he ran it on a pure Windows 10 (no Virtual Machine), where it worked. This computer has local IP adress
That's not the same friend which has the FTP server by any chance?
Because then it's obvious that it worked.
It just connected internally
It was the same friend, so this test was useless.

Code: Pascal  [Select][+][-]
  1. Type
  2.   TMyDummyClass = class(TObject)
  3.   public
  4.     class procedure OnStatus(etc. Etc cant look up the def now);
  5.   end;
  6. //...
  7. class procedure TMyDummyClass.OnStatus(etc. Etc cant look up the def now);
  8. begin
  9.   Writeln(logline);
  10. end;
  11. //...
  12.   fTX.OnStatus := @TMyDummyClass.OnStatus;
Thank you for that draft, it will help me.
And the timings look like... ?

Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018