"Switch To" another application

I want to pop a running application up to the top of the screen.
Basically I want to simulate the functionality of the "Switch to"
feature in Task Manager.  Naturally, it will not work.

First off, I obtain the process handle by using EnumProcesses().

Next, after realizing that this was an area of the API with lots of
holes, I find I must jump through hoops in order to "Switch To" this
application.

Next, I call GetProcessID() on my process handle.

Next, I call EnumThreadWindows which inconvienently uses a callback
function to obtain the window handles of the windows of that process.
My callback function is supposed to be called, but it is not:



EnumThreadWindows(dwProcessID, SwitchToProcessProc, 0);



BOOL CALLBACK SwitchToProcessProc(HWND inWnd, LPARAM lParam)
{
	BOOL fContinue = TRUE;
	if (0 == ::GetParent(inWnd))
	{
		SetForegroundWindow(inWnd);
		fContinue = FALSE;
	}
	return fContinue;
}


What gives?

0
scs0 (15)
9/21/2006 3:56:01 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
445 Views

Similar Articles

[PageSpeed] 58

How about using FindWindow to find the window and then use
SetForeGroundWindow on it.

---
Ajay

scs0 wrote:
> I want to pop a running application up to the top of the screen.
> Basically I want to simulate the functionality of the "Switch to"
> feature in Task Manager.  Naturally, it will not work.
>
> First off, I obtain the process handle by using EnumProcesses().
>
> Next, after realizing that this was an area of the API with lots of
> holes, I find I must jump through hoops in order to "Switch To" this
> application.
>
> Next, I call GetProcessID() on my process handle.
>
> Next, I call EnumThreadWindows which inconvienently uses a callback
> function to obtain the window handles of the windows of that process.
> My callback function is supposed to be called, but it is not:
>
>
>
> EnumThreadWindows(dwProcessID, SwitchToProcessProc, 0);
>
>
>
> BOOL CALLBACK SwitchToProcessProc(HWND inWnd, LPARAM lParam)
> {
> 	BOOL fContinue = TRUE;
> 	if (0 == ::GetParent(inWnd))
> 	{
> 		SetForegroundWindow(inWnd);
> 		fContinue = FALSE;
> 	}
> 	return fContinue;
> }
> 
> 
> What gives?

0
ajaykalra (6842)
9/21/2006 4:03:06 PM
I can't do that because I don't know the window class name and there's
no way to know what the window's caption is going to be.




Ajay Kalra wrote:
> How about using FindWindow to find the window and then use
> SetForeGroundWindow on it.
>
> ---
> Ajay
>
> scs0 wrote:
> > I want to pop a running application up to the top of the screen.
> > Basically I want to simulate the functionality of the "Switch to"
> > feature in Task Manager.  Naturally, it will not work.
> >
> > First off, I obtain the process handle by using EnumProcesses().
> >
> > Next, after realizing that this was an area of the API with lots of
> > holes, I find I must jump through hoops in order to "Switch To" this
> > application.
> >
> > Next, I call GetProcessID() on my process handle.
> >
> > Next, I call EnumThreadWindows which inconvienently uses a callback
> > function to obtain the window handles of the windows of that process.
> > My callback function is supposed to be called, but it is not:
> >
> >
> >
> > EnumThreadWindows(dwProcessID, SwitchToProcessProc, 0);
> >
> >
> >
> > BOOL CALLBACK SwitchToProcessProc(HWND inWnd, LPARAM lParam)
> > {
> > 	BOOL fContinue = TRUE;
> > 	if (0 == ::GetParent(inWnd))
> > 	{
> > 		SetForegroundWindow(inWnd);
> > 		fContinue = FALSE;
> > 	}
> > 	return fContinue;
> > }
> > 
> > 
> > What gives?

0
scs0 (15)
9/21/2006 4:36:39 PM
Reply:

Similar Artilces:

