FormStyle = fsStayOnTop
I am also wondering this as I need to have OnTaskbar set to False so I am hoping that is not a requirement. My example macro below sets OnTaskBar to False and it still seems to work fine.JRL wrote:Do you need to set OnTaskbar to True for fsStayOnTop to work? I tried your sample without OnTaskbar set to True and it seemed to work.
Rain, your method seemed to solve another problem for me. I have a stay-on-top dialog with an Edit field. With my old code, the cursor blinks in the Edit field whether or not the Dialog itself has keyboard focus. This is confusing to a user as a blinking cursor usually indicates that when you type, the chars will show up there... but without keyboard focus on the actual dialog, those chars are going to some other window.
Using your method, it automatically takes care of that blinking cursor in the Edit field... if the dialog does not have keyboard focus, no blinking cursor... when it has keyboard focus, the blinking cursor appears... this is exactly what I was looking for. All is fine... running uncompiled.
However when I compile it, the dialog will not stay on top. So I went back to using JRL's trick of continually getting the window's position and then moving it to where it already is... in the idle loop... and yes, it makes the dialog say on top... but it also brings the blinking cursor back in the Edit field... even when the dialog itself does not have keyboard focus:
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 251
Top = 97
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Dialog Stay On Top Example'
ClientHeight = 77
ClientWidth = 213
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 8
Width = 172
Height = 13
Caption = '1. Set the FormStyle to fsStayOnTop'
end
object Edit1: TEdit
Left = 46
Top = 37
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,,OnClose,Exit
Show>Dialog1
Label>Loop
wait>.01
//If macro is compiled, the dialog will not Stay On Top
//unless we also add the following two lines (JRL's trick)
GetWindowPos>Dialog Stay On Top Example,X,Y
MoveWindow>Dialog Stay On Top Example,X,Y
Goto>Loop
SRT>Exit
Exit>1
END>Exit