Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-09

MDI problem and fix for Windows with Qt4/Qt5

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rudolf Cornelissen

Hi all,

This is my first post here, I hope my input is considered helpfull.

Anyhow, I am busy converting a Delphi MDI application (which I develop as a daytime job) to Lazarus using Qt/Qt5.
Compared to Win32 Widgeset indeed Qt has much more stuff in place.

A problem I encountered is a mouse offset between mouseposition in the MDI child window 'onscreen' and the position as handled internally in LCL when a button in pressed.

The effect is that for instance if I have a button onscreen, and I hover over it, the color correctly changes hinting me that I can press that button. When I do however, the button is not activated unless I hover my mouse 'titlebar height' above the button.

There is a simple fix possible for this my modifying the file 'qtwidgets.pas' in both Qt and Qt5 LCL/interfaces folders.

When I modify routine 'TQtMainWindow.OffsetMousePos' in the below way MDI works fully correctly concerning the mouse positions here (windows7 tested):

procedure TQtMainWindow.OffsetMousePos(APoint: PQtPoint);
var
  MyWidget         : QWidgetH;
  MyStyle          : QStyleH;
  MyTitleBarHeight : Integer;
begin
  inherited OffsetMousePos(APoint);
  if IsMdiChild and not IsMaximized then
  begin
    //correct windowed Y-pos
    //dec(APoint^.Y, GetSystemMetrics(SM_CYCAPTION)); //windows only
    MyWidget := GetWidget;
    MyStyle  := QWidget_style(MyWidget);
    MyTitleBarHeight := QStyle_pixelMetric(MyStyle
,QStylePM_TitleBarHeight, nil, MyWidget);
    dec(APoint^.Y, MyTitleBarHeight);
    //correct windowed X-pos
    dec(APoint^.X, (self.getFrameSize.Width -
self.getClientBounds.Size.Width) div 2);
  end;
end;

Can someone validate I am not doing something stupid here and update the sources if not?
That would save me some work manually modifying these routines over here..

Thanks for taking the time to look at this..

Kind regards,

Rudolf.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180905/090b3675/attachment.html>

Reply by email

zeljko
to Rudolf Cornelissen
Rudolf Cornelissen wrote 55 lines
Hi all, This is my first post here, I hope my input is considered helpfull. Anyhow, I am busy converting a Delphi MDI application (which I develop as a daytime job) to Lazarus using Qt/Qt5. Compared to Win32 Widgeset indeed Qt has much more stuff in place. A problem I encountered is a mouse offset between mouseposition in the MDI child window 'onscreen' and the position as handled internally in LCL when a button in pressed. The effect is that for instance if I have a button onscreen, and I hover over it, the color correctly changes hinting me that I can press that button. When I do however, the button is not activated unless I hover my mouse 'titlebar height' above the button. There is a simple fix possible for this my modifying the file 'qtwidgets.pas' in both Qt and Qt5 LCL/interfaces folders. When I modify routine 'TQtMainWindow.OffsetMousePos' in the below way MDI works fully correctly concerning the mouse positions here (windows7 tested): procedure TQtMainWindow.OffsetMousePos(APoint: PQtPoint); var   MyWidget         : QWidgetH;   MyStyle          : QStyleH;   MyTitleBarHeight : Integer; begin   inherited OffsetMousePos(APoint);   if IsMdiChild and not IsMaximized then   begin     //correct windowed Y-pos     //dec(APoint^.Y, GetSystemMetrics(SM_CYCAPTION)); //windows only     MyWidget := GetWidget;     MyStyle  := QWidget_style(MyWidget);     MyTitleBarHeight := QStyle_pixelMetric(MyStyle ,QStylePM_TitleBarHeight, nil, MyWidget);     dec(APoint^.Y, MyTitleBarHeight);     //correct windowed X-pos     dec(APoint^.X, (self.getFrameSize.Width - self.getClientBounds.Size.Width) div 2);   end; end; Can someone validate I am not doing something stupid here and update the sources if not? That would save me some work manually modifying these routines over here.. Thanks for taking the time to look at this..

Please open an issue about it and attach example project.

zeljko

Reply by email