Salve ragazzi,
vorrei sapere come e se si può calcolare l'altezza delle barra di windows.
Perchè io ho una form che è impostata com TopMost,quindi mi va sopra la barra, ma vorrei che ciò non accada.
Grazie
Salve ragazzi,
vorrei sapere come e se si può calcolare l'altezza delle barra di windows.
Perchè io ho una form che è impostata com TopMost,quindi mi va sopra la barra, ma vorrei che ciò non accada.
Grazie
Puoi ottenere/impostare i confini dell'area di lavoro (per intenderci, l'area che occupano le finestre massimizzate) con la property DWA.DesktopWorkingArea.
codice:using System; using System.Runtime.InteropServices; namespace SetDeskWA { /// <summary> /// Rectangle used by API functions /// </summary> public struct APIRectangle { public int Left; public int Top; public int Right; public int Bottom; public override string ToString() { return "{Left=" + Left.ToString() + ",Top=" + Top.ToString() + ",Right=" + Right.ToString() + ",Bottom=" + Bottom.ToString() + "}"; } public APIRectangle(int Left, int Top, int Right, int Bottom) { this.Left=Left; this.Top=Top; this.Right=Right; this.Bottom=Bottom; } }; /// <summary> /// Desktop Working Area routines /// </summary> public static class DWA { private const int SPI_SETWORKAREA = 47; private const int SPI_GETWORKAREA = 48; [DllImport("user32.dll")] private static extern bool SystemParametersInfo(int uiAction, int uiParam, ref APIRectangle rect, int fWinIni); public static APIRectangle DesktopWorkingArea { get { APIRectangle WA = new APIRectangle(); if(!SystemParametersInfo(SPI_GETWORKAREA,0,ref WA,0)) throw new System.ComponentModel.Win32Exception(); return WA; } set { if(!SystemParametersInfo(SPI_SETWORKAREA,0,ref value,0)) throw new System.ComponentModel.Win32Exception("Used rectangle: " + value.ToString()); } } } }
Amaro C++, il gusto pieno dell'undefined behavior.
Allora cioò è vero e dovrebbe funzionare. Allora io ho la risoluzione dello schermo impostata ha 1680*1050. Il metodo DesktopWorkingArea mi restituisce come valore Bottom 1020. Se io faccio:Originariamente inviato da MItaly
Puoi ottenere/impostare i confini dell'area di lavoro (per intenderci, l'area che occupano le finestre massimizzate) con la property DWA.DesktopWorkingArea.
codice:using System; using System.Runtime.InteropServices; namespace SetDeskWA { /// <summary> /// Rectangle used by API functions /// </summary> public struct APIRectangle { public int Left; public int Top; public int Right; public int Bottom; public override string ToString() { return "{Left=" + Left.ToString() + ",Top=" + Top.ToString() + ",Right=" + Right.ToString() + ",Bottom=" + Bottom.ToString() + "}"; } public APIRectangle(int Left, int Top, int Right, int Bottom) { this.Left=Left; this.Top=Top; this.Right=Right; this.Bottom=Bottom; } }; /// <summary> /// Desktop Working Area routines /// </summary> public static class DWA { private const int SPI_SETWORKAREA = 47; private const int SPI_GETWORKAREA = 48; [DllImport("user32.dll")] private static extern bool SystemParametersInfo(int uiAction, int uiParam, ref APIRectangle rect, int fWinIni); public static APIRectangle DesktopWorkingArea { get { APIRectangle WA = new APIRectangle(); if(!SystemParametersInfo(SPI_GETWORKAREA,0,ref WA,0)) throw new System.ComponentModel.Win32Exception(); return WA; } set { if(!SystemParametersInfo(SPI_SETWORKAREA,0,ref value,0)) throw new System.ComponentModel.Win32Exception("Used rectangle: " + value.ToString()); } } } }
Perchè lui allora ancora copre la barra anche se ho visto che il valore giusto da inserire in modo tale che la form non sovrapponga la barra sia 920?codice:Form a = new Form("Main"); a.TopMost = true; a.Size = new Size(320,DWA.DesktopWorkingArea.Bottom); a.Show();
Grazie