Solved

I need to make a toolwindow (like in Photoshop)

Posted on 2001-06-27
7
359 Views
Last Modified: 2010-04-06
Ok, I was wondering if there was a component out there to make a toolwindow.  I've tried to use the bsToolWindow setting for a window, but it does not give the desired effect.  I guess what I really need is a way to:
1) have a form with controls on it
2) be able to use the StayOnTop setting
3) have the controls be clickable, BUT
4) does not take focus away from currently active window.

I guess I could always return focus to a form, but was wondering if there was an obvious (easier) way that I am missing.
0
Comment
Question by:felonious
7 Comments
 
LVL 6

Expert Comment

by:Jaymol
ID: 6234198
I'd advise using a form without a caption bar or border, and place an image on it that looks like a form.  That way, when it does not have focus, it doesn't look disabled.

I know this is basic, but you may not know so I'll tell you anyway.  Set the border style to bsNone and set the caption blank.  The form will just appear as a grey rectangle.  Drop the image on it and set both the image and form to autosize:=true.

It's not the best way, but it does work nicely.

John.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6234201
Hi felonious,
it is not an easy question, really.
It something like combobox dropdown window, right?
You can take a look at my component TDBFieldsGrid, there is a sample how to show ListBox by the meaning way. Pay attension on TConstBox.CreateWnd and  TDBFieldsGrid.ShowConstBox methods.

http://i-g-o-r.virtualave.net/fldgrd.html

------
Igor
0
 
LVL 1

Expert Comment

by:Kaspars
ID: 6234588
I suggest you to use, for example, panel and make it docked with ManualFloat. It will look like just as a tool window but will be focused with the form it belongs to ad is minimized also, when the form is minimized.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:felonious
ID: 6236715
Ok, while everything offered so far had been very interesting, I've either failed to understand it or it doesn't give the desired effect.  

For instance, ManualFloating a panel (never knew this was possible) does give you something that is close to a toolwindow, but again when the panel is clicked on the currently active window (in this case an MDI child form) losses focus.

And I guess I just dont understand windows messages and such enough to comprehend Igor's code.  I checked out the WM_SETFOCUS and WM_KILLFOCUS messages as well as SETFOCUS, and everything else in the CreateWnd procedure but I failed to understand what it does (as I cant compile/install the package in Delphi 6 I can not see the effects on that component).

Again, to restate what I would like:

-A form that *DOES NOT* take the focus away from currently selected window when it is clicked yet the controls on it act normally (OnClick events fire when a control is clicked) (i.e. like Photoshops toolbars.  I can select a tool to use from a toolbar, but the image I am working on always retains focus)
0
 
LVL 9

Accepted Solution

by:
ITugay earned 50 total points
ID: 6237250
Ok, here is another way.

let say you have Form2 that should be toolbar. Set it's property in designtime.
Form2.FormStyle := fsStayOnTop;
Form2.BorderStyle := bsToolWindow;

To show this form without loosing focus on current( main) form do next:

  Form2.Parent := Self;
  Form2.Show;

Your main form will not loose focus, but toolbar window will never get focus, so, some of controls
may not works on toolbar form. (e.g. TEdit.) while TListBox, TComboBox, TButtons etc. still works.

-----
Igor.
0
 

Author Comment

by:felonious
ID: 6237841
This worked very well for me.  I ended up going into the main project file where the application creates the forms and adding in a few lines of code:

  Application.CreateForm(TTBTools, TBTools);
  TBTools.Parent := mainform;
  Application.CreateForm(TTBDetails, TBDetails);
  TBDetails.Parent := mainform;
  Application.CreateForm(TTBItems, TBItems);
  TBItems.Parent := mainform;

Thanks for the help Igor!
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6237857
always wellcome :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now