Solved

Minimize app

Posted on 2004-04-02
13
601 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 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

623 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