Solved

AlwaysOnTop form and hook

Posted on 2007-04-11
4
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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