Hallo Forum,
folgendes Problem. ALso ich habe mir ein Formular gebaut das etwas länger ist ca. 2 17' Bildschirmlängen.Ich möchte gerne das das Formular bei jeder Bildschirmgröße zentriert ist. Mit welchem Befehl schaffe ich das?
Mein Zweites Problem ist das Drucken. Ich möchte die ersten 2 Frames auf ein Blatt drucken. Das Drucken an sich funktioniert jedoch nicht die Position sowie die Größe. Es wird immer egal wo ich mich auf dem Bildschirm befinde oben links die Monitorecke als Startbereich zum Drucken genommen. Aus diesem Grund wird das Formular nur zu 3/4 gedruckt.
Meine Codeabschnitte:
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = -16
Private Const GWL_EXSTYLE As Long = -20
Private Const WS_CAPTION As Long = &HC00000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_POPUP As Long = &H80000000
Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_EX_DLGMODALFRAME As Long = &H1
Private Const WS_EX_APPWINDOW As Long = &H40000
Private Const SW_SHOW As Long = 5
Dim g_hForm As Long
Dim maxi As Boolean
Dim maxiT As Boolean
Dim OldWidth As Single, OldHeight As Single, OldTop As Single, OldLeft As Single
Private Declare Function MapVirtualKey Lib "user32.dll" Alias "MapVirtualKeyA" ( _
ByVal wCode As Long, _
ByVal wMapType As Long) As Long
Private Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_MENU = &H12
Private Const lngMargin = 1 'Breite der Seitenränder in cm
Private Sub UserForm_Activate()
Dim lngCurrentStyle As Long, lngNewStyle As Long
If Val(Application.Version) < 9 Then
g_hForm = FindWindow("ThunderXFrame", Me.Caption)
Else
g_hForm = FindWindow("ThunderDFrame", Me.Caption)
End If
lngCurrentStyle = GetWindowLong(g_hForm, GWL_STYLE)
lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
lngNewStyle = lngNewStyle And Not WS_VISIBLE And Not WS_POPUP
SetWindowLong g_hForm, GWL_STYLE, lngNewStyle
lngCurrentStyle = GetWindowLong(g_hForm, GWL_EXSTYLE)
lngNewStyle = lngCurrentStyle Or WS_EX_APPWINDOW
SetWindowLong g_hForm, GWL_EXSTYLE, lngNewStyle
ShowWindow g_hForm, SW_SHOW
End Sub
Private Sub UserForm_Initialize()
'ComboBox mit Werten füllen
cboInfoBereich.AddItem "Finance"
cboInfoBereich.AddItem "Production"
cboInfoBereich.AddItem "Sales"
Dim Style As Long
g_hForm = FindWindow(vbNullString, Me.Caption)
SetWindowLong g_hForm, -16, &H20000 Or &H10000 Or &H84C80080
Style = GetWindowLong(g_hForm, -16) And Not &HC00000
SetWindowLong g_hForm, -16, Style
DrawMenuBar g_hForm
If maxiT Then
Me.Move OldLeft, OldTop, OldWidth, OldHeight
maxiT = False
' Schließe.Left = Me.Width - 50
'Label111.Left = Me.Width - 70
Else
OldWidth = frmKlassifizierung.Width
OldHeight = frmKlassifizierung.Height
OldTop = frmKlassifizierung.Top
OldLeft = frmKlassifizierung.Left
Me.Move 0, 0, GetSystemMetrics(0) * 0.75, (GetSystemMetrics(1) - 30) * 0.75
maxiT = True
'Schließe.Left = Me.Width - 50
'Label111.Left = Me.Width - 70
End If
End Sub
Grüße Louis
|