Guten Morgen,
habe am Wochenende versucht, meine Anwendung an einen HDMI Monitor (28 Zoll) anzupassen.
Einstellung: 3.840 x 2.160; Skalierung 200%
Die Einträge in der Mainifest und App.config habe ich gemacht und die Anwendung startet auch mit der hohen Auflösung.
Da das Programm von mehreren Personen genutzt wird, gibt es ein Setting für Schriftname und Schriftgrösse.
Bevor eine Form sichtbar wird, durchläuft es eine Sub und weisst der Form die Schrift zu.
Die Formen haben zu 90% den gleichen Aufbau.
Auf der Form liegt ein TableLayoutPanel.
2 Spalten, jeweils 50%.
Zeile1: Absolut 20 Pixel (Inhalt: ToolStripmenu; Dock Fill)
Zeile2: Absolut 30 Pixel (Inhalt: Panel, Dock Fill)
Zeile3: 100% (Inhalt Spalte1: Datagridview, Spalte2: Panel; beide Dock Fill)
Die Controls bzw. das Toolstripmenue in den Zeilen 1 und 2 (Absolut) passen sich nicht wirklich an.
Oft liegt in Zeile 2 ein TabControl. Die Darstellung ist auch hier fehlerhaft.
Spoiler anzeigen
Ändern des AutoScaleMode bringt auch keinen Erfolg.
habe am Wochenende versucht, meine Anwendung an einen HDMI Monitor (28 Zoll) anzupassen.
Einstellung: 3.840 x 2.160; Skalierung 200%
Die Einträge in der Mainifest und App.config habe ich gemacht und die Anwendung startet auch mit der hohen Auflösung.
Da das Programm von mehreren Personen genutzt wird, gibt es ein Setting für Schriftname und Schriftgrösse.
Bevor eine Form sichtbar wird, durchläuft es eine Sub und weisst der Form die Schrift zu.
Die Formen haben zu 90% den gleichen Aufbau.
Auf der Form liegt ein TableLayoutPanel.
2 Spalten, jeweils 50%.
Zeile1: Absolut 20 Pixel (Inhalt: ToolStripmenu; Dock Fill)
Zeile2: Absolut 30 Pixel (Inhalt: Panel, Dock Fill)
Zeile3: 100% (Inhalt Spalte1: Datagridview, Spalte2: Panel; beide Dock Fill)
Die Controls bzw. das Toolstripmenue in den Zeilen 1 und 2 (Absolut) passen sich nicht wirklich an.
Oft liegt in Zeile 2 ein TabControl. Die Darstellung ist auch hier fehlerhaft.
VB.NET-Quellcode
- Public Sub Form_Initalisieren(ByVal WinForm As Form, Optional Journalschreiben As Boolean = True, Optional Ladungsanzeige As Boolean = False)
- AppForm = WinForm
- If FormLadung.Visible Then FormLadung.Close()
- If Ladungsanzeige Then
- FormLadung.Label_Ausgabe.Text = "Öffne " & WinForm.Text & " ..."
- FormLadung.Show()
- FormLadung.Label_Ausgabe.Refresh()
- End If
- With WinForm
- .Visible = False
- .Opacity = 0
- .Visible = True
- .Font = Schrift
- .ShowInTaskbar = False
- ' .AutoScaleMode = AutoScaleMode.Dpi
- End With
- ' ControlsDurchlaufen(WinForm)
- ' Exit Sub
- For Each Element As Control In WinForm.Controls
- Element.Font = Schrift
- For Each Tpl As Control In Element.Controls
- Tpl.Font = Schrift
- For Each Pan As Control In Tpl.Controls
- Pan.Font = Schrift
- Next Pan
- Next Tpl
- Next Element
- For Each TSM As ToolStrip In WinForm.Controls.OfType(Of ToolStrip)()
- TSM.BackColor = Farbe_Toolstrip
- TSM.Font = Schrift
- For Each TSLabel As ToolStripLabel In TSM.Items.OfType(Of ToolStripLabel)
- If TSLabel.Name = "TS_Copyright" Then
- TSLabel.Text = Vorlagen.Copyright_Kurz
- TSLabel.ToolTipText = Vorlagen.Copyright_Lang
- End If
- Next TSLabel
- SystemToolstrip_Formatieren(TSM, Schrift, Farbe_Toolstrip)
- Next TSM
- For Each TLPanel As TableLayoutPanel In WinForm.Controls.OfType(Of TableLayoutPanel)
- TLPanel.Font = Schrift
- For Each TDGV As DataGridView In TLPanel.Controls.OfType(Of DataGridView)
- With TDGV
- .DefaultCellStyle.Font = Schrift
- .ColumnHeadersDefaultCellStyle.Font = Schrift
- End With
- Next TDGV
- 'For Each MePanel As Panel In TLPanel.Controls.OfType(Of Panel)
- ' MePanel.Font = Schrift
- 'Next MePanel
- For Each TSM As ToolStrip In TLPanel.Controls.OfType(Of ToolStrip)()
- 'For Each PPanel As Panel In TLPanel.Controls.OfType(Of Panel)
- ' PPanel.Font = Schrift
- ' For Each TTBox As TextBox In PPanel.Controls.OfType(Of TextBox)
- ' TTBox.Font = Schrift
- ' Next TTBox
- ' For Each TLabel As Label In PPanel.Controls.OfType(Of Label)
- ' TLabel.Font = Schrift
- ' Next TLabel
- 'Next PPanel
- TSM.BackColor = Farbe_Toolstrip
- TSM.Font = Schrift
- For Each TSLabel As ToolStripLabel In TSM.Items.OfType(Of ToolStripLabel)
- If TSLabel.Name = "TS_Copyright" Then
- TSLabel.Text = Vorlagen.Copyright_Kurz
- TSLabel.ToolTipText = Vorlagen.Copyright_Lang
- End If
- Next TSLabel
- SystemToolstrip_Formatieren(TSM, Schrift, Farbe_Toolstrip)
- Next TSM
- Next TLPanel
- If Journalschreiben Then Journal.Programm.Schreiben("Öffne App " & WinForm.Name)
- End Sub
- Public Sub SystemToolstrip_Formatieren(ByVal SysToolStrip As ToolStrip, ByVal SchriftTS As Font, ByVal FarbeTS As Color)
- SysToolStrip.BackColor = FarbeTS
- SysToolStrip.Font = SchriftTS
- Dim HForm As Form = SysToolStrip.FindForm
- For Each _Label In SysToolStrip.Items.OfType(Of ToolStripLabel)()
- With _Label
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- Next
- For Each _Seperator In SysToolStrip.Items.OfType(Of ToolStripSeparator)()
- With _Seperator
- .BackColor = FarbeTS
- .ForeColor = FarbeTS
- End With
- Next
- For Each _Textbox In SysToolStrip.Items.OfType(Of ToolStripTextBox)()
- With _Textbox
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- Next
- For Each _Button In SysToolStrip.Items.OfType(Of ToolStripButton)()
- With _Button
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- Next
- For Each _Combobox In SysToolStrip.Items.OfType(Of ToolStripComboBox)()
- With _Combobox
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- Next
- For Each _DDButton In SysToolStrip.Items.OfType(Of ToolStripDropDownButton)()
- With _DDButton
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- For Each _MenueItem In _DDButton.DropDownItems.OfType(Of ToolStripMenuItem)()
- With _MenueItem
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- SystemToolStrip_Formatieren_SubItems(_MenueItem, HForm, SchriftTS, FarbeTS)
- Next
- Next
- For Each _Splitbutton In SysToolStrip.Items.OfType(Of ToolStripSplitButton)()
- With _Splitbutton
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- For Each _MenueItem In _Splitbutton.DropDownItems.OfType(Of ToolStripMenuItem)()
- With _MenueItem
- .BackColor = FarbeTS
- .Font = Font.FromHfont(SchriftTS.ToHfont)
- End With
- SystemToolStrip_Formatieren_SubItems(_MenueItem, HForm, SchriftTS, FarbeTS)
- Next
- Next
- End Sub
- Private Sub SystemToolStrip_Formatieren_SubItems(ByVal Eintrag As ToolStripMenuItem, HForm As Form, ItemSchrift As Font, ItemFarbe As Color)
- For Each _SubMenueItem In Eintrag.DropDownItems.OfType(Of ToolStripMenuItem)()
- With _SubMenueItem
- .BackColor = ItemFarbe
- .Font = Font.FromHfont(ItemSchrift.ToHfont)
- End With
- SystemToolStrip_Formatieren_SubItems(_SubMenueItem, HForm, ItemSchrift, ItemFarbe)
- Next
- End Sub
Ändern des AutoScaleMode bringt auch keinen Erfolg.
Gruß Markus