[WinApi] How to raise program from background?

S

Szyk

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
 
V

Victor Bazarov

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
 
A

Alf P. Steinbach /Usenet

* 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
 
G

Geoff

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

* Szyk, on 11.03.2011 20:05:


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. ;)
 
R

RaZiel

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
 
G

Geoff

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.
 
R

RaZiel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top