"Switch To" another application
I want to pop a running application up to the top of the screen. Basically I want to simulate the functionality of the "Switch to" feature in Task Manager. Naturally, it will not work. First off, I obtain the process handle by using EnumProcesses(). Next, after realizing that this was an area of the API with lots of holes, I find I must jump through hoops in order to "Switch To" this application. Next, I call GetProcessID() on my process handle. Next, I call EnumThreadWindows which inconvienently uses a callback function to obtain the window handles of the windows of t...

converting switch to lookup tbl?
I've had this lingering question for a while and am now finally trying to address it. We know switch statements' sizes are limited. I have this switch statement below, and I need to add more but am bumping up against the size limitation: SELECT Switch( [TCODE]="4030","Purchase - abcd" , [TCODE]="3021","Dividend - abcd", [TCODE]="8081","FIFO Sale - Subtract CDSC", [TCODE]="7011" And IsNull([TBL1.SACCTNUM])<>True,"Not purchase", [TCODE]="7011" And IsNull([TBL1.SACCTNUM])=True,"Purchas...

Unable to switch to native mode
I am trying to convert from Mixed to Native mode using the steps in Q272314. Our environment is 4 sites that were upgraded from Exchange 5.5 to Exchange 2k3 and we have moved all mailboxes, public folders to the new servers. I have followed all the steps in the Q article above and made sure that all recipient CA's were removed. I've removed all the Directory Replication Connectors (except ADNAutoDRC) When I get to the final Step 11 and 12 I get an error that the "SRS is function9ing as the bridgehead for one or more directory replication connectors and cannot be deleted.&qu...

Command line switch to open file as read-only?
I have a batch script which I use to open a spreadsheet when I logon in the morning. When the batch file opens the spreadsheet, I get a requestor asking me if I want to open the file as 'Read Only'(Other people use the spreadsheet and have it open). I'd like to bypass that requestor entirely. Is there a command line switch that will open the file as read-only? Please reply to the group as my email addy is, of course, invalid... Thanks! Take a look at "startup switches" inside Excel's help. From there, you'll see you can add "/r" without the quotes t...

Macro to switch to another sheet, grab ref to any cell, paste ref in current sheet??
I am looking for a way (either macro or VBA) to perform one simple task: while in *any cell* of your choice in the current worksheet, switch to another specific sheet, choose *any* cell, grab a reference to that cell (not its value), switch back to the first worksheet and slap in the reference of the cell in the other sheet. This would be the automated equivalent of doing the following manually: 1) Select *any cell* (say *F11*) in the current sheet (Call it "*Destination*"). 2) Press "=" (no "ENTER") 3) Click the tab for the other sheet (call it "*Source*&...

Switch to Mac?!
Dear all! I am seriously contemplating switching to Apple.... I usually hear screams of horror at this point, but given this is a Mac forum !... I have long been a Microsoft addict. I have the SPV phone, a Dell Axim, I have 3 pc desktops, 3 laptops- all running some form of Windows. I am even a Microsoft beta tester. BUT, I am sick of it. I want a change. One of my primary concerns about the switch is Office. I love office 2003 for the pc- BUT error messages are constant and outlook keeps crashing. I've looked on the Microsoft mactopia website and it all looks very good but of course...

I try to switch to euros and appears ######
I pointed the values of my monthly earnings in numbers and when I tried to move to euro appears that ####### Try widening the column. Please hit Yes if my comments have helped. Thanks. "JAJM" wrote: > I pointed the values of my monthly earnings in numbers and when I tried to > move to euro appears that ####### HI Try widening the column. -- Regards Roger Govier "JAJM" <JAJM@discussions.microsoft.com> wrote in message news:FC46EEA9-D1B6-4EDE-8F2F-03BDF08C467D@microsoft.com... > I pointed the values of my monthly earnings i...

Using VBA to switch to a particular Access database
Need a bit of help, please, with some VBA code that I've written in Microsoft Outlook 2007. It is intended to call up a specific Microsoft Access database and open a particular form and subform, so that it can then go on to take various actions based on the values from Outlook. Here's the basic code: ------ Sub SwitchToProjects() Dim appAccess As Access.Application Dim ThisDatabaseFileName As String ThisDatabaseFileName = "C:\myFile.mdb" Set appAccess = GetObject(ThisDatabaseFileName, "Access.Application") appAccess...

switch to html
When I compose new mail my signature file appears in plain text. When I attempt to change format I get a message asking to switch to html. When I do that the signature displays properly. How can I make a permanent change on the setting so that I don't have to go through that every time? Thanks, Bryan Tools\optins\mail format, "send messages in this format": HTML, and don't select Word as the email editor. >-----Original Message----- >When I compose new mail my signature file appears in >plain text. When I attempt to change format I get a >message as...

switch to quicken
would any of you ever consider switching to Quicken? Why/why not? In a heartbeat - if it was easy. I have 12 years of info in my Money file (it came with my very first IBM personal computer back in the mid 90's). But now they have a few problems with 2006 and I feel like I am treated like an idiot when it is the programmers, or the people in customer service who don't know about investments and rates of returns, and returns for the period and things like that. So, if you have an easy way to convert - let me know!!!! So far, only investment information is easily converted -...

Returning entries are gone after switch to Office XP
Hi! I have exported (using import/export) OUTLOOK 2002 Data including all subdirectories and reimported them to Outlook XP . After having a first glance on the data I later realized that every returning entry is gone. Like "gym on wednesday" or "eating sauerkraut each sunday" ! Did I do something wrong? can I solve this problem in any way? Did somebody have it before and can help me? Einie Alexander Weidemann <einie@mac.com> wrote: > I have exported (using import/export) OUTLOOK 2002 Data including all > subdirectories and reimported them to Outlook XP . T...

Switch to mac means all Office files are Read Only
Can someone please tell me what I can do to resolve the following problem? Last Friday I bought a new 12" Powerbook (O/S 10.3.3) as well as Microsoft Office 2004. I have previously been using a Sony VAIO (PC Notebook) with Microsoft Windows 2000 O/S using Microsoft Office 2000. I read the instructions on the Mac Switch site and copied all my office files and folders to a Switch CD (RW) then inserted the CD into my new Mac. I dragged all the files to the Documents folder in the Mac. Result is all files open but, regardless of whether it is a Word document, an Excel spreadsheet or a Pow...

How do I switch to horizontal pane split?
I'm pretty sure this is something sooooo easy - I just want to read my emails horizontally, underneath my inbox, not to the right of it - I call this horizontal pane split, but perhaps I am searching with the wrong key words. HELP! Judy Outlook\View\Reading Pane -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "Judy C" <Judy C@discussions.microsoft.com> wrote in message news:E18ACA6B-9050-46F3-ABE2-AC57064757EC@microsoft.com... > I'm pretty sure this is something sooooo easy -...

Switch to Novell
When is Microsoft going to switch to a better system? ...

Should I switch to Money 2005?
I've used Quicken on and off for a few years, but have been using the web version of their bill pay service for quite a while now. With their recent upgrade of the bill pay service, I had to also install Quicken 2005. I was less than pleased to find that QIF imports to checking and savings accounts are now disabled. My credit union refuses to pay Intuit's (high, I might mention) fees to use WebConnect. My question: is Money any better? I know my bank supports Money, which is nice. What about on the other issues: is Money's bill pay service decent? Is the software easy...

Data labels switch to text boxes on negative values
Hello- I am not sure if this has been asked previously but I am having an issue with a number of charts that I populate using a macro. The charts are all horizontal bar charts and in the macro I auto format the data labels. When I save the file in the macro the labels of the negative values switch from being a data label to a floating text box. Has anyone experienced this? Is there something that can be done to fix this? Thanks, What version of Excel is this? Could you post the relevant code? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technica...

Money 2006 Standard
I've just started to use the Money 2006 and I'm trying to move from the Essential Budget to the Advanced Budget, but the software does not move to the selected option. Is there any action to correct this problem? I was using a very old Money version (97) and the file was converted without any problem with budget data in the Advanced format, but as I can't select the Advanced Budget I'm not able to change anything in it. Is it possible to somebody help me on solving this problem? Thank you very much -- Bob Campos Have you tried doing a File - Repair, Bob? -- Michael Gor...

Switch to a specific open 3rd party program
Hi I'd like to know how to move windows focus from a microsoft access program to 3rd party software which is also running. It would be inadvisable to use sendkeys to alt-tab through this environment and I cannot find kb articles relating to this problem post 1996. Thanks in advance "p" <p.macrae@gmail.com> wrote in message news:1179446726.614604.173140@w5g2000hsg.googlegroups.com... > > I'd like to know how to move windows focus from a microsoft access > program to 3rd party software which is also running. It would be > inadvisable to use sendkeys to al...

How to switch to another user on OWA
We have OWA 2000 for users to access the email remotely. Some of users saved their logon names and passwords on their laptops so that they don't need to type the logon information. That is OK. But, how do they switch to another user if they logon automatically? For example, I logon myself as bob on my laptop while John wants to check his email. (We don't want to disable autologon). Any suggestions? Perhaps I need some clarifications. If you have user using OWA which is via the internet then you would want them to log into it using their credentials. This would provide additio...

command line switch to open a specific worksheet?
Is there a way to open a specific worksheet in a workbook using command line switches? I'm trying to create a menu selection in AutoCAD that will open an Excel workbook to a specific worksheet inside of that workbook. Typing the command "start" <CR> followed by "Excel /filename/" <CR> will open that particular file, but how do I get it to open to a specific worksheet? Thanks for any help, Paul There's no command line switch that will activate a worksheet. You have to do one of the following: -Save the workbook with the desired sheet active. Exc...

brochure-switch to inside page w/ template
i can go to 'insert' - 'page' but how do i do this and get the proper template that matches the one on which i've been working. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/office/community/en-us/default.mspx?mid=379daa7...

Lost Contacts after switch to Personal Folders File.. any suggestions?
I recently switched my Outlook 2k3 data file from the old 97-2002 format to the updated larger capacity Personal Folders File. I created a new new data file in the PFF format then imported the old 97-2002 file back into the new data file. Here is where the problems start, all the email messages seem to have imported correctly but none of the contacts made it over. In addition if i have the mail button highlited in the lower left corner i do not have an icon for my contacts listed under All Mail Folders in the middle left pane of outlook. Can i re-import only contacts and why is "conta...

Should I Switch to another program?
Am I reading the news announcement right? I have Microsoft Money 2007 Deluxe; soon will I be unable to download transactions from my bank? Should I start shopping for a new financial management tool? Thanks. In microsoft.public.money, SLeepdepD wrote: >Am I reading the news announcement right? Reading is good. > I have Microsoft Money 2007 >Deluxe; soon will I be unable to download transactions from my bank? It depends on your bank, but you would have to go thru you bank's website. > >Should I start shopping for a new financial management tool? > >Thanks....

Switch to Multi-Bin
We are running GP 9.0. When switching to multi-bin in inventory setup (in a test environment) some of my item's inventory counts make it to the bin that I set up in the site default for Sales Order Fulfillment while others fall into the autocreate bin. I know that prior to switching to multi-bin none of my items had a default bin assigned at the item level yet some of them did end up in the default bin at the site level for set for Sales Order Fulfillment. What other criteria does the inventory reconciliation look for when assigning the item's inventory to a bin (either the au...

How to switch to edit the cell
Dear all, I am browsing one excel file with the up and down arrow, and when I want to edit the cell content, I need to use the mouse to click the content,then I can edit it. Is there any short-cut key to switch from browsing to edit, that means I do not need to click on the cell to edit it, I can press SOME key so I can edit the content from browsing (using up and down arrow). Thanks Hi F2 HTH. Best wishes Harald "hon123456" <peterhon321@yahoo.com.hk> skrev i melding news:34387e87.0501130216.697a276a@posting.google.com... > Dear all, > > I am bro...