Create a maximize & minimize button in userform

User avatar
HansV
Administrator
Posts: 78596
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create a maximize & minimize button in userform

Post by HansV »

In my Excel 2007, your code does that, but it's useless, as I pointed out.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Create a maximize & minimize button in userform

Post by VegasNath »

Try this:
You do not have the required permissions to view the files attached to this post.
:wales: Nathan :uk:
There's no place like home.....

User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Re: Create a maximize & minimize button in userform

Post by adam »

I guess now I got what I was searching for. Thanks Nathan. I appriciate your help. I dont see any difference in this code. I guess the foreward or backwared button is added. Anyway thanks for the help once again.
Best Regards,
Adam

User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Re: Create a maximize & minimize button in userform

Post by adam »

Which lines should I remove If I want the maximize button to be removed from the form? when the form is maximized it looks pretty annoying.
Any suggestions would be kindly appreciated.
Best Regards,
Adam

User avatar
HansV
Administrator
Posts: 78596
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create a maximize & minimize button in userform

Post by HansV »

The lines that modify the title bar are

Code: Select all

    lngCurrentStyle = GetWindowLong(lngHwnd, GWL_STYLE)
    lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
    lngNewStyle = lngNewStyle And Not WS_VISIBLE And Not WS_POPUP
    SetWindowLong lngHwnd, GWL_STYLE, lngNewStyle
It's easy to see what you should do to remove, or rather disable, the maximize button.
Best wishes,
Hans

User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Re: Create a maximize & minimize button in userform

Post by adam »

It's easy to see what you should do to remove, or rather disable, the maximize button.
Does the above refer to remove the text

Code: Select all

Or WS_MAXIMIZEBOX
From the line

Code: Select all

lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
Best Regards,
Adam

User avatar
HansV
Administrator
Posts: 78596
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create a maximize & minimize button in userform

Post by HansV »

Why don't you try it? :smile:

If it does what you want, fine. If it doesn't, it's easy to restore the code.
Best wishes,
Hans

User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Re: Create a maximize & minimize button in userform

Post by adam »

I did & It works. Just thought It might give me some error messages. That's why wanted to get a clarification from you.
Best Regards,
Adam