Click to See Complete Forum and Search --> : Form resizing


Kdev
April 25th, 2001, 03:15 PM
I designed my application to run on a 2nd monitor as a progress indicator. There really is no interaction with the user after starting it. I designed the form to take up the full screen and to have no border. However, I would like to make this useable in a windowed state if the user only has 1 monitor configured on the system. I have code to detect if there is only 1 monitor and then it should set the form to have a sizeable border. Here is the example:

If lMonitors = 1 then
me.BorderStyle = 2
me.ScaleHeight = 573
me.ScaleWidth = 792
End If



This code works to the extent that if I check the values of the above properties at run time they are set to the new values (Normal values are BorderStyle = 0, ScaleWidth = 800, ScaleHeight = 600). However, the form does not seem to have a border. What is the best way to go about this sort of thing?

-K

softweng
April 25th, 2001, 05:38 PM
I have never tried it, but you will probably need to put the code for setting the border and size
in the Form_Load event or Form_Initialize event to get it to work.


Kris
Software Engineer
Phoenix,AZ

shree
April 26th, 2001, 08:16 AM
The borderstyle of a form doesn't change at run time. Instead, use the following workaround:

Set the ControlBox property to false.

When you want the full screen borderless mode, set

frmProgress.Caption = ""

The title bar will disappear.
When you want the tile bar back, set the caption to something other than ""

The drawback of this method is that the form will have no control box, and I think it won't make much of a difference because the user is not interacting much with this form. If you need to provide the user a method of unloading this form, use a button.

slcotten
April 26th, 2001, 01:56 PM
As indicated by an earlier reply, the BorderStyle property of a form is normally read-only at run-time. However using the Windows API that can be worked around. You can use the SendMessage API function. I would suggest taking a look at http://www.mvps.org/vb/ Click on the link "Samples" on the left and then scroll to the heading that says "FormBrdr.zip" (or something like that... I can't remember exactly right now). Anyway hope that accomplishes what you're looking for.