Re: Getting/Setting States of VB-Shelled Application Windows
From: MikeD (nobody_at_nowhere.edu)
Date: 09/30/04
- Next message: Robert Murrell: "Default behavior of the RichEdit control"
- Previous message: news.telus.net: "Giving Components permissions"
- In reply to: Struggling Rod: "Getting/Setting States of VB-Shelled Application Windows"
- Next in thread: Struggling Rod: "Re: Getting/Setting States of VB-Shelled Application Windows"
- Reply: Struggling Rod: "Re: Getting/Setting States of VB-Shelled Application Windows"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Sep 2004 19:45:20 -0400
"Struggling Rod" <StrugglingRod@discussions.microsoft.com> wrote in message
news:41DDE8AD-6A79-4E92-8F0F-CF1E5F130C01@microsoft.com...
> My VB application launches a windows application (either WordPad or
Notepad)
> using the Shell function..
>
> How can I determine the state of the shelled application's window:
> minimized, restored, or maximized?
>
First, you need to get the hWnd (window handle, which is a value assigned by
Windows when the window is created and which identifies the window) of
either Wordpad or Notepad. VB's Shell function does not return an hWnd.
You'll have to use the API to get that. FindWindow, for example.
After you've got that, there are several different ways of determining if
the app is minimized or maximized. IMO, the easiest way would be to use the
IsIconic and IsZoomed API functions. If both these return 0, then you know
the app is restored. However, GetWindowPlacement would work too (and it's
only one call).
> How do I set the window's state to any of these three possibilities?
>
> I believe the answers lie with one or more of the following API functions:
> ShowWindow, GetWindowPlacement, SetWindowPlacement.
You could use either ShowWindow or SetWindowPlacement for this. I have to
ask though, why don't you set the state when you shell to it? The Shell
function supports this. If the user changes the window state after you've
started the app, you probably shouldn't mess around with it.
>
> Is there a web site that lets me key in one or more keywords and returns
one
> or more descriptions of windows API functions that may solve my problem
along
> with narratives and examples of how to use the API functions?
MSDN Library is the "official" documentation for Windows' API functions (and
Windows programming in general, as well as developing with any of MS's
programming tools, even Office). It's your best source for the most
up-to-date information and is searchable. It's available online at
http://msdn.microsoft.com/library/default.asp. However, much of it
(particularly the API) is documented with C/C++ programmers in mind.
Thusly, any example code included in the documentation is going to be C/C++.
If you're familiar with C/C++ and know how to "translate" it to VB, that
shouldn't be a problem. If you're not familiar with C/C++, then a lot of the
documentation and example code may not make much sense. Because of that,
there are (or used to be) numerous resources for VB programmers. There's a
book named "Visual Basic Programmer's Guide to the Win32 API" by Dan
Appleman that's widely considered as THE book for using the API in VB. As
the title states, it's strictly geared towards VB programmers. There used to
be a web site (apiguide.com or something like that; unfortunately, I forget
exactly what it is and don't even know if it's still around) that provided
VB-centric documentation and example code for API functions. Personally, I
always thought some (actually, quite a few) of the examples were
"questionable"; therefore, I never consulted it much. Other than that, there
are still quite a few VB-classic web sites still around. Many of them delve
into the API quite extensively. Check out www.mvps.org. Karl, Randy, Brad,
and Eduardo all have very good sites. My guess is that the others are
probably decent too. I've just not visited any others so it wouldn't be fair
for me to comment on them one way or the other. The sites from the 4 people
I mentioned don't provide documentation to the API as such. However, they
all provide very good example code. That sample code, in conjunction with
MSDN Library, should help you out a LOT with understanding and using the
Win32 API.
Mike
- Next message: Robert Murrell: "Default behavior of the RichEdit control"
- Previous message: news.telus.net: "Giving Components permissions"
- In reply to: Struggling Rod: "Getting/Setting States of VB-Shelled Application Windows"
- Next in thread: Struggling Rod: "Re: Getting/Setting States of VB-Shelled Application Windows"
- Reply: Struggling Rod: "Re: Getting/Setting States of VB-Shelled Application Windows"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|