0
votes

I have a problem with the text editors in Delphi XE2 when a VCL style is applied. If I have 2 TMemo controls (Memo1 and Memo2) placed on a form and Memo1 is partially behind Memo2, then the scollbars of Memo1 are painted over Memo2.

I tried to create a style hook inherited from TScrollingStyleHook, but I didn't find any way to fix the problem. Does anybody have an idea on how this bug could be fixed?

BTW: I tested it in Delphi XE5 too and it behaves in the same way.

Here is the source code for the .dfm and .pas files:

DFM:

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 282
  ClientWidth = 418
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 120
    Top = 80
    Width = 185
    Height = 89
    Lines.Strings = (
      'Memo1')
    ScrollBars = ssBoth
    TabOrder = 0
  end
  object Memo2: TMemo
    Left = 160
    Top = 128
    Width = 185
    Height = 89
    Lines.Strings = (
      'Memo2')
    ScrollBars = ssBoth
    TabOrder = 1
  end
end

PAS:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
1
Can you include a image of the issue?RRUZ
I am a new member of this website and I am not allowed to add images to the post, but I added the .pas and .dfm code to the description.daniel

1 Answers

3
votes

The Vcl Style Engine does not support correctly the scrollbar , in memo , the scrollbar is created from TScrollWindow class that is inherited from TWinControl class . the standard scrollbar (without vcl style) is painted as a part of memo . When using the vcl style the scrollbar of memo become a top window , and that's what cause the previous problems. if you look at the TScrollingStyleHook.UpdateScroll event , you can find that the style engine use SetWindowPos that bring the scrollbar to the top of others controls in order to show the scrollbar .

SetWindowPos(FVertScrollWnd.Handle, HWND_TOP, Control.Left + Left,
           Control.Top + Top, Right - Left, Bottom - Top, SWP_SHOWWINDOW);

if you want to fix this issue you need to paint the scrollbar inside the TMemo class , in the WM_NCPAINT message .