none
Projektvorlage erstellen, bei VB2008? RRS feed

  • Frage

  • Hallo,

    Ich möchte, wenn ich auf Neues Projekt klicke, dass ich eine Vorlage erstellen kann, die immer folgenden Code am anfang hat:

    <Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure MARGINS
      Public cxLeftWidth As Integer
      Public cxRightWidth As Integer
      Public cyTopHeight As Integer
      Public cyButtomheight As Integer
    End Structure
    Public Class Form1
      Dim lStartPos As Point
    
      Private Sub Form1_MouseDown(ByVal sender As Object, _
             ByVal e As System.Windows.Forms.MouseEventArgs _
               ) Handles Me.MouseDown
    
        If e.Button = Windows.Forms.MouseButtons.Left Then
          lStartPos = e.Location
        End If
      End Sub
    
      Private Sub Form1_MouseMove(ByVal sender As Object, _
             ByVal e As System.Windows.Forms.MouseEventArgs _
               ) Handles Me.MouseMove
    
        If e.Button = Windows.Forms.MouseButtons.Left Then
          Dim lDelta As New Point(e.Location.X - lStartPos.X, e.Location.Y - lStartPos.Y)
          Dim lNewPos = New Point(Me.Location.X + lDelta.X, Me.Location.Y + lDelta.Y)
    
          Me.Location = lNewPos
        End If
      End Sub
      Public Declare Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" (ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
          Me.TransparencyKey = Color.PowderBlue
          Me.BackColor = Color.PowderBlue
          'Wichtig: Die TransparencyKey darf kein Grauton sein (also auch kein Weiß oder Schwarz)
          'sonst kann man wieder einmal durch die Form klicken.
    
          Dim margins As MARGINS = New MARGINS
          margins.cxLeftWidth = -1
          margins.cxRightWidth = -1
          margins.cyTopHeight = -1
          margins.cyButtomheight = -1
          'wenn alle werte -1 sind, ist alles im aero design
          Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, margins)
        Catch ex As Exception
          MsgBox(ex.Message)
        End Try
      End Sub
    End Class
    


    Danke im voraus.

    Freitag, 16. Juli 2010 12:25

Antworten

  • Hallo,

    Ich möchte, wenn ich auf Neues Projekt klicke, dass ich eine Vorlage erstellen kann, die immer folgenden Code am anfang hat:

    Du kannst das Projekt oder einen Eintrag daraus über das Menü Datei => als Vorlage exportieren. Ggf. wäre es aber auch eine Überlegung, dass Du Dir ein eigenes Basisformular erstellst, dies als eigenes Assembly oder Codefile in Deine Projekte einbeziehst und alle weiteren Formulare von Deinem erweitertem Formular ableitest, statt von System.Windows.Forms.Form.


    Thorsten Dörfler
    Microsoft MVP Visual Basic
    vb-faq.de
    • Als Antwort markiert MaSch0212 Freitag, 16. Juli 2010 13:08
    Freitag, 16. Juli 2010 12:59
    Moderator