Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimize on my own 2

Status
Not open for further replies.

WoodyRoundUp

Programmer
Feb 28, 2001
187
AU
Hi all.
How do I minimize a window using my own button and then maximise it?
I have done the minimize one by just simply put
WindowState = 1
I can't find the maximize one.
What should I do?

Woody
 
Constant Value Description

vbNormal 0 (Default) Normal.
vbMinimized 1 Minimized (minimized to an icon)
vbMaximized 2 Maximized (enlarged to maximum size)

 
Well, I don't mean this.
What I mean is how do I trigger the maximization of the window? Because after I minimize, and then, when I click the application on the task bar, it does not give me any reaction.
So, how do I put it to maximize?
The minimize button is on my own, not the VB one.

Thanks.
 
If I understand correctly you do the following...

Private Sub Command1_Click()
Me.WindowState = vbMinimized
End Sub

And then when you click the icon on the task bar, you want it to be maximized, even if the windowstate was normal prior to minimizing it?

 
Do you want to allow the user to normalize the form after you have maximized the form in code?
 
Maybe using ShowWindow() ?

This example has buttons to minimize, maximize and restore the window (in this case its own window).

Remedy

----------------------------

Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const WIN_MAXIMIZE = 3
Private Const WIN_MINIMIZE = 6
Private Const WIN_RESTORE = 9

Public Sub CallWindow(Frm As Form, ByVal Message As Long)

Dim liRetval As Long
liRetval = ShowWindow(Frm.hwnd, Message)
End Sub

Private Sub cmdMaximize_Click()
CallWindow Me, WIN_MAXIMIZE
End Sub

Private Sub cmdMinimize_Click()
CallWindow Me, WIN_MINIMIZE
End Sub

Private Sub cmdRestore_Click()
CallWindow Me, WIN_RESTORE
End Sub

 
If you just want to go from minimized to maximized, put code in the form_resize to check the value of WindowState...if windowstate is normal, change to maximize. If you want to allow normalized view, you may need to set a global flag to indicate whether the window was previously minimized before maximizing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top