2017-01-28 9 views
0

vb.netを使用して小さなフチ無しフォームを作成しました。フォームには3つのスクエアボタンがあります。フォームのサイズは(93,31)です。フォームの設計時にはすべて役に立ちますが、プログラムを実行するとフォームのサイズがいくらか(98,34)増えます。私はフォームの自動サイズ設定プロパティでtrueとfalseの間で切り替えて、それが問題の原因であるかどうかを確認しましたが、そのような助けが助けになります。
フォームのサイズ変更を中止するにはどうすればよいですか?ボーダレスフォームは、実行時に自動的にサイズが変更されます。vb.net。

EDIT:
コード

Public Class OSD_Dialog 

Dim drag As Boolean 
Dim mousex As Integer 
Dim mousey As Integer 

' The folllowing three subs are helpfull in making the form dragable 

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown 
    drag = True 
    mousex = Windows.Forms.Cursor.Position.X - Me.Left 
    mousey = Windows.Forms.Cursor.Position.Y - Me.Top 
End Sub 

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove 
    If drag Then 
     Me.Top = Windows.Forms.Cursor.Position.Y - mousey 
     Me.Left = Windows.Forms.Cursor.Position.X - mousex 
    End If 
End Sub 

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp 
    drag = False 
End Sub 

'The following sub is helpful in creating an outline on the border of the form 

Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs) 
    MyBase.OnPaintBackground(e) 

    Dim rect As New Rectangle(0, 0, Me.ClientSize.Width - 1, Me.ClientSize.Height - 1) 

    e.Graphics.DrawRectangle(Pens.White, rect) 
End Sub 

Private Sub OSD_Dialog_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    Me.TopMost = True 
    Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) 

    Me.BackColor = Color.Red 
    TransparencyKey = BackColor 

End Sub 
+0

私たちに見せるためにいくつかのコードを追加できますか? – Faegy

+0

フォームボーダーレスをどのように設定しましたか(どのプロパティを設定しましたか)? –

+0

@ S.SerpフォームのFormBorderStyleプロパティをNoneに設定してフォームをボーダレスにしました – Wiz

答えて

1

があなたのForm_Loadイベントにこれを追加だ、私はここではなし

に、フォームのFormBorderStyleプロパティを設定することにより、フォームのボーダレスを作った:

Me.Size = New Size(93, 31) 

また、設計時にAutoScaleModeを 'なし'に設定していることを確認してくださいe

+0

ありがとうございました。これは "this"を "Me"に置き換え、セミコロンとその中括弧を削除するだけで魅力的でした。 – Wiz

+0

私はそれがC#の構文のように即座に更新されました。とにかく、それがあなたを助けてくれてうれしいです –

関連する問題