Difference between revisions of "SetWindowTopMost"

From SCAR Divi Manual
Jump to: navigation, search
m (Freddy moved page SetOnTop to SetWindowTopMost)
 
Line 1: Line 1:
 
==Definition==
 
==Definition==
 
<source lang="scar" lines="false">
 
<source lang="scar" lines="false">
procedure SetOnTop(Window: Integer; Top: Boolean);
+
procedure SetWindowTopMost(const Wnd: Hwnd; const TopMost: Boolean);
 
</source>
 
</source>
  
 
===Source Code===
 
===Source Code===
 
<source lang="scar">
 
<source lang="scar">
procedure SetOnTop(Window: Hwnd; Top: Boolean);
+
procedure SetWindowTopMost(const Wnd: Hwnd; const TopMost: Boolean);
 
begin
 
begin
   if Window <> 0 then
+
   if IsWinfow(Window) then
 
     if Top then
 
     if Top then
 
       SetWindowPos(Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
 
       SetWindowPos(Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
Line 17: Line 17:
  
 
==Availability==
 
==Availability==
SCAR Divi 3.12 > Current
+
SCAR Divi 3.35 > Current
 +
 
 +
===Aliases===
 +
*SetOnTop (SCAR Divi 3.12 > 3.34)
  
 
==Description==
 
==Description==
This function adds the HWND_TOPMOST flag to a window specified by it's handle '''Window''' if '''Top''' is [[true]]. If '''Top''' is [[false]], it will add the flag HWND_NOTOPMOST.
+
Adds the HWND_TOPMOST flag to a window specified by it's handle '''Wnd''' if '''TopMost''' is [[true]], this will move the window in the topmost position on your desktop. If '''TopMost''' is [[false]], it will add the flag HWND_NOTOPMOST, which will remove the window from it's topmost position. The function will only work on windows outside of the SCAR process which is running the script.
  
 
===Internal Flags<ref>[http://msdn.microsoft.com/en-us/library/ms633545%28v=vs.85%29.aspx SetWindowPos at MSDN]</ref>===
 
===Internal Flags<ref>[http://msdn.microsoft.com/en-us/library/ms633545%28v=vs.85%29.aspx SetWindowPos at MSDN]</ref>===
Line 28: Line 31:
 
==Example==
 
==Example==
 
<source lang="scar">
 
<source lang="scar">
 +
var
 +
  Wnds: THwndArray;
 +
 
begin
 
begin
   SetOnTop(GetClientWindowHandle, True);
+
   Wnds := FindWindowsEx(GetDesktopWindow, 'notepad', '', False, False, True); 
 +
  if Length(Wnds) > 0 then
 +
    SetWindowTopMost(Wnds[0], True);
 
end.
 
end.
 
</source>
 
</source>
  
 
==See Also==
 
==See Also==
*[[SetClientPos]]
+
*[[IsWindowTopMost]]
  
 
==References==
 
==References==

Latest revision as of 12:18, 7 August 2012

Definition

procedure SetWindowTopMost(const Wnd: Hwnd; const TopMost: Boolean);

Source Code

procedure SetWindowTopMost(const Wnd: Hwnd; const TopMost: Boolean);
begin
  if IsWinfow(Window) then
    if Top then
      SetWindowPos(Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
    else
      SetWindowPos(Window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;

Availability

SCAR Divi 3.35 > Current

Aliases

  • SetOnTop (SCAR Divi 3.12 > 3.34)

Description

Adds the HWND_TOPMOST flag to a window specified by it's handle Wnd if TopMost is true, this will move the window in the topmost position on your desktop. If TopMost is false, it will add the flag HWND_NOTOPMOST, which will remove the window from it's topmost position. The function will only work on windows outside of the SCAR process which is running the script.

Internal Flags[1]

  • HWND_TOPMOST: Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
  • HWND_NOTOPMOST: Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.

Example

var
  Wnds: THwndArray;
 
begin
  Wnds := FindWindowsEx(GetDesktopWindow, 'notepad', '', False, False, True);  
  if Length(Wnds) > 0 then
    SetWindowTopMost(Wnds[0], True);
end.

See Also

References

<references>