Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Minimize app

Posted on 2004-04-02
13
Medium Priority
?
603 Views
Last Modified: 2012-08-14
How to programmatically minimze my app/form?
More preferred - verify somehow that the now foreground app is internet explorer...
And if so - sendkeys (Ctrl+D) to the URL?
0
Comment
Question by:sirbounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 5

Accepted Solution

by:
crazycomputers earned 2000 total points
ID: 10746512
> How to programmatically minimze my app/form?

FormName.WindowState = vbMinimized

> verify somehow that the now foreground app is internet explorer

Put this code in a module:

' ------
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Public Function IsIEActive() As Boolean
    Dim sClass As String * 50
    Dim fWnd As Long

    fWnd = GetForegroundWindow
    GetClassName fWnd, sClass, 50

    IsIEActive = (Left(sClass, 8) = "IEFrame" & vbNullChar)
End Function
' ------

Then you can do something like:

If IsIEActive Then MsgBox "IE is active"
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10747429
crazycomputers - Thanx - that's great - the points are yours.
But for 'bonus' points - can I alter the last bit a little?

I'm "using" IE  - but it loads under an overlay (www.myie2.com).
It arranges seperate windows in tabbed format, similar to netscape.

Do you know of a way to get that information?

Thanx - increasing to 350 - will increase to 500 if you can get this info for me!
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10747481
Actually, I saw the message box when I clicked on my app in the taskbar... Hmm...
Thanx for all your help!  
I like your profile, btw. :D
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:crazycomputers
ID: 10748630
You're welcome.  =)  And what specifically about my profile attracts your attention?  ;)

As for the "tabbed format" and such, I'm not sure exactly what you're asking.  Could you describe it better and/or post a screenshot?
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10748968
well, myie2 overlays iexplore.exe - it doesn't replace it.
It's got a great pop up killer and it allows you to run your browser in one instance, instead of multiple instances for each page you load.
For instance, if I load 2 IE pages - there will be two items in my task bar.
But myie2 only loads one instance and I can have 20 windows open - they're just 'tabbed' - much like VB's tab control...

Okay, well - perhaps you can walk me through your code...
I'm self-teaching myself VB, but have a long way to go apparently... would you mind walking me through these?

>>Public Declare Function GetForegroundWindow Lib "user32" () As Long<<
>>Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long<<

>>    Dim sClass As String * 50<< 'why * 50?

>>     fWnd = GetForegroundWindow ' I take it that this uses user32 to find out what the foreground window is - but how?

>>    GetClassName fWnd, sClass, 50<< ??

>>    IsIEActive = (Left(sClass, 8) = "IEFrame" & vbNullChar) << ' guess I'll understand this when I understand why sclass (string?) is multiplied by 50...  Is "IEFrame" related to IE somehow?

Thanx.

Can you send an email to me on the other?  I like to keep personal items out of the threads...  Thanx. :D
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10750014
Public Declare Function GetForegroundWindow Lib "user32" () As Long
' Imports the GetForegroundWindow API function.  It returns a
' handle to the foreground window.

Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
' Imports the GetClassNameA API function.  Given a window handle,
' a string, and the string's length, it fills the string with the window
' class of the window represented by the handle.

' Note that GetClassNameA is aliased to GetClassName in the VB code.

Dim sClass As String * 50
' * 50 declares a string to be a 50-character fixed-length string.  We
' need to pre-allocate space for GetClassNameA to fill.

GetClassName fWnd, sClass, 50
' Fills sClass with the window class, up to 50 characters.

IsIEActive = (Left(sClass, 8) = "IEFrame" & vbNullChar)
' Let's break this down:

' Left(sClass, 8) returns the left-most 8 characters of sClass.  "IEFrame"
' is 7, plus one null character to ensure that it's not "IEFrame2" or
' something else like that.

' "IEFrame" & vbNullChar is the 8-character string we want to compare
' to the left eight characters of sClass.  We can't directly compare
' because sClass is 50 characters (it's fixed-length).

' IsIEActive = ... sets the return value.
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10750054
> I'm "using" IE  - but it loads under an overlay (www.myie2.com).
> It arranges seperate windows in tabbed format, similar to netscape.

> Do you know of a way to get that information?

Get what information?
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10750427
Well, how do you know that sClass will be "IEFrame"?  Is that something that's within IE?
I mean - if I wanted to check that Outlook was the foreground, how would I alter this (for example), or for Word, Excel - whatever?

Thanx so much for your help.  You're really good at this! :D
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10752464
> Well, how do you know that sClass will be "IEFrame"?

I didn't before you posted this.  =)

All you do is after "GetClassName fWnd, sClass, 50" just do something like "Debug.Print sClass" or "MsgBox sClass" and look at what it is.  Of course, the program you're targetting must be the foreground window when the code is executed.  (Timers are useful here.)

> Thanx so much for your help.  You're really good at this! :D

I'm just an information sponge.  ;)
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10752995
Thank you very much for your help Mr. information sponge...
Wish I was younger, my sponge is slowly shrinking... :D
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10753046
You're welcome.  =)  Let me know if you need any more help with VB.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10753053
What times are you normally online?
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10753646
Pretty much random.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question