how to maximize a minimized window?

Hi,

How to maximize a minimized window (Not Microsoft product) by visual basic?

Thank you very much for your help!

Best regards
Doris
d_p2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vasu_iCommented:
You can use the API SendMessage with SW_MAXIMIZED value. This function will notify the window to maximize.
0
vasu_iCommented:
You can use the API SendMessage with SW_MAXIMIZED value. This function will notify the window to maximize.
0
jeremydCommented:
Do you want to:
- Maximize the window of the program you are writing
- Maximize the window of some other program that's running
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

d_p2Author Commented:
maximize the window of other program!

i.e. I want to use

AppActivate "ProgramTitle"
sendkey "1", true

However, if the program is minimize, the key is not sent to the program!

Thank you very much!

Best regards
Doris
0
d_p2Author Commented:
maximize the window of other program!

i.e. I want to use

AppActivate "ProgramTitle"
sendkey "1", true

However, if the program is minimize, the key is not sent to the program!

Thank you very much!

Best regards
Doris
0
d_p2Author Commented:
maximize the window of other program!

i.e. I want to use

AppActivate "ProgramTitle"
sendkey "1", true

However, if the program is minimize, the key is not sent to the program!

Thank you very much!

Best regards
Doris
0
cody76589Commented:
0
d_p2Author Commented:
Sorry, could you give more details in this address
http://lightning.prohosting.com/~shell123
?

Thank you very much!

Best regards
Doris
0
vbyuvalCommented:
You can open the application by this code (e.g. notepad ) :


AppActivate Shell("c:\winnt\notepad.exe", vbNormalFocus), True

SendKeys "1", true

*But I think the problem is with the wait parameter in the AppActivate it should be False if you want the program get your key with the SendKeys command !

                              Enjoy
                            Yuval Amir

0
d_p2Author Commented:
Sorry, my problem is the program is single instance and as it is existed and minimize.  I can't restore it.

Thank you very much!

Best regards
Doris
0
jeremydCommented:
I have a possible answer but you need to evaluate the answer given first.
0
d_p2Author Commented:
AppActivate Shell("c:\winnt\notepad.exe", vbNormalFocus), True

SendKeys "1", true

Can't solve my problem as the program is minimized.  Please give some suggestions.

Thank you very much!

Best regards
Doris
0
jeremydCommented:
Use this:

Private const WM_SIZE as long = 5
Private const SIZE_MAXIMIZED as long = 2

Private Declare Function GetForegroundWindow lib "user32.dll" as long

Private Declare Function SendMessage lib "user32.dll" (byval hWnd as long, byval nMsg as long, byval wParam as long, byval lParam as long) as long

<inside your click sub or whatever...>
  dim hWnd as long

  AppActivate "Window Title of program"
  hWnd = GetForegroundWindow
  SendMessage hWnd, WM_SIZE, SIZE_MAXIMIZED, 0, 0

<end of your click sub or whatever...>

Note that if this code is in a module instead of a form you should change the privates to publics or maybe leave them out alltogether.

The only way I could see that this might not work is if the window you want doesn't become the "foreground window" after calling AppActivate (which I think it does, but you never know with MS).

If this is the case you can use the EnumWindows function in the API to get the right hWnd.  I think there's a good article on this in the MSDN CD.  Just type EnumWindows in the index/search
0
d_p2Author Commented:
Hi jeremyd,

You are right!

The solution is :


 Declare Function OpenIcon Lib "user32" (ByVal hwnd As Long) As Long
      Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
         (ByVal lpClassName As String, ByVal lpWindowName As String) _
         As Long
      Declare Function GetWindow Lib "user32" _
         (ByVal hwnd As Long, ByVal wCmd As Long) As Long
      Declare Function SetForegroundWindow Lib "user32" _
        (ByVal hwnd As Long) As Long


AppActivate AppTitle
    WindowHndl = FindWindow(vbNullString, AppTitle)
    result = OpenIcon(WindowHndl)         'Restore the program.
    result = SetForegroundWindow(WindowHndl)        'Activate the application.

Then it can resume!

jeremyd, please propose it as answer so that i can accept your answer!

Thank you very much for your help! :>

Best regards
Doris
0
jeremydCommented:
I can't.  You have to decline the previous answer first.

Glad I could help...
0
d_p2Author Commented:
Sorry vbyuval, jeremyd answered the question.  However, thank you very much for your suggestion!

Thanks a lot!

Best regards
Doris
0
jeremydCommented:
Use this:

Private const WM_SIZE as long = 5
Private const SIZE_MAXIMIZED as long = 2

Private Declare Function GetForegroundWindow lib "user32.dll" as long

Private Declare Function SendMessage lib "user32.dll" (byval hWnd as long, byval nMsg as long, byval wParam as long, byval lParam as long) as long

<inside your click sub or whatever...>
  dim hWnd as long

  AppActivate "Window Title of program"
  hWnd = GetForegroundWindow
  SendMessage hWnd, WM_SIZE, SIZE_MAXIMIZED, 0, 0

<end of your click sub or whatever...>

Note that if this code is in a module instead of a form you should change the privates to publics or maybe leave them out alltogether.

The only way I could see that this might not work is if the window you want doesn't become the "foreground window" after calling AppActivate (which I think it does, but you never know with MS).

If this is the case you can use the EnumWindows function in the API to get the right hWnd.  I think there's a good article on this in the MSDN CD.  Just type EnumWindows in the index/search
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbyuvalCommented:
That's fine with me !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.