Solved

Minimize app

Posted on 2004-04-02
13
559 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
Comment Utility
> 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
Comment Utility
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
Comment Utility
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
 
LVL 5

Expert Comment

by:crazycomputers
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:crazycomputers
Comment Utility
> 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
Comment Utility
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
Comment Utility
> 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
Comment Utility
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
Comment Utility
You're welcome.  =)  Let me know if you need any more help with VB.
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
What times are you normally online?
0
 
LVL 5

Expert Comment

by:crazycomputers
Comment Utility
Pretty much random.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now