|
-
Jan 5th, 2000, 05:49 AM
#1
Thread Starter
Lively Member
I everyone (again)! I am quite new to the Windows API, and wonder if anyone could show me some code to do this:
1) when one button is pressed to find all currently maximised windows and to minimise them.
2) when another button is pressed to maximise all the windows that I have just minimised.
I realise that if someone shows me how to do the first one I will probably be able to do the second.
Thanks in advance,
Mark
-
Jan 5th, 2000, 06:28 AM
#2
If you are talking about the windows in your app, you don't need to use an API. In Form1, just do Form2.WindowState = vbMinimized, and to return them to their previous state do Form2.WindowState = vbNormal
.
------------------
Marty
[This message has been edited by MartinLiss (edited 01-05-2000).]
-
Jan 5th, 2000, 06:32 AM
#3
Thread Starter
Lively Member
Thanks for trying to help, but this is not what I meant. I would like to be able to minimize other apps windows.
Thanks
-
Jan 5th, 2000, 06:34 AM
#4
Fanatic Member
Try this:
In Module:
Code:
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const WS_MINIMIZEBOX = &H20000
Private Const SW_MINIMIZE = 6
Private Const GWL_STYLE = (-16)
Public Function EnumProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
'Make sure the Window is Visible and Minimizable..
If IsWindowVisible(hwnd) Then
If (GetWindowLong(hwnd, GWL_STYLE) And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
'Minimize it
Call ShowWindow(hwnd, SW_MINIMIZE)
End If
End If
EnumProc = hwnd
End Function
In form
Code:
Private Sub Command1_Click()
Call EnumWindows(AddressOf EnumProc, 0)
End Sub
Hope this helps (HTH)
Regards
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 01-05-2000).]
-
Jan 5th, 2000, 06:44 AM
#5
Thread Starter
Lively Member
Thanks for this. However, the code does not work. I have followed your instructions and upon pressing the CommandButton, nothing happens. Any ideas?
-
Jan 5th, 2000, 06:46 AM
#6
Fanatic Member
Well it works on my machine. Are you sure you copied everything all right?
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
-
Jan 5th, 2000, 06:59 AM
#7
Thread Starter
Lively Member
Very sure. The button has no affect at all. Maybe you could email the project and see if that works, just incase I am doing something wrong, but I doubt it.
Thanks a lot
Mark
-
Jan 5th, 2000, 07:37 AM
#8
Member
Just for minimize all windows
Place a CommandButton onto Form1.
Copy and paste the following code into Form1's Code Window.
Code:
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B
Private Sub Command1_Click()
' 77 is the character code for the letter 'M'
Call keybd_event(VK_LWIN, 0, 0, 0)
Call keybd_event(77, 0, 0, 0)
Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub
Joon
[This message has been edited by jpark (edited 01-05-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|