Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   [WinApi] How to raise program from background? (http://www.velocityreviews.com/forums/t744958-winapi-how-to-raise-program-from-background.html)

Szyk 03-11-2011 07:05 PM

[WinApi] How to raise program from background?
 
Hi

I want to write text editor. So at the very begining I must send command
line parameters to running program in the case it is already running. I
do this by local socket. But I have problem with raising my app from
background to foreground and set focus on it. I write my app under
Windows 7 32bit and use Qt library. There are functions:
QWidget::raise() and QWidget::activateWindow() which should do what I
want, but they only cause blinking app icon on task bar. I asked about
this at Qt Centre, and they give me WinApi solution, but it does not
work in the case when program is NOT minimized.

How to raise my program from background to foreground with WinApi?


thanks
Szyk

Victor Bazarov 03-11-2011 07:18 PM

Re: [WinApi] How to raise program from background?
 
On 3/11/2011 2:05 PM, Szyk wrote:
> I want to write text editor. [..] But I have problem with raising my app from
> background to foreground and set focus on it. I write my app under
> Windows 7 32bit and use Qt library. There are functions:
> QWidget::raise() and QWidget::activateWindow() which should do what I
> want, but they only cause blinking app icon on task bar. I asked about
> this at Qt Centre, and they give me WinApi solution, but it does not
> work in the case when program is NOT minimized.
>
> How to raise my program from background to foreground with WinApi?


People in a Windows programming newsgroup should know. Here we talk C++
language, not WinAPI, sorry.

V
--
I do not respond to top-posted replies, please don't ask

Alf P. Steinbach /Usenet 03-11-2011 08:58 PM

Re: [WinApi] How to raise program from background?
 
* Szyk, on 11.03.2011 20:05:
> Hi
>
> I want to write text editor. So at the very begining I must send command line
> parameters to running program in the case it is already running. I do this by
> local socket. But I have problem with raising my app from background to
> foreground and set focus on it. I write my app under Windows 7 32bit and use Qt
> library. There are functions: QWidget::raise() and QWidget::activateWindow()
> which should do what I want, but they only cause blinking app icon on task bar.
> I asked about this at Qt Centre, and they give me WinApi solution, but it does
> not work in the case when program is NOT minimized.
>
> How to raise my program from background to foreground with WinApi?


Please tell the group how you arrived at this question.

I have seen so many questions like this, always from someone anonymous. "how do
I display a *message box* using the Windows API?". There are many more ways to
do it than using the MessageBox API function, but the fact that the question
includes wording almost identical to the most well-known related API function,
makes it clear that somehow the question was constructed to arrive at a specific
single answer.

So, how/where did your such question originate?

Did you start with the name of the API function?

Or is this a homework question (where you teacher started with the API function)?

If, against all expection, it is a real question, then what prevented you from
googling or accessing your local documentation?

And, also in the case of real question, why do you think others should do the
documentation look-up for you, i.e. why is *your* time more valuable than ours?

And why are you posting in an off-topic newsgroup?



Cheers, and thanks in advance for answers to all of the above,

- Alf

--
blog at <url: http://alfps.wordpress.com>

Geoff 03-12-2011 12:44 AM

Re: [WinApi] How to raise program from background?
 
On Fri, 11 Mar 2011 20:05:53 +0100, Szyk <szyk100@o2.pl> wrote:

>
>How to raise my program from background to foreground with WinApi?


Question is OT for this group.

The answer is documented in the in the Windows API documentation that
comes with your development toolset.

Öö Tiib 03-12-2011 01:26 AM

Re: How to raise program from background?
 
On Mar 11, 10:58*pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
+use...@gmail.com> wrote:
> * Szyk, on 11.03.2011 20:05:
>
> > Bla-blah, QT, bla-blah Windows 7.

>
> Please tell the group how you arrived at this question.


Oh, but it is Szyk, he is a spy master. He uses usenet to spread
encoded commands to his agents who are writing software for US
government. Reading comp.lang.c++ is not considered suspicious
activity of them. The questions sure look idiotic for real specialists
but have been very carefully crafted. ;)

RaZiel 03-12-2011 01:52 AM

Re: [WinApi] How to raise program from background?
 
On 11.03.2011 20:05, Szyk wrote:
> Hi
>
> I want to write text editor. So at the very begining I must send command
> line parameters to running program in the case it is already running. I
> do this by local socket. But I have problem with raising my app from
> background to foreground and set focus on it. I write my app under
> Windows 7 32bit and use Qt library. There are functions:
> QWidget::raise() and QWidget::activateWindow() which should do what I
> want, but they only cause blinking app icon on task bar. I asked about
> this at Qt Centre, and they give me WinApi solution, but it does not
> work in the case when program is NOT minimized.
>
> How to raise my program from background to foreground with WinApi?
>
>
> thanks
> Szyk


You should realize the question is OT. But I'll give you a hint, since
the answer you're looking for is not common knowledge nor documented
anywhere in the API docs. Here it is: "Stealing focus" +
AttachThreadInput. Other solutions will not work on all 3 platforms (XP,
Vista, Win7). Good luck.

- RaZ

Geoff 03-12-2011 06:05 AM

Re: [WinApi] How to raise program from background?
 
On Sat, 12 Mar 2011 02:52:57 +0100, RaZiel <raziel_206_@hotmail.com>
wrote:


>
>You should realize the question is OT. But I'll give you a hint, since
>the answer you're looking for is not common knowledge nor documented
>anywhere in the API docs. Here it is: "Stealing focus" +
>AttachThreadInput. Other solutions will not work on all 3 platforms (XP,
>Vista, Win7). Good luck.
>
>- RaZ


SetWindowPos, SetForegroundWindow; Windows 2000 and up.

RaZiel 03-12-2011 11:32 AM

Re: [WinApi] How to raise program from background?
 
On 12.03.2011 07:05, Geoff wrote:
> On Sat, 12 Mar 2011 02:52:57 +0100, RaZiel<raziel_206_@hotmail.com>
> wrote:
>
>
>>
>> You should realize the question is OT. But I'll give you a hint, since
>> the answer you're looking for is not common knowledge nor documented
>> anywhere in the API docs. Here it is: "Stealing focus" +
>> AttachThreadInput. Other solutions will not work on all 3 platforms (XP,
>> Vista, Win7). Good luck.
>>
>> - RaZ

>
> SetWindowPos, SetForegroundWindow; Windows 2000 and up.


Incorrect. Won't work well on Vista and Win7. He wants to bring a window
from another process to the foreground.


All times are GMT. The time now is 07:44 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.