![]() |
#1
|
|||
|
|||
![]()
This has been asked before, and many answers given. But never one I needed, so here goes:
When you look at photoshop, and it's toolwindows. Then you will find the Main window does not <cb>seem</cb> to loose focus when you click on any toolwindow, even though they are not mdi-children! In fact, all toolwindows are colored dark blue like the main window (windows xp standard window layout) (So all windows from photoshop that are toolwindows have the activeborder color/look) When I make an application and add forms with borders like toolwindows, I can perfectly mimic the photoshop exterior except the active colors -> <cr>I'm only able to have one tool window or the main window seem focussed</cr> My question(s): - How do I make the main window of my app always seem to be active (having the activebordercolor) as long as any window belonging to the app is focussed. - How do I have every toolwindow seem active all the time as well, as long as any window from my application has focus. So I know I can only have one form focussed at the time. Adobe Photoshop makes it seem it has all those windows focussed, and uses some windows paint method, cause it works just fine for every XP-theme. Anybody??? -RwD ps, please accept ![]() |
#2
|
|||
|
|||
![]()
Hi :-)
The simplest way to me it seems, is to remove the form's own caption bar and replace it with a TPanel. Some sample code, created with Delphi3. Form1 is the main form , Form2 will be the ToolTip window. <ct> unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ToolWin, StdCtrls, ExtCtrls, Buttons; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } procedure ApplicationDeactivate (Sender : tObject); procedure ApplicationActivate (Sender : tObject); public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin Form2.Show; end; procedure TForm1.FormCreate(Sender: TObject); begin Application.OnDeactivate:=ApplicationDeactivate; Application.OnActivate:=ApplicationActivate; end; procedure TForm1.ApplicationDeactivate (Sender : tObject); begin //when the application loses focus //if Form2 is not on the Auto-Create list, you must make sure to add code to check if the Form exists Form2.Panel1.Color := clInActiveCaption; end; procedure TForm1.ApplicationActivate (Sender : tObject); begin //when the application regains focus Form2.Panel1.Color := clActiveCaption; end; end. </ct> now for Form2, the sample tooltip window: <ct> unit Unit2; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls; type TForm2 = class(TForm) Panel1: TPanel; SpeedButton1: TSpeedButton; procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure SpeedButton1Click(Sender: TObject); procedure FormResize(Sender: TObject); private { Private declarations } public { Public declarations } procedure CreateParams(var Params: TCreateParams); override; end; var Form2: TForm2; implementation {$R *.DFM} //remove the caption bar procedure TForm2.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); with Params do Style:=(Style or WS_POPUP) and (not WS_DLGFRAME); end; //move the form when dragging the panel procedure TForm2.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbLeft then begin ReleaseCapture(); SendMessage(Handle, WM_SYSCOMMAND, $F012, 0); end; end; procedure TForm2.SpeedButton1Click(Sender: TObject); begin Close; end; procedure TForm2.FormResize(Sender: TObject); begin SpeedButton1.Left:=Form2.Width-SpeedButton1.Width-10; end; end. </ct> and the dfm for Form2: object Form2: TForm2 Left = 200 Top = 114 Width = 544 Height = 375 Caption = 'Form2' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] <cb> FormStyle = fsStayOnTop</cb> OnResize = FormResize PixelsPerInch = 96 TextHeight = 13 object Panel1: TPanel Left = 0 Top = 0 Width = 536 Height = 22 <cb> Align = alTop </cb> Caption = 'Form Caption' Color = clActiveCaption Font.Charset = DEFAULT_CHARSET Font.Color = clYellow Font.Height = -16 Font.Name = 'MS Sans Serif' Font.Style = [fsBold] ParentFont = False TabOrder = 0 OnMouseDown = Panel1MouseDown object SpeedButton1: TSpeedButton Left = 514 Top = 2 Width = 19 Height = 17 <cb> Caption = 'r' </cb> Font.Charset = SYMBOL_CHARSET Font.Color = clWindowText Font.Height = -11 <cb> Font.Name = 'Marlett'</cb> Font.Style = [fsBold] ParentFont = False OnClick = SpeedButton1Click end end end Also see this previous topic, http://www.delphipages.com/threads/thread.cfm?ID=61974&G=61846 Hope this helps! |
#3
|
|||
|
|||
![]()
I might not have been specific enough:
The photoshop toolwindows change with the theme you use, they always have the before mentionedbehaviour, but always look like the toolwindow from the theme you're using. HTML: Thanks for the help, but... Your solution doesn't do the above, and even only repainting the panel in the right theme, doesn't do the trick because you need window borders too, since they change with themes. (I have no idea how to piant the panel like the toolwindow border of the current theme to begin with) I also read all threads comming up using the keyword 'toolwindow'. One thing I found out: I am sure photoshop uses it's own repaint methods for the border, since it visibly repaints when I move some other window on top of it. And normal toolwindows do not flicker (what I named repainting) when you move something over them. (besides, normal toolwindows don't have minimize buttons. So they did something with it for sure) -RwD ps, please accept ![]() |
#4
|
|||
|
|||
![]()
I don't think you are going to find an easy answer to this question. HTML is probably correct in that they are painting it themselves. You will need to figure out a way to paint the window like the current theme.
One possible solution would be to do a screen capture of a normal window and then cut up that bitmap to create the elements of the tool windows. -Jim If this helps then please "<cr>Accept as Answer</cr>" |
#5
|
|||
|
|||
![]()
Use FloatingWindow from DelphiPages.
<cr>NEW!</cr> http://www.organizermp3.com (21.Apr.2003) http://softlock.organizermp3.com (23.Nov.2002) |
#6
|
|||
|
|||
![]()
and how do you determine the toolwindow variant from that screen capture? And if you meant doing it by hand: that is ofcourse not right, it has to work on every computer, no matter what the theme.
I consider this answer as an idea in the right direction, but I'm afraid it is not quite the answer, sorry =P ps, I'd already conlcluded they drew it themelves ![]() I do think a lot of people would like a component or form thing that accomplishes this. So I will try to find the way to do it, but would still like help ![]() -RwD ps, please accept ![]() |
#7
|
|||
|
|||
![]()
Cool thing, but I'm affraid it is as the solution opted by HTML, roughly put; not what I asked
thanks though, I might use this in something else I am working on ![]() -RwD ps, please accept ![]() |
#8
|
|||
|
|||
![]()
Sorry RwD. I was thinking of Photoshop6, which if I remember correctly doesn't seem to color the toolwindows with the WinXP theme? On the other hand Photoshop7 seems to do what you describe.
I think I got the solution, please wait just a few minutes folks ;-) let's see what happens. |
#9
|
|||
|
|||
![]()
Hello again.
Hope I got it right this time. As I've learned you can send a Form a WM_NCACTIVATE message to make the form draw itself as it would in a active or focused state. Again Form1=MainForm and Form2=ToolWindow unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); private procedure ApplicationDeactivate (Sender : tObject); procedure ApplicationActivate (Sender : tObject); { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin Form2.Show; end; procedure TForm1.FormActivate(Sender: TObject); begin //still make the tooltip form appear as it has focus SendMessage(Form2.Handle, WM_NCACTIVATE, WPARAM(1), LPARAM(0)); end; procedure TForm1.FormCreate(Sender: TObject); begin Application.OnDeactivate:=ApplicationDeactivate; Application.OnActivate:=ApplicationActivate; end; procedure TForm1.ApplicationDeactivate (Sender : tObject); begin //remove the focused coloring for the forms SendMessage(Application.MainForm.Handle, WM_NCACTIVATE, WPARAM(0), LPARAM(0)); SendMessage(Form2.Handle, WM_NCACTIVATE, WPARAM(0), LPARAM(0)); end; procedure TForm1.ApplicationActivate (Sender : tObject); begin //set back the focused coloring for the forms SendMessage(Application.MainForm.Handle, WM_NCACTIVATE, WPARAM(1), LPARAM(0)); SendMessage(Form2.Handle, WM_NCACTIVATE, WPARAM(1), LPARAM(0)); end; end. unit Unit2; //Form2 properties set //FormStyle = fsStayOnTop //BorderStyle = bsToolWindow interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Button1: TButton; procedure FormActivate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.DFM} procedure TForm2.FormActivate(Sender: TObject); begin //make the main form still appear as it has focus SendMessage(Application.MainForm.Handle, WM_NCACTIVATE, WPARAM(1), LPARAM(0)); end; end. |
#10
|
|||
|
|||
![]()
Close enough!!
I think your solution is even beter then adobes solution. That is, as long as you don't need a minimize button. (and I don't need one) Thanks!!! -RwD ps, please accept ![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|