Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003761 [JEDI VCL] 00 JVCL Components minor always 2006-06-11 01:02 2008-10-14 02:25
Reporter bunglehead View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.20
Summary 0003761: JvDocking focus bug (VID and .NET style)
Description Tab Container doesn't focus properly..
You can try it on VIDDemo example..

1. Show 3 docking forms (at least). For example Project Explorer, Properties and Toolbox.
2. Dock two of them into a tab container, then dock this container.
3. Now set focus on third (not tabbed) form and dock it to then container
4. Container caption didn't highlight. And doesn't respond on mouse clicks and focusing of tabbed forms.
Additional Information
Tags No tags attached.
Attached Files zip file icon [^] (20,121 bytes) 2007-03-07 13:34
zip file icon [^] (135,781 bytes) 2007-03-20 09:25
? file icon JvDockVIDStyle.patch [^] (1,693 bytes) 2008-03-07 22:20
? file icon JvDockVIDStyle2.patch [^] (1,634 bytes) 2008-03-13 14:53

- Relationships

-  Notes
obones (administrator)
2006-06-22 08:11

Yes, it does not highlight, but it does respond to mouse clicks on tabs.
Please try with todays snapshot: [^]
bunglehead (reporter)
2006-06-22 16:16

No, no..I meant caption doesn't respond by highlighting when you click on it..
Tabs work of course..
It isn't a big problem, but users don't understand it)
obones (administrator)
2007-01-03 12:07

Can you provide the zipped sources of a demo application showing what you mean?
bunglehead (reporter)
2007-03-07 13:34

You can try this with src provided. I've tried it just now with latest snapshot, problem remains the same.
Dock two froms to each other to get tab container.
Then dock this container to left side of a main form.
After docking title bar of tab container remains inactive, but all tab functions are ok.
After Minimizing -> Maximizing everything become good.
Kiriakos (reporter)
2007-03-18 17:03

In my private copy of JvDockVIDStyle I have made the following changes to deal with focus problems:

a) In TJvDockVIDTabPageControl.Change I have commented out 5 lines as below:

procedure TJvDockVIDTabPageControl.Change;
  inherited Change;

  { During closing/undocking of a form,
    ActivePage is actually going to be wrong.
    See above in DoRemoveDockClient for where we fix
    this problem. }
  ParentForm.Caption := ActivePage.Caption;

  if ParentForm.HostDockSite is TJvDockCustomPanel then
// if ParentForm.Visible and ParentForm.CanFocus then
// ParentForm.SetFocus;
// if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then
// if ParentForm.Visible and ParentForm.CanFocus then
// ActivePage.SetFocus;

b) In TJvDockTabPanel.MouseDown I have added 8 lines

procedure TJvDockTabPanel.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
  Ctrl: TControl;
  Index: Integer;
  Msg: TWMMouse;
  Sheet: TJvDockVIDTabSheet;
  inherited MouseDown(Button, Shift, X, Y);
  if Page = nil then

  Index := GetPageIndexFromMousePos(X, Y);
  if Index >= 0 then
    // added
    if Page.ParentForm.HostDockSite is TJvDockCustomPanel then
    with Page do begin
      if ParentForm.Visible and ParentForm.CanFocus then
      if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then
        if ParentForm.Visible and ParentForm.CanFocus then
    // added

Does this resolve your problem?


Further down in TJvDockTabPanel.MouseDown there is the code:
  Page.ActivePageIndex := Index;
This shows the new page of TabPanel sets the focus to the first selectable control of the docked form.
Just below this statement there the line:
This triggers the change method that is listed at the top of this comment. The commented out lines remove the focus from the docked form and set to the tab page itself. This creates the focus problems.
bunglehead (reporter)
2007-03-19 07:58

No, this doesn't resolve it. Problem remains the same.
Kiriakos (reporter)
2007-03-19 19:55

OK. The submitted changes solve a different focus problem.

Please try the following:

In unit JvDockVIDStyle add these lines at the end of TJvDockVIDPanel.CustomDockDrop

    if (Source.Control is TJvDockTabHostForm) and
      (TJvDockTabHostForm(Source.Control).GetActiveDockForm <> nil) and
      TJvDockTabHostForm(Source.Control).GetActiveDockForm.CanFocus then

Optionally (this is for when you undock tabbed forms) add the following method to TJvDockTabHostForm in unit JvDockControlForm

    procedure DoDock(NewDockSite: TWinControl; var ARect: TRect); override;

procedure TJvDockTabHostForm.DoDock(NewDockSite: TWinControl; var ARect: TRect);
  if (GetActiveDockForm <> nil) and
      GetActiveDockForm.CanFocus then

Please report back.
Kiriakos (reporter)
2007-03-19 20:47

Corrected TJvDockTabHostForm.DoDock below. Please use this one instead of the one given above.

