Wheelmouse capture lazarus / 7-LCL ---------------------------------------------------------------------- cov · 2007-06-12 10:43 Hi, I've put a TScrollBox and a Tmemo onto a form. The TScrollbox has a Mousewheel event that I can use to capture Mousewheel scrolls. However, if I place a TImage into the TScrollBox, the Mousewheel is no longer accessible. If I click into the TScrollbox, it works. If I move the curser over the TMemo, it still works. But if I move the cursor over the TImage the mousewheel events are no longer being read. Does anyone have a solution? ---------------------------------------------------------------------- theo · 2007-06-12 11:04 I usually don't use TImage for this. You could make your own TCustomControl descendant then paint a bitmap in the OnPaint event and override function  DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; There are probably easier solutions. ---------------------------------------------------------------------- antonio · 2007-06-12 19:07 Quote from: "cov" But if I move the cursor over the TImage the mousewheel events are no longer being read. I tried this and the wheel events do are read. ---------------------------------------------------------------------- cov · 2007-06-12 20:21 Quote from: "antonio"Quote from: "cov" But if I move the cursor over the TImage the mousewheel events are no longer being read. I tried this and the wheel events do are read. Well, I'm afraid that My Mileage Differs. It works fine until I place the TImage on the TScrollBox. Also the TMemo does not appear to interfere. I also tried the following code:Code: [Select]unit wheelimage; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, Controls, Graphics, LCLType;   type   { TWheelImage }   TWheelImage = class(TCustomControl)   public     procedure EraseBackground(DC: HDC); override;     procedure Paint; override;     function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;   end; implementation uses unit1; procedure TWheelImage.EraseBackground(DC: HDC); begin   inherited EraseBackground(DC); end; procedure TWheelImage.Paint; var   x, y: Integer;   Bitmap: TBitmap; begin   Bitmap := TBitmap.Create;   try     // Initializes the Bitmap Size     Bitmap.Height := Height;     Bitmap.Width := Width;     // Draws the background     Bitmap.Canvas.Pen.Color := clBlack;     Bitmap.Canvas.Rectangle(0, 0, Width, Height);   finally     Bitmap.Free;   end;   inherited Paint; end; function TWheelImage.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;   MousePos: TPoint): Boolean; begin   Result:=inherited DoMouseWheel(Shift, WheelDelta, MousePos); end; end.                                                                                 How do I find out if the DoMouseWheel event has been triggered? ---------------------------------------------------------------------- antonio · 2007-06-12 20:30 I put a Scrollbox on a form and a TMemo and a TImage on it. Then I set property Autscroll to True and a Beep on the wheel event. It executed. If the event executes, DoMouseWheel method has been triggered. ---------------------------------------------------------------------- theo · 2007-06-12 21:06 Which widgetset are you talking about btw? I've just tested this on GTK1/2 and it works fine with a TImage on a TScrollbox. ---------------------------------------------------------------------- cov · 2007-06-13 04:47 Sorry: I'm Using 0.9.22 on XP. Antonio; try this: Form1.Height:=600; Form1.Widtht:=600; Memo1.Top:=496; Memo1.Left:=0; Memo1.Height:=100; Memo1.Widtht:=600; Image1.Top:=0; Image1.Left:=0; Image1.Height:=560; Image1.Widtht:=460; On my system the mousewheel works if the mouse cursor is over the TImage if x>100 (approximately). If you take it over the left side of the TImage it stops working. *I've just realised that I've posted under "Suggestions and Ideas" in error. Sorry!* ---------------------------------------------------------------------- Vincent Snijders · 2007-06-13 06:29 I am not sure if I understand exactly what you are trying to tell (too lazy to try the examples), but the win32 interface to the LCL sends mousewheel message to the control that is under the mouse pointer. So if you move your mouuse from athe timage, it won't get any mousewheel events. ---------------------------------------------------------------------- cov · 2007-06-13 07:28 Vincent; yes. I had a Form on which I placed a TScrollbox. I placed a TImage and a Tmemo into the scrollbox. The TImage took up most of the ScrollBox with the TMemo occupying a strip of 100 pixels at the bottom. In this case DoMousewheel Events were not passed onto the TScrollBox. Antonio did the same thing to try it out, but found that the DoMouseWhell event behaved as expected. Indeed when I tried it again and just dropped the TImage onto the TSCrollBox (without resizing it), the DoWheelMouse events were handled correctly. However, when I resized the TImage, a dead area manifested itself in the Top Left Corner of the TScrollbox which seems to be dependent on the size of the TImage. ie. the bigger the TImage, the larger the dead area. ---------------------------------------------------------------------- antonio · 2007-06-13 14:47 If the Scrollbox is the active control, the wheel events perform even if mouse pointer is out of it. And it becomes active even if you click on the image. If you click on the memo, this becomes active and the wheel events are not triggered. However, it seems to be there something if you put the image at the top and the memo on bottom. When the mouse is over the image, the wheel events aren't triggered. Not the same happens if you put two images on the box. Or if you put the memo on the top and the image on bottom. Or if you put two memos. The memo seems to interfere on the behavior of scrollbox, but only the first control on the scrollbox seems to loose wheel events, no matter it's a memo or a image. Or, yes, it seems to be restricted to a part of the first control, perhaps restricted to the first size of the first control. It seems to be there  some difference if you align scrollbox client or not. ---------------------------------------------------------------------- cov · 2007-06-13 17:47 Hi Antonio. Form laid out with the 300x300 TImage in the middle of the TScrollbox, TScrollBox is 690x600, Tmemo is 690x100 high. The app starts up with no response from moving the mousewheel. Click on the TMemo: still the mousewheel doesn't trigger events. Click in the middle of the TImage: the mousewheel is now producing events. Mousewheel now produces events except in an area about 260x300 in the top left corner. ie there is a dead spot about 260 wide by 300 high in the top left hand corner of the Form. Can you reproduce these results? ---------------------------------------------------------------------- antonio · 2007-06-13 17:55 Now I have two memos on the scrollbox. Not exactly, but yes. There is a dead area associated to the presence of the memo on the scrollbox. SynEdit doesn't solve the problem. Apparently you should not use any multiline edit control on the scrollbox. Probably it's valid for Windows only. ---------------------------------------------------------------------- cov · 2007-06-13 21:36 Quote from: "antonio"Now I have two memos on the scrollbox. Not exactly, but yes. There is a dead area associated to the presence of the memo on the scrollbox. SynEdit doesn't solve the problem. Apparently you should not use any multiline edit control on the scrollbox. Probably it's valid for Windows only. Antonio, I've taken the TMemo out of the TScrollBox and placed it directly onto the Form. There is no change in the wheelmouse behavior. ---------------------------------------------------------------------- antonio · 2007-06-13 21:42 The form doesn't have wheel events. It doesn't respond to the wheel at all. ---------------------------------------------------------------------- cov · 2007-06-14 05:11 Yes, but my point is that the multiline edit control is no longer in the TScrollBox, so it should not be having any impact. ---------------------------------------------------------------------- antonio · 2007-06-14 16:53 OK. If you put any other control on the scrollbox, probably it will work OK. If your point is: yes, go ahead and make Lazarus a geat IDE, I am with you. If your point is: no, Lazarus is a bad IDE, don't  use it, I'm not wih you. There are people who give up on the first problem and don't wanna make efforts. And there are people who like to find problems, because this is a way of help. If you are a user who would like to make applications with Lazarus, I would like you to know that this forum is a good way to find help. By the way, what Lazarus Project has to offer is not simply a IDE, it's a innovative organization style where users can be also developers. They can bring original and important contributions. Be you too a contributor to the project. ---------------------------------------------------------------------- cov · 2007-06-14 20:39 Antonio, My need is to make Lazarus work to make my app work. I am on the Lazarus list and I can assure you that I do make the effort. Years ago I paid good money to buy Delphi 3. Delphi 4 was a dud, so I didn't upgrade. Then Delphi 5 and Delphi 6 introduced restrictions into the 'Standard' license, so I didn't upgrade. I could probably use my (legitimate) Delphi 3 application to compile and distribute my application. That is not the point. The point is that I want my app to run on Linux. If it runs on Mac OS X, then so much the better. In any case I am just pointing out that my application cannot run under Lazarus as it is at the moment. Maybe Lazarus needs to change, maybe I need to rewrite my app so that it does run. If it's the latter please let me know how I need to change my program so that it runs. If it's the former, please help me to assist the developers to identify and rectify a bug (if bug it is). ---------------------------------------------------------------------- antonio · 2007-06-14 20:51 The dead area is a problem,  but not necessarily a Lazarus bug. Maybe it's a Windows bug. If so, you can prevent this bug by changing your program. Anyway, you could want to more accurately work on this by posting on bug tracker. If you want so, please do it, it's a way to contribute. Cov, please respond. If you will not post on the tracker, I will.