Re: BringWindowToTop: "Simulate" "ALT-Tab" keys

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for your Simulation of the ALT-tab keys. It seems that noone knows
how ALT-tab functions to simulate this.

Ok, let me explain my problem more clearly.

Application A is a dialog bases application, using the full screen display.
Application B is an exe-file, I think it's written in VB, but don't know. I
don't have the source. The only thing I can do with the application, is get
it's window handle with a registered Windows message and then send some
well-defined messages and get answers via OnCopyData.

Now application A starts application B:

STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
GetStartupInfo(&startupInfo);
bOk = CreateProcess("C:\Programme
Files\AppB\AppB.exe",NULL,NULL,NULL,TRUE,0,NULL,NULL,
&startupInfo,&processInfo);

And then asks for the window handle with PostMessage, Application B answers
via an afx_msg function in application A.

In application A I can now minimize and maximize application B with
SendMessages. If I do this, the application B is first minimized, then
maximized again, but not repainted on the screen, so I don't see the
application B in front of my application A. With SetForegroundWindow and
other Win32 API calls, don't effect application B.
Only when I use the ALT-tab key and select application B, it is shown on top
of the screen and repainted, so I can work with. I have not found out, which
function calls I must execute to get the same result, bringing it to the top
and forcing it to repaint. Bringing it to the top with SetForegroundWindow
functions, but not the repaint (I tried RedrawWindow,UpdateWindow). Making
application B topmost with SetWindowPos(handle,HWND_TOPMOST,...) has no
effect like all the other Win32 API functions.

So what can I do?

Regards, Guido



"AliR (VC++ MVP)" <AliR@xxxxxxxxxxxxx> schrieb im Newsbeitrag
news:BAl2i.6369$H_.2865@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Alt-Tab is not the answer but here is how to simulate it

void SimulateAltTab()
{
INPUT Inputs[4];
memset(Inputs,0,sizeof(INPUT)*4);

Inputs[0].type = INPUT_KEYBOARD;
Inputs[0].ki.wVk = VK_MENU;

Inputs[1].type = INPUT_KEYBOARD;
Inputs[1].ki.wVk = VK_TAB;

Inputs[2] = Inputs[1];
Inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;

Inputs[3] = Inputs[0];
Inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;

UINT Ret = SendInput(4,Inputs,sizeof(INPUT));
}

If you can describe your problem a little more clearer then maybe someone
can recommend a good solution.

A clear description would be something like:

Application A is a Dialog based application
Application B is an SDI application

Application B gets window handle to application A's main window.

and so on....

AliR.

"Guido Franzke" <guidof73@xxxxxxxx> wrote in message
news:eGebr%23wlHHA.3736@xxxxxxxxxxxxxxxxxxxxxxx
So I tried your hints with your order of the calls. Does not work in my
project.

My dialog starts the second application with CreateProcess(). Then I
send
a
message to the process and it gives me its HWND.
I can do whatever I like with the handle. Neither ::UpdateWindow,
::RedrawWindow nor the couple SetForeground--BringToTop-SetActive make
the
application repaint. SetForeground is ok, because it lets the app stay
at
the top, but since it never repaints, my dialog stays in front (when I
click
the mouse, I click in my dialog, so it comes active to the top).

So there's no description of the "ALT-tabulator" key behaviour?

Is it possible to do something with the process handle that I get from
CreateProcess(), so that I can repaint the application window with it?

Thanks and regards,
Guido






"AliR (VC++ MVP)" <AliR@xxxxxxxxxxxxx> schrieb im Newsbeitrag
news:Eal2i.6361$H_.3026@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
No need to post a new message, there are people answering in your
original
post.

I had this same problem when I was writting my OLE drag and drop
example.
(See COleDragAndDropListBox::ActivateWindow)
http://www.codeproject.com/combobox/oledragdroplistbox.asp

What I did was I made sure I call

SetForegroundWindow();
BringWindowToTop();
SetActiveWindow();

in that order on the main window of the application. That does it for
me
everytime.

On other thing to concider is that the order that you restore your
windows
is also important. I am not sure which application is controling
which,
but
if the one in the background is controlling the fullscreen one, then it
needs to tell the fullscreen one to maximize before the small one gets
maximized, otherwise this might happen:
Small application gets maximized, and you call SetForgroundWindow, then
the
fullscreen window gets maximized.

Ali

"Guido Franzke" <guidof73@xxxxxxxx> wrote in message
news:e4oYuNwlHHA.588@xxxxxxxxxxxxxxxxxxxxxxx
Hello NG,

so I still have the problem, that I have a CDialog occupying the
total
screen (without Windows style, but not topmost), and in it a second
programme, of which I only have the HWND.
In my dialogue, one can maximize and minimize the second programme to
show
or hide the application. It's the same functionality like the normal
Windows
system menu.

After the second programme has started, it is in the foreground. When
in
my
dialog I switch the second programme (minimize and then maximize),
the
programme does not repaint itself. I tried BringWindowToTop(hwnd) and
SetForegroundWindow(hwnd) and SetWindowPos(hwnd, HWND_TOPMOST,...)
and
SetActiveWindow(hwnd), but the programme stays unpainted i.e. hidden.
When
I
force the programme to popup a warn message, I can see that the
programme
is
in the foreground - I see its popup window, but not the whole
background
of
the programme. Is this possible?

Ok, if I use the Windows keys "ALT-Tab", I can bring the second
programme
to
the top and it is repainted.
My question: Is it possible to programme the behaviour of "ALT-Tab"
in
my
dialog, so that I can show the second programme?

Thanks in advance,
Guido










.



Relevant Pages

  • Re: Problems hiding the main form and displaying only a tray icon
    ... > I want my application to run most of the time as just an notify icon> visible in the system tray, with some dialogs windows that open if the> user selects an option from the context menu on the tray icon. ... It was all fine until I noticed that the> form was visible in the Alt-Tab menu and once you had alt-tabbed to it> there was no way of hiding it again:(> ... > But today I have noticed that now I can no longer minimize or hide the> form it appears as a minizied tool window in the bottom left of my desktop> when the application is running and even worse if the user double clicks> on the title bar the window expands to its normal size, apart from the> form is empty and there's no way to minimize it again! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Autorun/fly issue
    ... This happen to me sometimes while I alt-tab. ... stops as soon as I do and doesn't start again until I maximize the ... window again. ... Eilnich (70 Blood Elf Warlock) ...
    (alt.games.warcraft)
  • Re: BringWindowToTop: "Simulate" "ALT-Tab" keys
    ... Application B gets window handle to application A's main window. ... so that I can repaint the application window with it? ... one can maximize and minimize the second programme to ... After the second programme has started, ...
    (microsoft.public.vc.mfc)
  • Re: Z-order
    ... "Kathea Banshou" ... > Alt-tab cycles through ALL open documents/programs. ... > window you are using rather than the main window, ... >> I am having a terrible time with XP's Z order. ...
    (microsoft.public.windowsxp.newusers)
  • Re: JDK 1.6 and JFrame icon
    ... for the main window is not displaying under Windows when using Alt-Tab. ... I does display fine in the window itself and in the task bar, but not when I use Alt-Tab. ... Maybe a bug related to the new 1.6 feature which allows you to specify multiple icon images. ...
    (comp.lang.java.gui)