procedure TJvDockTabHostForm.DoDock(NewDockSite: TWinControl; var ARect: TRect);
  if not JvGlobalDockIsLoading and
    (GetActiveDockForm <> nil) and
    GetParentForm(Self).Visible and
    GetActiveDockForm.CanFocus then
Kiriakos (reporter)
2007-03-19 21:11

Also, make sure you set the Dock Server AutoFocusDockedForm property to True. With the combined changes I have presented I get the desired focus behaviour in the scenarios you described.
Kiriakos (reporter)
2007-03-20 09:31

I have done some more work on the Focus issue and attached the private copies of modified JvDocking files in the attached file. To test use the Advanced Demo:

a) Copy the zipped files to the directory of the Demo.

b) Modify TRunTimeForm.Create in the demo so that the memo component is displayed in the form and you can observe whether it receives the focus or not.

  with TMemo.Create(Self) do
    Parent := Self; //added
    Align := alClient;
    BorderStyle := bsNone;

c) Test with the VID VSNet styles

If the changes produce the desired results or at least improve over the current situation I will submit pathches to Jvcl.
bunglehead (reporter)
2007-03-20 13:03

Hello, I've tried it all. Well, it solves something it's true, but problem still exists. Sometimes caption of pagecontrol is not highlighted. But now it goes better. Vista style of dragging is very pretty, but it's must be an option (published property) I think. And it isn't included in SVN yet...
bunglehead (reporter)
2007-03-20 13:19

With a new dragging there're some unnecessary flashing of alphablended rectangle. This blinking goes far out of window - container of DockServer..
Maybe it's a common JvDocking issue, and isn't the result of your suggestions..
remkobonte (developer)
2007-03-26 15:55

Is the problem in this specific case maybe just the "if ActiveControl = Control then" check in TJvDockVIDTree.DrawDockGrabber?

ie, if you change it to

"if TWinControl(Control).ContainsControl(GetActiveControl) then" it works for me.
bunglehead (reporter)
2007-03-27 12:10

No, it doesn't help always. Sometimes I got the incorrect font color (when the same condition used for font color preselection).
remkobonte (developer)
2007-03-27 14:13

Could you try to reproduce a case when it's not correct? I'll inspect the changes by Kiriakos in the mean time :)
bunglehead (reporter)
2007-03-28 01:13

I'm sorry. I meant color of close and hide buttons on a grabber. I can't reproduce it all the time..Same as my initial issue (0003761). Kiriakos' changes don't resolve it all. Your suggestion is much more light. It eliminates focus issue, but not completely (it remains sometimes after multiple minimize/restore operations). If you could fix color of buttons this solution must be temporarely used.
Look at another Kiriakos suggestion on using Vista's alpha rectangle when dragging instead of traditional (in It isn't a finished work yet. Cause of flickering of this rectangle. But after some work it solud live as an aditional property I think.
bunglehead (reporter)
2007-03-29 12:15

I think this is fixed now (at 03/29/2007). But another behaviour changed: when main form (Container of all JvDocking components) lost focus, grabber remains highlighted. Is it a desired behaviour? I think previous versions (where grabber was disabled when main form lost focus) were better in this part.
remkobonte (developer)
2007-03-29 12:45

Thanks for the feedback, I didn't think of that. Should now be fixed in Rev 11245.
bunglehead (reporter)
2007-03-30 11:52

Yes, I thought about this solution yesterday. But:
It works only if Control in your IsActive condition contain a control that can catch a focus (such as in Advancepro demo example). If dock form has no focusable objects grabber doesn't repaint correctly.
And this code is unsafe. If you want to use this you should split it in something like that to prevent AV on getting Focused property:

        if Assigned(Screen.ActiveControl) then
           IsActive := Screen.ActiveControl.Focused and
           IsActive := False;

But first of all a patch needed to resolve this issue completely. I'm trying to find it too.
remkobonte (developer)
2007-04-01 05:22

That is not correct, I think:

* If the dock form contains no focusable objects and you or the system focuses the dock form then the Screen.ActiveControl will be the dock form itself; and the ContainsControl method will return True in this case.

* JVCL uses Delphi's short-circuit Boolean evaluation that means strict left-to-right evaluation that stops as soon as the result of the entire expression is determined.

Thus if "Assigned(Screen.ActiveControl)" is False then "Screen.ActiveControl.Focused" will not be evaluated.
bunglehead (reporter)
2007-04-01 13:26

About the first:
 may be it isn't serious, but when dockform contains no focusable objects in
 doesn't catch focus (I might be wrong but simple clicking on it hasn't any
 consequence such as grabber highlighting; but clicking on grabber active it

About short boolean evaluation:
 I did not know that it's a default JVCL compiler configuration.
 What about debug mode? By myself I prefer splitting in such pointer operation
 cases to be sure.
