Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AlwaysOnTop form and hook

Posted on 2007-04-11
4
Medium Priority
?
376 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 500 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 500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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