Solved

Disabling all application windows

Posted on 2001-06-26
12
190 Views
Last Modified: 2013-12-03
Hi there,

As part of a project, I'm writing a C/C++ Win32 API DLL which is hosted by a third-party application.

My DLL needs to present a modal dialog (whether it's a std. Windows "GetSaveFileName" or my own dialog).
The dialog needs to be modal, at least in the host application (disabling all windows, palette, dialog currently in the application).

So far, so good.

Now comes the tricky part.
When my dialog is open, I can't get the application windows to be disabled.

Any simple C/C++ code to do this?

Thanks
0
Comment
Question by:roov
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 6

Expert Comment

by:MichaelS
ID: 6228028
May be you can take a look at WM_ACTIVATE and when you get it just activate your window again?
0
 
LVL 2

Author Comment

by:roov
ID: 6228097
I need to disable all the third-party application windows, and can't easily know their state.
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6228145
Not sure that you will be able to do that. What is the problem with just not allowing all othe windows to become an active window?
0
 
LVL 2

Author Comment

by:roov
ID: 6228231
If I leave the other application windows active, the user will be able to continue working in the application, and I realy don't want that to happen.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6230191
EnumWindows will give you a list of all windows that you should disable. Please disable only those which are not disabled already (use IsWindowEnabled for this purpose). Please remember all windows, which you disabled, you have to enable them after you're done again.

Sorry, no C++ code, I'm a Delphi programmer...   :-)

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6230195
P.S: Perhaps you should only disable the windows in the current process. Use GetWindowThreadProcessID to get the processID of each window, then disable only those windows, which have the same processID as you have (GetCurrentProcessID).
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 2

Author Comment

by:roov
ID: 6230223
OK - Madshi's idea seems to be getting warmer, in the right direction.
Yet, the one problem I faced with that line of thoughts was how to determine from the EnumWindows callback function, which recives as input HWND and void*, to which process a given window (HWND) belongs...
Any thoughts?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6230336
Yeah, as I said, use GetWindowThreadProcessID(hwnd, &pid) to get the processID to which the window belongs and compare that to GetCurrentProcessID.
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6230345
>If I leave the other application windows active, the user will be able to continue working in the application

As I propose you leave the rest of the windows not active, you leave them "not active" but also "not disabled". When your window is about to loose focus than you just prevent it. Something like (code is pceudo):

OnWmActivation()
{   if(!bCanClose)
        SetActiveWindow(this);
}

OnWmClose()
{    bCanClose = true;
}

About approach from Madshi:
You also have to monitor new windows and disable tham, not only existing at the time your window is comming up.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6230356
>> You also have to monitor new windows and disable tham, not only existing at the time your window is comming up.

But usually windows do only pop up as a reaction to user activity. If you have disabled all windows of the current process, it's unprobable that new windows will pop up. But you're right. If you want to have it perfect, you also would have to watch for new windows...
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6230363
>usually windows do only pop up as a reaction to user activity

yep, 100% agree :)
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 7229691
This question will be placed in PAQ.

Regards,

ComTech
Community Support
Administrator @ EE
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

13 Experts available now in Live!

Get 1:1 Help Now