Kiriakos (reporter)
2007-04-17 18:38


The new JvDocking code is working fine except for the change you made in TJvDockTabPanel.MouseDown following my suggestion which does not always pass the focus to the controls of the form when you click the tab. I got a better solution which always works. It also focuses correctly when you click the tab of an already selected form. Here is the amended part of TJvDockTabPanel.MouseDown.

procedure TJvDockTabPanel.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
  Ctrl: TControl;
  Index: Integer;
  Msg: TWMMouse;
  Sheet: TJvDockVIDTabSheet;
  AParentForm: TCustomForm;
  inherited MouseDown(Button, Shift, X, Y);
  if Page = nil then

  Index := GetPageIndexFromMousePos(X, Y);
  if Index >= 0 then
    if Index <> Page.ActivePageIndex then
      Sheet := Page.ActiveVIDPage;
      Page.ActivePageIndex := Index;
    // Added code
    if Assigned(Page.ActivePage) and Page.ActivePage.CanFocus then
      AParentForm := GetParentForm(Page);
      if Assigned(AParentForm) then begin

Also please take a look at reports 4108 and 4109.
Kiriakos (reporter)
2007-04-17 18:45


Also outstanding JvDocking patches are in reports 3998 and 4076.

Many thanks!
obones (administrator)
2008-02-21 03:30

Any news on this?
Kiriakos (reporter)
2008-03-07 22:23

I have attached a patch file with my changes to JvDockVIDStyle.pas. The changes are related to this focus issue. I have been using these changes for ages in the open source project PyScripter (, and have not heard of any problems.
obones (administrator)
2008-03-10 01:59

Thanks, but the patch seems to be done on a very old version of the file, in a format that TortoiseSVN cannot understand. And I even suspect it's done in reverse with the "--" lines being what you want added and not removed.
Can you recreate the patch from the current version of the file from subversion?
Thanks in advance.
Kiriakos (reporter)
2008-03-13 14:54

Added a new patch, which is against the SVN version. I hope the format is OK...
obones (administrator)
2008-10-14 02:24

This is in SVN since March, sorry for the delay in updating the issue.

- Issue History
Date Modified Username Field Change
2006-06-11 01:02 bunglehead New Issue
2006-06-11 01:03 bunglehead Issue Monitored: bunglehead
2006-06-11 01:12 bunglehead Issue End Monitor: bunglehead
2006-06-22 08:11 obones Note Added: 0009621
2006-06-22 08:11 obones Status new => feedback
2006-06-22 16:16 bunglehead Note Added: 0009631
2007-01-03 12:07 obones Note Added: 0010492
2007-03-07 13:34 bunglehead Note Added: 0011296
2007-03-07 13:34 bunglehead File Added:
2007-03-18 17:03 Kiriakos Note Added: 0011459
2007-03-19 07:58 bunglehead Note Added: 0011477
2007-03-19 19:55 Kiriakos Note Added: 0011493
2007-03-19 20:47 Kiriakos Note Added: 0011494
2007-03-19 21:11 Kiriakos Note Added: 0011495
2007-03-20 09:25 Kiriakos File Added:
2007-03-20 09:31 Kiriakos Note Added: 0011520
2007-03-20 13:03 bunglehead Note Added: 0011521
2007-03-20 13:19 bunglehead Note Added: 0011522
2007-03-26 15:55 remkobonte Note Added: 0011610
2007-03-27 12:10 bunglehead Note Added: 0011634
2007-03-27 14:13 remkobonte Note Added: 0011635
2007-03-28 01:13 bunglehead Note Added: 0011645
2007-03-29 12:15 bunglehead Note Added: 0011675
2007-03-29 12:45 remkobonte Note Added: 0011676
2007-03-30 11:52 bunglehead Note Added: 0011704
2007-04-01 05:22 remkobonte Note Added: 0011738
2007-04-01 13:26 bunglehead Note Added: 0011743
2007-04-17 18:38 Kiriakos Note Added: 0012153
2007-04-17 18:45 Kiriakos Note Added: 0012154
2008-02-21 03:30 obones Note Added: 0014224
2008-03-07 22:20 Kiriakos File Added: JvDockVIDStyle.patch
2008-03-07 22:23 Kiriakos Note Added: 0014285
2008-03-10 01:59 obones Note Added: 0014287
2008-03-13 14:53 Kiriakos File Added: JvDockVIDStyle2.patch
2008-03-13 14:54 Kiriakos Note Added: 0014294
2008-10-14 02:24 obones Status feedback => resolved
2008-10-14 02:24 obones Fixed in Version => 3.34
2008-10-14 02:24 obones Resolution open => fixed
2008-10-14 02:24 obones Assigned To => obones
2008-10-14 02:24 obones Note Added: 0014856

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker