LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Minimize and maximize buttons userforms

I had heard about "It is the economy stupid", but not this one.
It is is simple enough for me though.
The only thing I haven't figured out yet is how to get the focus in a
treeview
control when I press the restore up button from the minimized position.
Tried numerous construction, but no success yet.

RBS


"Tom Ogilvy" wrote in message
...
In the US it is a common acronym meaning:

Keep it simple stupid

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote in message
...
This is a very busy userform and I don't want to add another label or
textbox.
Also the titlebar is just nice for this purpose as it stands out and is
clear.
It is no trouble as all I have to do is add the line AddMinMax after any
code
that alters the caption.

I tend to subscribe to KISS personally


What is that?

RBS


"Bob Phillips" wrote in message
...
I appreciate that it doesn't solve the problem, but would it not have

been
better (easier?) to have a status area and display your messages there
rather than change the caption. I tend to subscribe to KISS personally.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...

Two answers.

I use the userform title bar (caption) to display all kind of messages
for
the users.

Public Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

RBS


"Bob Phillips" wrote in message
...
Two questions.

Why do you need to change the caption?

Where is DrawMenuBar defined?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
I think I have this now all worked out.
This is the code that does it:


Private Declare Function GetWindowLong _
Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) 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 Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const GWL_STYLE = (-16)

Sub AddMinMax()

Dim hWnd As Long
Dim lngStyle As Long

hWnd = FindWindow(vbNullString, MainForm.Caption)

lngStyle = GetWindowLong(hWnd, GWL_STYLE)
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or WS_MINIMIZEBOX
SetWindowLong hWnd, GWL_STYLE, lngStyle

DrawMenuBar hWnd

End Sub

Just have to run AddMinMax from the Userform Activate event and

after
any
code that alters the caption
of the userform via Userform.Caption =
It works very nice indeed.
Just have to make my keyboard shortcuts now to run these menubar
buttons.


RBS


"RB Smissaert" wrote in message
...
How do I add minimize and maximize buttons to a VBA userform?
I have this code that does it, but when I change the caption of

the
userform
the buttons don't work anymore. I am slowly coming to the

conclusion
that
it probably is not worth the trouble and that it is better to
make
your
own buttons.

Public Declare Function FindWindow _
Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As Long, _
ByVal lpWindowName 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 Sub UserForm_Initialize()

Dim hWnd as Long

hWnd = FindWindow(vbNullString, UserForm1.Caption)
SetWindowLong hWnd, -16, &H20000 Or &H10000 Or &H84C80080

End Sub


RBS











 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
minimize and maximize buttons missing KR4d Excel Discussion (Misc queries) 8 October 9th 09 03:32 PM
how do i minimize/maximize a workbook from vba? I want to minimize it durring processing to speed things up a bit Daniel Excel Worksheet Functions 2 July 9th 05 03:35 AM
Maximize & Minimize where are you ? Don Bowyer Excel Programming 2 July 18th 04 02:41 PM
Maximize & Minimize buttons where are they? Don Bowyer Excel Programming 3 July 18th 04 01:28 AM
How to get Maximize and Minimize buttons on Userform TBA[_2_] Excel Programming 1 September 9th 03 08:13 PM


All times are GMT +1. The time now is 09:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"