Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by Andreas Osswald
Wed, 18 Apr 2007 10:02
Foreground another application
Author: Andreas Osswald
Date: Wed, 18 Apr 2007 10:02
Date: Wed, 18 Apr 2007 10:02
17 lines
1475 bytes
1475 bytes
Hello,
I want to bring another app (ext_app) to foreground. I do it like this:
ExtHandle = FindWindow("CalssName","Caption");
PostMessage(ExtHandle,WM_SYSCOMMAND,SC_RESTORE,0);
SetForegroundWindow(ExtHandle);
The minimized ext_app comes to foreground, it works.
But if I want to minimize the ext_app (which was restore/comes to
foreground) it doesn't work. I can click to the minimize button but nothing
happens. I use the system menu but nothing happens too. After I restore the
ext_app by my application I can't minimize the ext_app anymore.
Regards
Andreas
Re: Foreground another application
Author: Bob Gonder
Date: Wed, 18 Apr 2007 13:56
Date: Wed, 18 Apr 2007 13:56
15 lines
1361 bytes
1361 bytes
Andreas Osswald wrote:
>I want to bring another app (ext_app) to foreground. I do it like this:
>
>ExtHandle = FindWindow("CalssName","Caption");
>PostMessage(ExtHandle,WM_SYSCOMMAND,SC_RESTORE,0);
>SetForegroundWindow(ExtHandle);
Try it this way:
if( IsIconic( h ) )
{ ShowWindow( h, SW_RESTORE );
}else{
SetForegroundWindow( h );
};
Re: Foreground another application
Author: Andreas Osswald
Date: Wed, 18 Apr 2007 16:38
Date: Wed, 18 Apr 2007 16:38
29 lines
1809 bytes
1809 bytes
Is doesn't work!
the function IsIconic returns always zero whether the application is
minimized or not.
After I use the ShowWindow function I can't re minimize the application.
regards
Andreas
"Bob Gonder" <notbg@notmindspring.invalid> schrieb im Newsbeitrag
news:sm8c235a13e21geu4lp54r7rorcgee163e@4ax.com...
> Andreas Osswald wrote:
>
>>I want to bring another app (ext_app) to foreground. I do it like this:
>>
>>ExtHandle = FindWindow("CalssName","Caption");
>>PostMessage(ExtHandle,WM_SYSCOMMAND,SC_RESTORE,0);
>>SetForegroundWindow(ExtHandle);
>
> Try it this way:
>
> if( IsIconic( h ) )
> { ShowWindow( h, SW_RESTORE );
> }else{
> SetForegroundWindow( h );
> };
>
>
Re: Foreground another application
Author: Bob Gonder
Date: Wed, 18 Apr 2007 21:51
Date: Wed, 18 Apr 2007 21:51
16 lines
1684 bytes
1684 bytes
Andreas Osswald wrote: >Is doesn't work! > >the function IsIconic returns always zero whether the application is >minimized or not. > >After I use the ShowWindow function I can't re minimize the application. I just rechecked my console app that uses that code. I use EnumWindows(EnumProc,0); to get a list of hwnds that the user can select. I then run that handle through the code I gave, and even restored minimized windows can be minimized again. If that code isn't working for you then either the hwnds aren't the proper ones, or VCL is otherwise screwing with you.
Re: Foreground another application
Author: JD
Date: Fri, 20 Apr 2007 20:55
Date: Fri, 20 Apr 2007 20:55
37 lines
2253 bytes
2253 bytes
"Andreas Osswald" <noname@noname.de> wrote:
>
>I want to bring another app (ext_app) to foreground. I do it like this:
>
>ExtHandle = FindWindow("CalssName","Caption");
>PostMessage(ExtHandle,WM_SYSCOMMAND,SC_RESTORE,0);
>SetForegroundWindow(ExtHandle);
I would expect this to be problematic because you're posting
the restore which IMO will not get processed until after you
have tried to being it to front.
> But if I want to minimize the ext_app (which was restore/comes
> to foreground) it doesn't work. I can click to the minimize
> button but nothing happens. I use the system menu but
> nothing happens too. After I restore the ext_app by my
> application I can't minimize the ext_app anymore.
You can if you right click it's TaskBar Icon and play with it.
The problem is that you're confusing Windows with respect to
the actual window state by minimizing a minimized window or
restoring a restored window.
Bob is correct that you need to use IsIconic and that you're
calling it with the wrong HWND. IsIconic doesn't work with
child windows so you need to call it on the Application's
Handle.
Once you get the Target HWND, add this:
HWND hWnd = reinterpret_cast<HWND>( ::GetWindowLong(TargetHwnd, GWL_HWNDPARENT) );
if( IsIconic(hWnd) ) ::ShowWindow( hWnd, SW_RESTORE );
::SetForegroundWindow( hWnd );
~ JD
Re: Foreground another application
Author: JD
Date: Fri, 20 Apr 2007 20:59
Date: Fri, 20 Apr 2007 20:59
15 lines
1370 bytes
1370 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote: > > [...] or VCL is otherwise screwing with you. For shame, for shame, for shame! Please see my reply to Andreas. I had a very similar problem long ago and posted several times and no one could help. Then one day ... YOU pointed out that IsIconic wants the Application's Handle! Getting too old for this <g> ? ~ JD
Re: Foreground another application
Author: Remy Lebeau (TeamB)
Date: Fri, 20 Apr 2007 21:22
Date: Fri, 20 Apr 2007 21:22
17 lines
1470 bytes
1470 bytes
"JD" <nospam@nospam.com> wrote in message
news:462928d0$1@newsgroups.borland.com...
> HWND hWnd = reinterpret_cast<HWND>( ::GetWindowLong(TargetHwnd,
GWL_HWNDPARENT) );
Use GetParent() instead:
HWND hWnd = ::GetParent(TargetHwnd);
Also, keep in mind that in BDS 2007, the TApplication object no longer
controls the taskbar button. I'm not sure if the TApplication window
is even still the parent for TForm windows anymore.
Gambit
Re: Foreground another application
Author: JD
Date: Tue, 24 Apr 2007 20:58
Date: Tue, 24 Apr 2007 20:58
19 lines
1592 bytes
1592 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > > Use GetParent() instead: Funny ... I do use GetParent else where .... but other than the extra typing, is there any difference? > Also, keep in mind that in BDS 2007, the TApplication object > no longer controls the taskbar button. I'm not sure if the > TApplication window is even still the parent for TForm > windows anymore. I've been diverted time and time again with BCB6 stuff and I'm angry about that! Thanks for the heads-up. I'll look at it as soon as I get BDS installed (which looks like some time after the next BDS is released). ~ JD
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads