Solved

AlwaysOnTop form and hook

Posted on 2007-04-11
4
365 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now