Here's some code I used successfully in an onclick of the mainform to switch back and forth from fsStayOnTop:
{ Private declarations } Procedure WMWindowPosChanging(Var Msg: TWMWindowPosMsg); MESSAGE WM_WINDOWPOSCHANGING; Procedure TMainF1.WMWindowPosChanging(Var Msg: TWMWindowPosMsg); Begin Inherited; If StayOnTop = True Then Begin With Msg Do Begin If (WindowPos.flags And SWP_NOZORDER) = 0 Then Begin Result := 0; Windows.SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSENDCHANGING Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE); End; End; End; End; The buttonclick sets the Boolean and changes the button glyph and menu items. I just can't remember why I didn't put this in my action list? <g> But it's still working under XP/sp2...only problem seems to be on the first click which doesn't seem to work, just flash and make the visual changes, but each successive click does work, so I had to kill the visual changes on the first click as well. It was only for my illiterate brother-in-law and he always clicks twice anyway! <g> from "Robert Meek" dba "Tangentals Design" Creative Concepts Programming for Windows Vista E-mail: ffo...@comcast.net "Most people would sooner die than think; in fact, they do so!" [Bertrand Russell 1872-1970] -----Original Message----- From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On Behalf Of Cédric Joubert Sent: Sunday, May 10, 2009 2:45 AM To: Borland's Delphi Discussion List Subject: Re: Problem refreshing Memo of a Form hi, Thanks to you to look at my problem ! Oups sorry...:-) it is just because you need a main form (let's call it FormMain) calling the Form1 with a Show instruction (not Showodal) from a Button (let's call it ButtonMain) on the Main Form. But take a look at the source here if you want : http://www.crawleyscastingcalls.com/temp/test/ and yes, you're right it is TForm1 (not TForm2). So i my example, because of the Stay on Top Form1 above the FormMain form, the Form1.Deactivate event is fired each time you click on the Button1, or when you click on the FormMain form which is below Form1. I work under XP (sp2) with D7. Cédric ----- Original Message ----- From: "Sid Gudes" <s...@piasystems.com> To: "Borland's Delphi Discussion List" <delphi@elists.org> Sent: Saturday, May 09, 2009 5:37 PM Subject: Re: Problem refreshing Memo of a Form I created a small project that has these components and it worked fine in D7 under XP; which version are you using? I note that your OnClick below refereces Tform1, but your OnDeactivate references Tform2. Perhaps the code below doesn't reflect all the code in your project? Also, since the form is change to StayOnTop, the OnDeactivate event never gets fired... At 02:20 AM 5/9/2009, Cédric Joubert wrote: >hi, > >I have a simple question about repainting >controls in a form but this example is maybe simpler to ask my question : > >I have a form with 1 TButton, 1 TEdit and 1 TMemo. > > the text 'Edit1' is displayed in TEdit.text > the text 'Memo1' is displayed in the first line of TMemo > >In my code Button1.OnClick i have just 2 lines : > >procedure TForm1.Button1Click(Sender: TObject); >begin > FormStyle := fsNormal; > FormStyle := fsStayOnTop; >end; > >In my TForm.OnDeactivate i have just this line : > >procedure TForm2.FormDeactivate(Sender: TObject); >begin > Memo1.Lines.Add('deactivate'); >end; > > >Question : when i launch my form I see the 2 >text "Edit1" and "Memo1" correctly displayed. >Then when I click on the button, the "Edit1" >text stay right displayed in TEdit >but the text of TMemo is erased, why ? > >TEdit and TMemo have exactly the same priciapl >heritance hierarchy...(TWincontrol... TPersistent...). > >Anyone can help me ? > >Cédric > > >_______________________________________________ >Delphi mailing list -> Delphi@elists.org >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi Regards, Sid Gudes PIA Systems Corporation sid.gu...@piasystems.com _______________________________________________ Delphi mailing list -> Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi