|
-
Jun 30th, 2005, 09:58 AM
#1
Thread Starter
Lively Member
API Minimize through Code?
I have an altered Userform that can be minimized and maximized through the API similar to code used in this thread:
http://www.vbforums.com/showthread.php?t=243829
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong 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 GWL_STYLE = (-16)
Private Sub AddMinBox()
' Add minimize button to UserForm.
Dim hWnd As Long
Select Case Int(Val(Application.Version))
Case 8 ' Office 97.
hWnd = FindWindow("ThunderXFrame", vbNullString)
Case 9, 10 ' Office 2000, XP
hWnd = FindWindow("ThunderDFrame", vbNullString)
End Select
SetWindowLong hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) Or WS_MINIMIZEBOX
End Sub
Private Sub UserForm_Initialize()
AddMinBox
End Sub
What I need to be able to do is flip back and forth between the open form and the spreadsheet. I can't close the form and save variable info to globals, because the form only has one control: an ActiveX Reflections Console control that needs to stay open.
The form is modeless but is still "always on top" so that even though I can interact with the spreadsheet, the form is in the way. This is why I made the form minimizable so to speak.
Problem is, I have no idea how to minimze the form with code. It will not be obvious enough to the user to minimize the window themselves when needed, and I want the program to do it. Please let there be some genius here that can help me. I'll even take alternate solutions.
Thanks,
Last edited by mikeyc1204; Jun 30th, 2005 at 10:16 AM.
-
Jun 30th, 2005, 10:27 AM
#2
Re: API Minimize through Code?
Not too sure, but can you not just hide the form (me.visible=false) until the user selects an icon on the tray or something? Or if it is excel, perhaps a menu button or a button on the spreadsheet to hide/show the form??
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 30th, 2005, 10:42 AM
#3
Thread Starter
Lively Member
Re: API Minimize through Code?
That was my first thought too. Who knew you can't change a userform's 'visible' property?
Compile error:
Function or interface marked as restricted, or the function uses and Automation type not supported in Visual Basic
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
|