Solved

Minimize app

Posted on 2004-04-02
13
583 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
  • 7
  • 6
13 Comments
 
LVL 5

Accepted Solution

by:
crazycomputers earned 500 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 62
how to know if my Checkbox is True in VB6.0? 9 60
backup program with robocopy 6 43
VBA: loop recent folder and copy txt file. 8 33
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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