RIDIMENSIONAMENTO FORM E CONTROLLI

lunedì 15 settembre 2008 - 12.48

dandi Profilo | Newbie

Ciao a tutti ho urgente bisogno di un aiuto.... ho creato un'applicazione con il mio pc usanado una risoluzione molto alta ( da ignorante ) ora quando la installo su altri pc che utilizzano una risoluzione più bassa alcuni controlli non vengono visualizzati... vorrei sapere se qualcuno di vuoi conosce un metodo per poter ridimensionare un form e tutti i componenti che esso contiene in proporzione alla risoluzione dello schermo utilizzata.... grazie a tutti coloro che mi risponderanno!

SSUPERPIPPO Profilo | Guru

.NET mette a disposizione le proprietà Anchor e Dock per ancorare i controlli all'oggetto contenitore in modo che se questo viene ridimensionato automaticamente questi, in base alle impostazioni scelte, si adattano.

Se la proprietà WindowsState del tuo Form è impostata su Maximize allora la tua form automaticamente prenderà la dimensione massima visibile rispetto alla risulzione corrente (full screen) e i controlli, se correttamente ancorati (con Anchor e Dock), si autoridimensionareranno.

Ciao

Alessandro

http://blogs.dotnethell.it/alebadalin

dandi Profilo | Newbie

avevo già provato questa soluzione ma niente da fare.... se creo un form avendo risoluzione 1280x800 e lo visualizzo con una risoluzione 800x600 il form e i componenti al suo interno non vengono ridimensionati..... cmq grazie lo stesso

sergio58 Profilo | Junior Member

So che esiste GetSystemMetrics con SM_CXFULLSCREEN e SM_CYFULLSCREEN per
ottenere la risoluzione del tuo monitor e poi la SHAppBarMessage con
ABM_GETTASKBARPOS
Prova a guardare qui:
http://msdn.microsoft.com/en-us/library/ms724947.aspx
Oppure:
Dim coord As System.Drawing.Rectangle
coord = Screen.GetWorkingArea(coord)

in coord.bottom o .height hai l'altezza massima, quindi la dimensione dello
schermo

Imports System Imports System.Runtime.InteropServices Public Class Form1 <StructLayout(LayoutKind.Sequential)> _ Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Structure APPBARDATA Public cbSize As Integer Public hWnd As IntPtr Public uCallbackMessage As Integer Public uEdge As Integer Public rc As RECT Public lParam As IntPtr End Structure Enum ABMsg As Integer ABM_NEW = 0 ABM_REMOVE = 1 ABM_QUERYPOS = 2 ABM_SETPOS = 3 ABM_GETSTATE = 4 ABM_GETTASKBARPOS = 5 ABM_ACTIVATE = 6 ABM_GETAUTOHIDEBAR = 7 ABM_SETAUTOHIDEBAR = 8 ABM_WINDOWPOSCHANGED = 9 ABM_SETSTATE = 10 End Enum Enum ABEdge As Integer ABE_LEFT = 0 ABE_TOP ABE_RIGHT ABE_BOTTOM End Enum Enum ABState As Integer ABS_MANUAL = 0 ABS_AUTOHIDE = 1 ABS_ALWAYSONTOP = 2 ABS_AUTOHIDEANDONTOP = 3 End Enum Private Enum TaskBarEdge As Integer Bottom Top Left Right End Enum Private Declare Function SHAppBarMessage Lib "SHELL32" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As UInteger Private Sub GetTaskBarInfo(ByRef taskBarEdge As TaskBarEdge, ByRef height As Integer, ByRef autoHide As Boolean) Dim abd As APPBARDATA = New APPBARDATA height = 0 taskBarEdge = TaskBarEdge.Bottom autoHide = False Dim ret As UInteger = SHAppBarMessage(CType(ABMsg.ABM_GETTASKBARPOS, Integer), abd) Select Case (abd.uEdge) Case CType(ABEdge.ABE_BOTTOM, Integer) taskBarEdge = TaskBarEdge.Bottom height = (abd.rc.bottom - abd.rc.top) Case CType(ABEdge.ABE_TOP, Integer) taskBarEdge = TaskBarEdge.Top height = abd.rc.bottom Case CType(ABEdge.ABE_LEFT, Integer) taskBarEdge = TaskBarEdge.Left height = (abd.rc.right - abd.rc.left) Case CType(ABEdge.ABE_RIGHT, Integer) taskBarEdge = TaskBarEdge.Right height = (abd.rc.right - abd.rc.left) End Select abd = New APPBARDATA Dim uState As UInteger = SHAppBarMessage(CType(ABMsg.ABM_GETSTATE, Integer), abd) Select Case (uState) Case CType(ABState.ABS_ALWAYSONTOP, Integer) autoHide = False Case CType(ABState.ABS_AUTOHIDE, Integer) autoHide = True Case CType(ABState.ABS_AUTOHIDEANDONTOP, Integer) autoHide = True Case CType(ABState.ABS_MANUAL, Integer) autoHide = False End Select End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lato As TaskBarEdge Dim altezza As Integer Dim stato As Integer GetTaskBarInfo(lato, altezza, stato) Dim coord As System.Drawing.Rectangle coord = Screen.GetWorkingArea(coord) End Sub End Class
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5