?
Solved

how to maximize a minimized window?

Posted on 2000-01-30
18
Medium Priority
?
1,655 Views
Last Modified: 2012-08-13
Hi,

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

Thank you very much for your help!

Best regards
Doris
0
Comment
Question by:d_p2
  • 8
  • 5
  • 2
  • +2
18 Comments
 
LVL 1

Expert Comment

by:vasu_i
ID: 2453801
You can use the API SendMessage with SW_MAXIMIZED value. This function will notify the window to maximize.
0
 
LVL 1

Expert Comment

by:vasu_i
ID: 2453822
You can use the API SendMessage with SW_MAXIMIZED value. This function will notify the window to maximize.
0
 

Expert Comment

by:jeremyd
ID: 2454521
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:d_p2
ID: 2454581
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
 

Author Comment

by:d_p2
ID: 2454701
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
 

Author Comment

by:d_p2
ID: 2454721
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
 

Author Comment

by:d_p2
ID: 2456562
Sorry, could you give more details in this address
http://lightning.prohosting.com/~shell123
?

Thank you very much!

Best regards
Doris
0
 
LVL 1

Expert Comment

by:vbyuval
ID: 2461582
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
 

Author Comment

by:d_p2
ID: 2462263
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
 

Expert Comment

by:jeremyd
ID: 2463341
I have a possible answer but you need to evaluate the answer given first.
0
 

Author Comment

by:d_p2
ID: 2477012
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
 

Expert Comment

by:jeremyd
ID: 2477932
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
 

Author Comment

by:d_p2
ID: 2481911
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
 

Expert Comment

by:jeremyd
ID: 2483022
I can't.  You have to decline the previous answer first.

Glad I could help...
0
 

Author Comment

by:d_p2
ID: 2484279
Sorry vbyuval, jeremyd answered the question.  However, thank you very much for your suggestion!

Thanks a lot!

Best regards
Doris
0
 

Accepted Solution

by:
jeremyd earned 400 total points
ID: 2486613
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
 
LVL 1

Expert Comment

by:vbyuval
ID: 2490110
That's fine with me !
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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

598 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