FastReport 4 and VCL Styles Errors

This is my first post here, and English is not my native language, so bare with me if I do not articulate myself well enough.

Some background information. I work for a very small company that recently upgraded Delphi from version 6 (!!!) to Rad Studio XE5, and a lot has changed in 10 years. Most of the things seem to have been improved in the IDE and in the framework, but we have big problems with the new VCL Styles feature. It’s just a very buggy and doesn’t match the quality that we got used to from Borland that day. We have done many tricks and are working to make everything work, but one problem really causes me at the moment, and this is due to the preview form in FastReport 4.

  • There is a white frame on the toolbar.
  • The controls in the print dialog, while others are incorrectly or improperly located

We really want to use VCL Styles to give our software a fresh new look, so we hope there is a solution to these problems.

Steps to reproduce the problems:

  • Create a New VCL Forms Application
  • Check VCL style in project> Options> Application> Appearance, for example. Sapphire Camry.
  • Add TfrxReport Component Report to Form
  • Double-click the frxReport1 component and add a group of page titles to have some content.
  • Add TButton to the OnClick event, call frxReport1.ShowReport ();
  • Run the program and press the button. In the preview form, you see that the toolbar is surrounded by a white frame that looks strange.
  • , , , .

- ?

enter image description here

: RRUZ , №1, . :

procedure TToolBarStyleHookEx.PaintNC(Canvas: TCanvas);
begin
  if TToolBar(Control).BorderWidth>0 then
  begin
    Canvas.Pen.Width := 4;
    Canvas.Pen.Color := StyleServices.GetStyleColor(scWindow);
    Canvas.Brush.Style := bsClear;
    Canvas.Rectangle(2,2,Control.Width-2,Control.Height-1);
  end;
  inherited;
end;
+4
1

VCL Styles.

1) Q: .

A: TToolBarStyleHook BorderWidth. PaintNC, .

type
  TToolBarStyleHookEx = class(TToolBarStyleHook)
  protected
    procedure PaintNC(Canvas: TCanvas); override;
  end;

{ TToolBarStyleHookEx }
procedure TToolBarStyleHookEx.PaintNC(Canvas: TCanvas);
var
  Details: TThemedElementDetails;
  LStyle: TCustomStyleServices;
  R: TRect;
begin
  if TToolBar(Control).BorderWidth>0 then
  begin
    LStyle := StyleServices;
    R := Rect(0, 0, Control.Width, Control.Height);
    Details.Element := teToolBar;
    Details.Part := 0;
    Details.State := 0;
    if LStyle.HasTransparentParts(Details) then
      LStyle.DrawParentBackground(Handle, Canvas.Handle, Details, False);
    LStyle.DrawElement(Canvas.Handle, Details, R);
  end;
  inherited;
end;

initialization
  TCustomStyleEngine.RegisterStyleHook(TToolBar, TToolBarStyleHookEx);

2) Q:

A: , TFormStyleHook, 3 .

1) frxPrintDialog .

2) .

3) .

, HCBT_ACTIVATE hook

var

 hhk: HHOOK;

function CBT_FUNC(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
const
  ClassNameBufferSize = 1024;
var
 hWindow: HWND;
 RetVal : Integer;
 ClassNameBuffer: Array[0..ClassNameBufferSize-1] of Char;
 i : integer;
begin
   Result := CallNextHookEx(hhk, nCode, wParam, lParam);
   if nCode<0 then exit;
   case nCode of
     HCBT_ACTIVATE:
     begin
       hWindow := HWND(wParam);
       if (hWindow>0) then
       begin
          RetVal := GetClassName(wParam, ClassNameBuffer, SizeOf(ClassNameBuffer));
          if (RetVal>0) and SameText(ClassNameBuffer, 'TfrxPrintDialog') then
          for i:= 0 to Screen.FormCount-1 do
          if (SameText(Screen.Forms[i].ClassName, 'TfrxPrintDialog')) and (Screen.Forms[i].Width<=563) then
            Screen.Forms[i].Width:=Screen.Forms[i].Width+8;
       end;
     end;
   end;

end;

Procedure InitHook();
var
  dwThreadID : DWORD;
begin
  dwThreadID := GetCurrentThreadId;
  hhk := SetWindowsHookEx(WH_CBT, @CBT_FUNC, hInstance, dwThreadID);
  if hhk=0 then RaiseLastOSError;
end;

Procedure KillHook();
begin
  if (hhk <> 0) then
    UnhookWindowsHookEx(hhk);
end;

initialization
  InitHook();

finalization
  KillHook();

enter image description here

enter image description here

. , .

+5

Source: https://habr.com/ru/post/1537714/


All Articles