Greetings:
I am using .NET to pop up a graphical window for a legacy application
(remember the IBM System/23?). In order to achieve good performance, I
created a GUI Broker Server and a Client Stub. The Client just uses the
Win32 API and is very fast. The Server runs in the background, using .NET
(thus eliminating the startup time for an individual application).
The performance is very good, no problems there. However, I am having
an issue with focusing as the window spawned by the Server does not come to
the front.
I *would* feel stupid for asking this question, but I haven't done a lot
of Windows programming before, .NET or otherwise.
So far, I've tried executing Me.Focus in various Form events, but that
doesn't appear to do anything. My next guess is to call focus somehow for
the Server, but that never has a form showing.
Basically, my question is, how do I force an application to pop up to
the front of all other windows?
Thanks,
James 10 1542
try
me.activate()
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message
news:e0*************@TK2MSFTNGP11.phx.gbl... Greetings:
I am using .NET to pop up a graphical window for a legacy application (remember the IBM System/23?). In order to achieve good performance, I created a GUI Broker Server and a Client Stub. The Client just uses the Win32 API and is very fast. The Server runs in the background, using .NET (thus eliminating the startup time for an individual application).
The performance is very good, no problems there. However, I am having an issue with focusing as the window spawned by the Server does not come
to the front.
I *would* feel stupid for asking this question, but I haven't done a
lot of Windows programming before, .NET or otherwise.
So far, I've tried executing Me.Focus in various Form events, but that doesn't appear to do anything. My next guess is to call focus somehow for the Server, but that never has a form showing.
Basically, my question is, how do I force an application to pop up to the front of all other windows?
Thanks,
James
That just makes the taskbar entry for the pop up window flash.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... try
me.activate()
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message news:e0*************@TK2MSFTNGP11.phx.gbl... Greetings:
I am using .NET to pop up a graphical window for a legacy application (remember the IBM System/23?). In order to achieve good performance, I created a GUI Broker Server and a Client Stub. The Client just uses the Win32 API and is very fast. The Server runs in the background, using .NET (thus eliminating the startup time for an individual application).
The performance is very good, no problems there. However, I am having an issue with focusing as the window spawned by the Server does not come to the front.
I *would* feel stupid for asking this question, but I haven't done a lot of Windows programming before, .NET or otherwise.
So far, I've tried executing Me.Focus in various Form events, but that doesn't appear to do anything. My next guess is to call focus somehow for the Server, but that never has a form showing.
Basically, my question is, how do I force an application to pop up to the front of all other windows?
Thanks,
James
O, then can you maximise or restore after the activate
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl... That just makes the taskbar entry for the pop up window flash.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:%2***************@TK2MSFTNGP12.phx.gbl... try
me.activate()
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message news:e0*************@TK2MSFTNGP11.phx.gbl... Greetings:
I am using .NET to pop up a graphical window for a legacy
application (remember the IBM System/23?). In order to achieve good performance, I created a GUI Broker Server and a Client Stub. The Client just uses
the Win32 API and is very fast. The Server runs in the background, using .NET (thus eliminating the startup time for an individual application).
The performance is very good, no problems there. However, I am having an issue with focusing as the window spawned by the Server does not
come to the front.
I *would* feel stupid for asking this question, but I haven't done
a lot of Windows programming before, .NET or otherwise.
So far, I've tried executing Me.Focus in various Form events, but that doesn't appear to do anything. My next guess is to call focus somehow for the Server, but that never has a form showing.
Basically, my question is, how do I force an application to pop up
to the front of all other windows?
Thanks,
James
Nope, still having trouble with it.
Is there a VB method which tells the Windows OS to push that window to the
front and give it focus? Perhaps a Windows API call?
James
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uz****************@TK2MSFTNGP09.phx.gbl... O, then can you maximise or restore after the activate
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message news:eo**************@TK2MSFTNGP12.phx.gbl... That just makes the taskbar entry for the pop up window flash.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... > try > > me.activate() > > -- > > OHM ( Terry Burns ) > . . . One-Handed-Man . . . > If U Need My Email ,Ask Me > > Time flies when you don't know what you're doing > > "James Pyrich" <py*****@collectionsoftware.com> wrote in message > news:e0*************@TK2MSFTNGP11.phx.gbl... >> Greetings: >> >> I am using .NET to pop up a graphical window for a legacy application >> (remember the IBM System/23?). In order to achieve good performance, >> I >> created a GUI Broker Server and a Client Stub. The Client just uses the >> Win32 API and is very fast. The Server runs in the background, using >> .NET >> (thus eliminating the startup time for an individual application). >> >> The performance is very good, no problems there. However, I am >> having >> an issue with focusing as the window spawned by the Server does not come > to >> the front. >> >> I *would* feel stupid for asking this question, but I haven't done a > lot >> of Windows programming before, .NET or otherwise. >> >> So far, I've tried executing Me.Focus in various Form events, but >> that >> doesn't appear to do anything. My next guess is to call focus somehow >> for >> the Server, but that never has a form showing. >> >> Basically, my question is, how do I force an application to pop up to >> the front of all other windows? >> >> Thanks, >> >> James >> >> > >
James,
You want to make this iritating program?
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim tim As New Windows.Forms.Timer
AddHandler tim.Tick, AddressOf tim_Tick
tim.Interval = 1000
tim.Enabled = True
End Sub
Private Sub tim_Tick(ByVal sender As Object, ByVal e As
System.EventArgs)
Me.Activate()
Me.CenterToScreen()
Me.WindowState = FormWindowState.Normal
End Sub
///
I hope you do not want it?
:-)
Cor
Yeah, that's ugly... and I tried it... and it doesn't work!
It just flashes in the taskbar--it doesn't actually bring the window to
focus.
The window is on top of all the other windows, but it's got to be able to
accept keyboard input (and on Windows NT4, it *is* behind the other
windows).
Is this because, say, it sort of has focus, but it doesn't somehow? Maybe I
can have Windows think I clicked on it with the mouse somehow?
James
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:u6**************@tk2msftngp13.phx.gbl... James,
You want to make this iritating program?
\\\ Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim tim As New Windows.Forms.Timer AddHandler tim.Tick, AddressOf tim_Tick tim.Interval = 1000 tim.Enabled = True End Sub Private Sub tim_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Me.Activate() Me.CenterToScreen() Me.WindowState = FormWindowState.Normal End Sub ///
I hope you do not want it?
:-)
Cor
Did you try it as it is, or just copied some statements?
Maybe I am missing something here. Please give me the code you are running
on the server to launch the form
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl... Yeah, that's ugly... and I tried it... and it doesn't work!
It just flashes in the taskbar--it doesn't actually bring the window to focus.
The window is on top of all the other windows, but it's got to be able to accept keyboard input (and on Windows NT4, it *is* behind the other windows).
Is this because, say, it sort of has focus, but it doesn't somehow? Maybe
I can have Windows think I clicked on it with the mouse somehow?
James
"Cor Ligthert" <no**********@planet.nl> wrote in message news:u6**************@tk2msftngp13.phx.gbl... James,
You want to make this iritating program?
\\\ Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim tim As New Windows.Forms.Timer AddHandler tim.Tick, AddressOf tim_Tick tim.Interval = 1000 tim.Enabled = True End Sub Private Sub tim_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Me.Activate() Me.CenterToScreen() Me.WindowState = FormWindowState.Normal End Sub ///
I hope you do not want it?
:-)
Cor
I finally came up with the answer, and it involved a little Windows API
magic.
I found it here: http://www.thecodeproject.com/vb/net/SpokenWord_1_0.asp
He had some different requirements, but I was able to extract what I needed
from his code.
My final version is here:
Class Utility:
///
Private Declare Function GetCurrentThreadId Lib "kernel32" () As IntPtr
Private Declare Function AttachThreadInput Lib "user32" _
(ByVal idAttach As IntPtr, _
ByVal idAttachTo As IntPtr, _
ByVal fAttach As Boolean) As Boolean
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal lpdwProcessId As IntPtr) As IntPtr
Private Declare Function SetForegroundWindow Lib "user32" (ByVal ByValhWnd
As IntPtr) As Boolean
Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr
Public Shared Sub DoForceFocus(ByVal t As Timer, ByVal f As Form)
Dim foregroundThread As IntPtr =
GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero)
Dim currentThread As IntPtr = GetCurrentThreadId()
If Not foregroundThread.Equals(currentThread) Then
AttachThreadInput(foregroundThread, currentThread, True)
Else
' we have focus. disable timer
t.Enabled = False
End If
SetForegroundWindow(f.Handle)
If Not foregroundThread.Equals(currentThread) Then
AttachThreadInput(foregroundThread, currentThread, False)
End If
End Sub
///
In my form class:
///
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles TimerFocus.Tick
Me.Activate()
Utility.DoForceFocus(TimerFocus, Me)
End Sub
///
This accomplishes what I needed. (Sorry for not replying right away.)
James Pyrich
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl... Did you try it as it is, or just copied some statements?
Good to hear you solved it, sorry I was not able to expidite a solution for
you.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"James Pyrich" <py*****@collectionsoftware.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... I finally came up with the answer, and it involved a little Windows API magic.
I found it here: http://www.thecodeproject.com/vb/net/SpokenWord_1_0.asp
He had some different requirements, but I was able to extract what I
needed from his code.
My final version is here:
Class Utility: /// Private Declare Function GetCurrentThreadId Lib "kernel32" () As IntPtr
Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As IntPtr, _ ByVal idAttachTo As IntPtr, _ ByVal fAttach As Boolean) As Boolean
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As IntPtr, _ ByVal lpdwProcessId As IntPtr) As IntPtr
Private Declare Function SetForegroundWindow Lib "user32" (ByVal ByValhWnd As IntPtr) As Boolean
Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr
Public Shared Sub DoForceFocus(ByVal t As Timer, ByVal f As Form) Dim foregroundThread As IntPtr = GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero) Dim currentThread As IntPtr = GetCurrentThreadId() If Not foregroundThread.Equals(currentThread) Then AttachThreadInput(foregroundThread, currentThread, True) Else ' we have focus. disable timer t.Enabled = False End If
SetForegroundWindow(f.Handle)
If Not foregroundThread.Equals(currentThread) Then AttachThreadInput(foregroundThread, currentThread, False) End If
End Sub
///
In my form class: /// Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles TimerFocus.Tick Me.Activate() Utility.DoForceFocus(TimerFocus, Me) End Sub
///
This accomplishes what I needed. (Sorry for not replying right away.)
James Pyrich
"Cor Ligthert" <no**********@planet.nl> wrote in message news:e3**************@TK2MSFTNGP11.phx.gbl... Did you try it as it is, or just copied some statements?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shaun McKinnon |
last post by:
HI...Here's my problem...I have a popup window that loads when i want it to,
but it's not sized properly. I've set the size, but it doesn't seem to
work. I've been on 8 different websites to find...
|
by: theintrepidfox |
last post by:
Dear Group
I wondered whether you can help me with this. I do have a page that
contains a button and an IFrame. The IFrame contains a dummy page that
is set to redirect to a word document when...
|
by: Raffi |
last post by:
Hi,
We have a database application that runs in a popup Internet Explorer
application window. The reason for this is to isolate the casual user
from the address bar and the typical IE navigation...
|
by: VR |
last post by:
First, greetings to everyone :)
I'm doing a university seminar & I've encountered a problem. I have a
gallery with thumbnails linked on pictures. What I want is popup to be
opened with...
|
by: clsmith66 |
last post by:
I am building an ASP.NET application where I have been required to make all
the editing screens popup windows within the application. I didn't have any
trouble creating the new windows but only...
|
by: Alex.Svetos |
last post by:
Hello,
I'm trying to get a popup to keep focus when it is re-clicked.
The script below is supposed to produce this exact behaviour,
however it doesn't work, at least on firefox 1.0.7 and moz...
|
by: anthony.turcotte |
last post by:
Hi,
I've looked for a solution to this problem on google, read posts in
this newsgroup and I still haven't found anything that could help me.
Here's the scenario.
1. User accesses...
|
by: V S Rawat |
last post by:
using Javascript, I am opening a web-based url in a popup window.
MyWin1=Window.Open(url, "mywindow")
There is a form (form1) in the url in that popup window, I need to
submit that form.
...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |