[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Disabling all application windows

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
roov
Asked:
roov
  • 4
  • 4
  • 3
  • +1
1 Solution
 
MichaelSCommented:
May be you can take a look at WM_ACTIVATE and when you get it just activate your window again?
0
 
roovAuthor Commented:
I need to disable all the third-party application windows, and can't easily know their state.
0
 
MichaelSCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
roovAuthor Commented:
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
 
MadshiCommented:
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
 
MadshiCommented:
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
 
roovAuthor Commented:
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
 
MadshiCommented:
Yeah, as I said, use GetWindowThreadProcessID(hwnd, &pid) to get the processID to which the window belongs and compare that to GetCurrentProcessID.
0
 
MichaelSCommented:
>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
 
MadshiCommented:
>> 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
 
MichaelSCommented:
>usually windows do only pop up as a reaction to user activity

yep, 100% agree :)
0
 
ComTechCommented:
This question will be placed in PAQ.

Regards,

ComTech
Community Support
Administrator @ EE
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now