It is OK to set the FormBorderStyle property in the Properties window of the Vs.net IDE in the design mode.
In the running mode you can use the code to complete:
Dlgbx1.formborderstyle = System.Windows.Forms.FormBorderStyle.FixedDialog
These seven types of boundary type VB6, there is no big change in the running mode you need to control different enumeration variables to set.
2. How to create a transparent from
There are two ways you can do this at design time and run time.
At design time, you can set the Opacity property in the Vs.net IDE's Properties window to achieve this effect. This value is from 0.0 to 1.0. 0 means full transparency, and 1.0 means completely opaque.
Run time you can use the following code to set the form's opactiy properties to do. Specific:
frmtransparentform.opacity = 0.76; (C #)
It's easy to see now that you don't have to know any alpha variables anymore. Transparency is always an effect, don't abuse it.
3. How to set the position of the form on the screen
You can set the StartPosition property of the form, VS. NET generally gives you a conservative option of "windowsdefaultlocation" so that the system will determine a value based on the user's current computer settings in the Load form, or you can change it to another value "Center" at design time.
If you have to make sure that the form appears on the screen in a design way you can set StartPosition to manual and then set the location x and Y values.
The runtime seems to be more concise with code implementations:
Form1.location = new Point (vb.net)
Of course you can also modify the x and Y values of the location separately, corresponding to the left and top properties of the form, such as:
Form1.left + (vb.net)
Form1.top = (vb.net)
Another property will also affect the position of the form on the screen: Desktoplocation This property is very useful when you set up the form position relative to the taskbar (when you put the taskbar on top or left of the screen, you actually change the desktop coordinates (0,0) So you can set this property that doesn't appear in the Design Properties window,
Form1.desktoplocation = new Point (100,100)
The position of the form on the screen will depend primarily on the specific hardware and settings of the individual user, so the conservative approach is to use the default "WindowsDefaultLocation" or "Center"; the professional approach is to get the system settings and then encode the dynamic calculation after the setting, Otherwise it's easy to find your form on the screen.
4. How to make minimized and maximize buttons unavailable
The Form.minimizebox and form.maximizebox of the form are displayed when True, and false is not. See below programmatically:
Frmmaxmin.minnimizebox = False (vb.net)
Frmmaxmin.maxmnimizebox = True (vb.net)
5. How to make a form disappear
I think the most direct way is for you to call the Hide () method to do this. But I want to provide another way, and then you will get some other inspiration. (vb.net)
Private Const Ws_ex_toolwindow as Int32 = &h80
Private Const ws_popup as Int32 = &h80000000
Private Const ws_visible as Int32 = &h10000000
Private Const ws_sysmenu as Int32 = &h80000
Private Const ws_maximizebox as Int32 = &h10000
Protected Overrides ReadOnly Property CreateParams () as System.Windows.Forms.CreateParams
Dim CP as System.Windows.Forms.CreateParams
CP = Mybase.createparams
Cp. ExStyle = Ws_ex_toolwindow
Cp. Style = Ws_popup or ws_visible or Ws_sysmenu or Ws_maximizebox
Cp. Height = 0
Cp. Width = 0
It turns out that the height and width are set to 0, and I think this approach may be different from the bottom of the hide () call.
6. How to set the form to be non rectangular.
The problem I think I'm not offering is the most professional, at least it's not what I expected, which means it's going to turn back into a rectangle in some events. But at least I can tell you this: if you try to call the original Win32 ' s API setwindowrng, I've tried so much. Now you may need to know about the region property of a form
Public Sub setwindowregion ()
Dim Formpath as System.Drawing.Drawing2D.GraphicsPath
Dim Reg as Drawing.region
Dim Lret as Long
Formpath = New Drawing2d.graphicspath ()
Formpath.addellipse (New Rectangle (0, 0, 250, 120))
Me.region = New Region (formpath)
Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Me.region = Nothing
Protected Overrides Sub OnResize (ByVal e as System.EventArgs)
Me.region = Nothing
7. How to make a form at the top of the screen.
This is a very useful feature, and now you don't have to call other APIs, just set the topmost property to true. This property can be modified at design time and run-time. Code mode:
Mytopform.topmost = True (vb.net)
8. How to display a form of model and non-model
The form of model and modeless will mainly depend on your application, most of which is used in the Display dialog box. You call MyForm when you need the model form. ShowDialog instead of the model call Myform.show, there is an optional parameter for ShowDialog ower lets you establish a parent-child relationship for a form. For example:
' Visual Basic
Private Sub mnuabout_click (... args ...)
Dim F as New formoption
One thing to note is that for ShowDialog, when executed to this sentence, the form is displayed, but the code that follows will not be executed until the window is closed, and is instantaneous for show, and the following code will be executed immediately after the display of the form.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.