Google Answers Logo
View Question
 
Q: Minimizing Internet Explorer programatically. ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Minimizing Internet Explorer programatically.
Category: Computers > Internet
Asked by: ebarker-ga
List Price: $100.00
Posted: 04 Jun 2002 07:25 PDT
Expires: 11 Jun 2002 07:25 PDT
Question ID: 20625
Is there an easy way to programatically minimize Internet Explorer?  I
have a web app that uses IE (mostly 6, but a couple boxes have 5.5) in
kiosk mode (no toolbars), and I have my own toolbar.  I want to add a
button that will just minimize the browser, but have drawn a blank so
far.  Where would I go for this answer?
Answer  
Subject: Re: Minimizing Internet Explorer programatically.
Answered By: lazerfx-ga on 04 Jun 2002 08:54 PDT
Rated:5 out of 5 stars
 
Hello ebarker-ga,

There are two possibilities you are looking for here.  One is that you
need to use the Windows API to programatically minimize the IE window,
and the other is that you are looking to use DHTML to minimize the
window.

I have researched both, and provided sources for how you can do this.

The first I researched was the DHTML / Javascript way of minimizing
the current IE window.  I found quite a good 'how-to' on creating IE
toolbars at reference (1).  I then had a look for how to minimize the
IE window.  It appears that a lot of people are having trouble with
this, however a possible work-around was found at reference (2). 
Basically, this involves putting the window 2000px off the screen, and
so to all intents and purposes the window is 'minimized' (I.e. off
screen).  The script that does this looks like this:

<script language="javascript">
show=1
function minimize(){
  moveBy(2000,2000)
  show=0
}
function reshow(){
  if(show==0){
    moveBy(-2000,-2000)
    show=1
  }
}
</script>

I tested this out, and the author had made an error in the 'if'
statment, and failed to close their brackets.  This is the edited,
tested and working script.  I tested it in IE6 on Windows XP, however
it should work from IE4 upwards.

You will then need to put a onfocus=reshow() to the body tag.  Also,
you would put into the button the code to call minimize().  This would
have the desired effect of moving the window off the screen.  When
focus is passed back to the window, the code in the body tag means
that it is move back onto the screen.

---

The other option is to programatically minimize the window by calling
the Windows API.  I am assuming you are using VB, since that is the
most common programming language for producing toolbars and the like. 
After doing some research, the API call do monitor windows is
ShowWindow (Reference 3).  This requires the window handle of the
current window.  See reference 4 for information on how to do this.

Sample code (Please note, I have not tested this in a VB environment):

-------------------------
Private Declare Function M_GetActiveWindow Lib "user32" _
Alias "GetActiveWindow" () As Long 
Function GetActiveWindow() As Long 
Dim xHwnd As Long 
xHwnd = M_GetActiveWindow() 
GetActiveWindow = xHwnd 
End Function

-- In button onClick() event --

dim myHwnd as Long ' return value
dim retVal as Long ' the return value from the ShowWindow function
myHwnd = GetActiveWindow() ' get the hwnd value of the active window
retVal = ShowWindow(myHwnd, SW_MINIMIZE) ' minimize the IE window.
---------------------------

I hope this helps you to minimize (or simulate minimizing) from
Internet Explorer.  So you know what articles I got this information
from, I have included the Google Searches and the Articles I saw:

Google Search - Creating Internet Explorer Toolbars
(1) [ http://www.webreference.com/dhtml/column29/ ] - DHTML
Application Toolbars

Google Search - "Minimize IE" javascript
(2) [ http://lists.evolt.org/archive/Week-of-Mon-20020225/105265.html
] TheList at lists.evolt.org - Javascript Minimize.

Google Search - Minimize API VB
(3) [ http://216.26.161.91/vbapi/ref/s/showwindow.html ] -
ShowWindow() VB API call reference

Google Search - Get current window handle VB
(4) [ http://www.vbsquare.com/api/tip368.html ] - Get the current
active window handle (hwnd)


Extra information
-----------------
If you are using Delphi, There is a Delphi plugin, registration
US$10.55, that allows you to access the various controls in IE,
including minimize and maximize controls.

[ http://www.jazarsoft.com/ ] - Jazarsoft homepage
[ http://www.jazarsoft.com/vcl/view.php3?id=33 ] - IE Control
information page.

I hope this helps you,
LazerFX-GA
ebarker-ga rated this answer:5 out of 5 stars
Excellent!  Exactly what I was looking for, thanks!

Comments  
Subject: Re: Minimizing Internet Explorer programatically.
From: greenreaper-ga on 04 Jun 2002 11:45 PDT
 
Might want to make it a bit more than 2000 pixels just in case people
have screens that big/multiple screens (but not more than about 10000
- I think 9x has a GUI limit of either 16k or 32k).

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy