# Easy VB6 Questions

This topic is 4687 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Using VB6, I have been making a simple text/html editor. I have a few questions which are very basic and easy to answer regarding forms. 1) How do you set it up so that a form maximizes only to the height of the screen without the start bar, so that it will stop before some of it becomes hidden? 2) How can you prevent the user from resizing the window to a size less that a certain number? Resetting it is very choppy, and I'm wondering if there's a better way. 3) Is there a basic way to calculate a form's width without including the title and menu bar?

##### Share on other sites
Quote:
 Original post by gamechampionx1) How do you set it up so that a form maximizes only to the height of the screen without the start bar, so that it will stop before some of it becomes hidden?

This is default behavior, you don't have to do anything. Note that the form editor will allow you to place controls outside the space that's on screen, and that this is generally a bad idea.

Quote:
 2) How can you prevent the user from resizing the window to a size less that a certain number? Resetting it is very choppy, and I'm wondering if there's a better way.

If you set the borderstyle of the window to 1 ('fixed single') rather than 2 ('sizeable'), the user will be unable to resize your form. If you do this, the minimise button will be hidden by default, you'll need to reenable it if you want it available. If you wish to still allow them to resize the form, but stop it from going below a certain height, you'll need to put code into the Form_Resize sub; You'll want to check the height/width, and if they are below a certain value, reset them to your minimum size. As you've mentioned, this is quite choppy, but there isn't really a better way.

Quote:
 3) Is there a basic way to calculate a form's width without including the title and menu bar?

I assume you mean height? You want the scaleheight property; It's the height of the area within the borders and titlebar.

##### Share on other sites
Thanks, I was able to make the window adjust properly with that information.

I have one followup question about Common Dialogue stuff. How can you tell if an Open box has ReadOnly selected? I can't seem to find the way of determining that. Also, what kind of behaviour are you supposed to give it? Like, can you change it at all? Should you be able to save only as a different file, which seems hard since you can essentially save over any file?

Is there a way to disable this feature from the box?

##### Share on other sites
You setup the common dialogs properties... ill give you a little example, excuse my vb i havent used in awhile...

create a form with a button and a common dialogs control with default names. when you click the button it will show the open menu with readonly checked.

Private Sub Command1_Click()CommonDialog1.flags = cdlOFNReadOnlyCommonDialog1.ShowOpenText1.Text = CommonDialog1.FileNameEnd Sub

if you save files as read only you can have the open box not show them. i think you do something like

You can find out more by opening up your project that includes mscommon dialog and pressing F2 for the object browser, in the top dropdown goto MSCommonDialog youll be able to look at all the associated properties methods and constants.

##### Share on other sites
Is there any way to prevent this check box from even showing up on the Open dialogue box? It doesn't show on the SaveAs, so what's the point? My application is very simple and I don't really want to delve into this topic too much.

##### Share on other sites
2In save as if the file you opened was read only you wwont be able to save over it, as well as anyother readonly files.