472,958 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Set foreground window

Given the handle of a window, is there a way to make it the foreground window
using C# (rather than win32 API)?
Jun 27 '08 #1
3 3735
On Fri, 06 Jun 2008 00:58:03 -0700, AA2e72E
<AA*****@discussions.microsoft.comwrote:
Given the handle of a window, is there a way to make it the foreground
window
using C# (rather than win32 API)?
Given just the handle? No, I don't think so. A handle is an unmanaged
data structure, and you need to use unmanaged code.

If you know something else about the handle (for example, you know for
sure it's from a managed Form instance), then there's the possibility you
can convert it into something that would allow you to use the result from
managed code. But otherwise, no.

Pete

Jun 27 '08 #2

I can do this quite easily using Win32 APIs from unmanaged code; I am trying
to avoid unmanaged code.

As well as the handle, I can get the caption.

Basically I am using an out of process COM server to which I need to send
instructions via SendKeys; for this, I need to make the COM server visible (I
can) and be the foreground window.
Jun 27 '08 #3
On Fri, 06 Jun 2008 09:34:00 -0700, AA2e72E
<AA*****@discussions.microsoft.comwrote:
I can do this quite easily using Win32 APIs from unmanaged code; I am
trying
to avoid unmanaged code.
Based on your description, I don't think that will be possible. But,
using p/invoke for the one function you need (SetForegroundWindow)
shouldn't really be an issue, especially given that you're already
basically messing around with unmanaged stuff anyway.

Note, of course, the limitations on SetForegroundWindow. Assuming your
own application is already in the foreground, you should be fine. But
it's not a panacea.

Pete
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: one2001boy | last post by:
Hello, I have an executable file lanuched from another application. is there a way to make thie executable file foreground if it is launched from other application? Thanks.
0
by: Tom | last post by:
Here is a very strange problem that I am stumped by. I have a rather large application written in VB.NET (of course) using Framework 1.1. As you know, with an MDI application you can have multiple...
3
by: Carl Fenley | last post by:
I am trying to capture the Windows QueryCancelAutoPlay message that is sent to the "foreground window" when an AutoRun enabled CD is inserted into a drive. Enabling and Disabling AutoRun...
1
by: Terry Olsen | last post by:
In my chat application, I create a new window for each private chat. I use the FlashWindowEx API to flash the window if it's not the Foreground window. I determine the Foreground window using the...
17
by: M O J O | last post by:
Hi, How can I force a form to the foreground no matter what application is in front? Thanks! M O J O
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.