Create a Photoshop floating window application has not written blog in some days, and give it a one. Friends who have used Photoshop must have a convenient floating panel for it. In fact, these panels are a small form, but these small forms are placed on Photoshop's main form (not existing main forms. ), Have your own title bar, minimize buttons and maximize buttons. However, they differ from the MDI program that they can drag to the main window, more importantly, all of these panel forms and main forms are at most active. Use Spy & Capture to find out that it is not difficult to find that the Parent Window of these panel forms is the main form of Photoshop (as an example of Photoshop Cs, the main form of Handle is 001906D8, all panel Parent Window points to 001906D8) And the pealth of the form we created is for NONE. The following code is demonstrated for this Photoshop floating window: //...... Var Form1: TFORM1;
IMPLEMentation
Uses unit2;
{$ R * .dfm}
procedure TForm1.Button1Click (Sender: TObject); begin // Parent is changed to the Form2 Form1 Form2: = TForm2.CreateParented (Form1.Handle); Form2.Show; // such active Form2 the SendMessage (Form2.Handle, WM_NCACTIVATE , ORD (TRUE), 0);
Procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT); Begin Form2.Close;
Procedure TFORM1.FORMDESTROY (Sender: Tobject); Begin // Remember to add this sentence if form2.showing the form2.close;
The code above can display FORM2 that is active with Form1, and then makes some necessary choices for Form2's BorderStyle and Bordericons properties, you can achieve a more perfect effect!
Someone asked me that the form2 generated by the above code cannot move out of Form1, because Form2.Parent is specified as Form1.
To remove the main form as a Photoshop panel, I think of the way to do:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class (TForm) btn1: TButton; btn2: TButton; edt1: TEdit; mmo1: TMemo; procedure FormDeactivate (Sender: TObject); procedure btn1Click (Sender: TObject); procedure btn2Click (Sender: TObject); procedure FormCreate (Sender: TObject); procedure SetAllFormsActivate (Sender: TObject); procedure SetAllFormsDeactivate (Sender: TObject); private {Private declarations } public {public declarations} end; var Form1: TForm1; implementation uses Unit2, Unit3; {$ R * .dfm} procedure TForm1.SetAllFormsActivate (Sender: TObject); var i: Integer; begin for i: = 0 to Application. ComponentCount - 1 do begin if Application.Components [i] is TForm then SendMessage (. TForm (Application.Components [i]) Handle, WM_NCACTIVATE, Ord (True), 0); end; end; procedure TForm1.SetAllFormsDeactivate (Sender: TOBJECT); VAR i: integer; begin for i: = 0 to Application.comPonentcount - 1 Do Begin if Application.Components [i] IS TFORM THEN SENDMESSAGE (TForm (Application.Components [i]). Handle, WM_NCACTIVATE, ORD (FALSE), 0); End; End; Procedure TFORM1. FormDeactivate (Sender: TObject); begin if Application.Active then SendMessage (Handle, WM_NCACTIVATE, Ord (True), 0); end; procedure TForm1.btn1Click (Sender: TObject); begin form2.Show; end; procedure TForm1.btn2Click (Sender: TObject); begin Form3.Show; end; procedure TForm1.FormCreate (Sender: TObject); begin Application.OnDeactivate: = SetAllFormsDeactivate; Application.OnActivate: = SetAllFormsActivate; end; end additional Form:. procedure TForm2.FormDeactivate Sender: TOBJECT;