Solved

AlwaysOnTop form and hook

Posted on 2007-04-11
4
370 Views
Last Modified: 2010-04-05
Hello!

I have a problem, but i didn't find any solution on the Internet.
The problem is the following. I have a stayontop window (created by me) and i want to keep it
always on top over other desktop windows but !!! not over popup menus (like right click context menus), file menus (e.g. File-Edit-Settings...), and dropdown lists. If a window is created with WS_POPUP or WS_POPUPWINDOW style flag then my window can't stay on top. I tried to use a hook but wont work...because i don't know how can i draw a distinction between a real popup window and a standard window created with WS_POPUP or WS_POPUPWINDOW flag...


if PCWP^.Message = WM_WINDOWPOSCHANGING or WM_WINDOWPOSCHANGED then
begin

//stayontopform is my window
if PCWP^.hwnd<>FindWindow(nil,'stayontopform') then
  begin
      if (GetWindowLong(PCWP.hwnd, GWL_EXSTYLE) and WS_EX_TOPMOST) <> 0 then
      begin
      Style:=GetWindowLong(PCWP^.hwnd, GWL_STYLE);

      //if not WS_POPUP
      if ((Style and WS_POPUP or WS_POPUPWINDOW or WS_SYSMENU)=0) then
      SetWindowPos(PCWP^.hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE + SWP_NOMOVE);

      //if has menu
      if ((HMenu(GetMenu(PCWP^.hwnd))<>0) and (SendMessage(PCWP^.hwnd,LB_SETCOUNT,0,0)=0)) then
      SetWindowPos(PCWP^.hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE + SWP_NOMOVE);

      //if has system menu
      if (HMenu(GetSystemMenu(PCWP^.hwnd,false))<>0) then
      SetWindowPos(PCWP^.hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE + SWP_NOMOVE);

      //if has captionbar
      if ((Style and WS_CAPTION)=WS_CAPTION) then
      SetWindowPos(PCWP^.hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE + SWP_NOMOVE);

     end;
  end;
end;

    Result:=CallNextHookEx(MyHook, pCode, pHandle, pWindow);
end;



Is there any difference between these windows? For example a system message that's applicable for a
real popup (right click menus, file menus, dropdown lists) and not for a standard desktop window?
(or vice versa)

Thanks in advance!
0
Comment
Question by:rogerrr
4 Comments
 
LVL 5

Accepted Solution

by:
xr1140 earned 125 total points
ID: 18893669

maybe i haven`t understood your problem but .... by default popup menus are drawn over onTop windows
0
 
LVL 16

Assisted Solution

by:CodedK
CodedK earned 125 total points
ID: 18897938
I have a problem like that with a custom ontop form.
I've noticed the following :

In my form i have a pop up menu.
When i pop up my form menu and close it...
Then EVERY other pop up menu sit above my form without a problem !

So if you don't find something to work with just fire up a Pop-up menu once, when the form loads.
Hope this will help.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21156552
Forced accept.

Computer101
EE Admin
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question