Click here to Skip to main content
15,890,123 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Message Queue Pin
Member 997471330-Jun-13 23:19
Member 997471330-Jun-13 23:19 
GeneralRe: Message Queue Pin
Pete O'Hanlon1-Jul-13 3:01
mvePete O'Hanlon1-Jul-13 3:01 
QuestionCan not move controls over a user control Pin
dSolariuM29-Jun-13 9:53
dSolariuM29-Jun-13 9:53 
QuestionDiscussion on Screen Size and MDI Pin
Ron Beyer26-Jun-13 12:20
professionalRon Beyer26-Jun-13 12:20 
AnswerRe: Discussion on Screen Size and MDI Pin
Sergey Alexandrovich Kryukov26-Jun-13 13:33
mvaSergey Alexandrovich Kryukov26-Jun-13 13:33 
GeneralRe: Discussion on Screen Size and MDI Pin
Ron Beyer26-Jun-13 14:03
professionalRon Beyer26-Jun-13 14:03 
GeneralRe: Discussion on Screen Size and MDI Pin
Sergey Alexandrovich Kryukov26-Jun-13 16:55
mvaSergey Alexandrovich Kryukov26-Jun-13 16:55 
SuggestionRe: Discussion on Screen Size and MDI Pin
TnTinMn27-Jun-13 8:00
TnTinMn27-Jun-13 8:00 
Quote:
... Our field engineers making changes to screens typically use laptops to edit screens that run on 23" monitors, so every time they open a screen, WF graciously resizes them (thanks MS!).


Here is a hack to deal with that frustration. Inherit from this Form instead of Forms.Form.
Imports System.ComponentModel
Imports System.Runtime.InteropServices

Public Class FormWithDesignSize
   Inherits Form
   Private Const DefaultMax As Int32 = 2000 'set this to whatever you need

   Private _MaxDesignWidth As Int32 = DefaultMax
   Private _MaxDesignHeight As Int32 = DefaultMax

   <Category("Design")> _
   <DisplayName("MaxDesignWidth")> _
   Public Property aaa_MaxDesignWidth() As Int32  'Prefix aaa_ is to force Designer code placement before ClientSize setting
      Get                                         ' avoids need to write customer serializer code
         Return _MaxDesignWidth
      End Get
      Set(ByVal value As Int32)
         _MaxDesignWidth = value
      End Set
   End Property

   <Category("Design")> _
   <DisplayName("MaxDesignHeight")> _
   Public Property aaa_MaxDesignHeight() As Int32  'Prefix aaa_ is to force Designer code placement before ClientSize setting
      Get                                          ' avoids need to write customer serializer code
         Return _MaxDesignHeight
      End Get
      Set(ByVal value As Int32)
         _MaxDesignHeight = value
      End Set
   End Property


   Protected Overrides Sub SetBoundsCore(ByVal x As Int32, ByVal y As Int32, ByVal width As Int32, ByVal height As Int32, ByVal specified As BoundsSpecified)
      If Me.DesignMode Then
         ' The Forms.Form.SetBoundsCore method limits the size based on SystemInformation.MaxWindowTrackSize

         ' From the GetSystemMetrics function documentation for SMCXMINTRACK: 
         '   "The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size 
         '    smaller than these dimensions. A window can override this value by processing the WMGETMINMAXINFO
         '    message."
         ' See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385%28v=vs.85%29.aspx

         ' This message also appears to control the size set by the MoveWindow API, 
         ' so it is intercepted and the maximum size is set to MaxWidth by MaxHeight
         ' in the WndProc method when in DesignMode.

         ' Form.SetBoundsCore ultimately calls Forms.Control.SetBoundsCore that calls SetWindowPos but, 
         ' MoveWindow will be used instead to set the Window size when in the designer as it requires less
         ' parameters to achieve the desired effect.

         MoveWindow(Me.Handle, Me.Left, Me.Top, width, height, True)
      Else
         MyBase.SetBoundsCore(x, y, width, height, specified)
      End If
   End Sub

   Private Const WMGETMINMAXINFO As Int32 = &H24
   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      MyBase.WndProc(m)
      If Me.DesignMode AndAlso m.Msg = WMGETMINMAXINFO Then

         Dim MMI As New MINMAXINFO
         ' retrieve default MINMAXINFO values from the structure pointed to by m.LParam
         Marshal.PtrToStructure(m.LParam, MMI)

         ' reset the ptMaxTrackSize value
         MMI.ptMaxTrackSize = New POINTAPI(_MaxDesignWidth, _MaxDesignHeight)

         ' copy the modified structure back to LParam
         Marshal.StructureToPtr(MMI, m.LParam, True)
      End If

   End Sub

   <StructLayout(LayoutKind.Sequential)> _
   Private Class MINMAXINFO
       Public ptReserved As POINTAPI
       Public ptMaxSize As POINTAPI
       Public ptMaxPosition As POINTAPI
       Public ptMinTrackSize As POINTAPI
       Public ptMaxTrackSize As POINTAPI
   End Class

    <System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
    Public Structure POINTAPI
      Public X As Int32
      Public Y As Int32

      Public Sub New(ByVal X As Int32, ByVal Y As Int32)
         Me.X = X
         Me.Y = Y
      End Sub

      Public Overrides Function ToString() As String
         Return "(" & X.ToString() & ", " & Y.ToString() & ")"
      End Function
    End Structure

    <DllImport("user32.dll")> _
    Private Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean
    End Function

End Class

GeneralRe: Discussion on Screen Size and MDI Pin
Ron Beyer27-Jun-13 8:39
professionalRon Beyer27-Jun-13 8:39 
GeneralRe: Discussion on Screen Size and MDI Pin
TnTinMn27-Jun-13 13:47
TnTinMn27-Jun-13 13:47 
QuestionCan not load dlls in project Pin
Nooredin25-Jun-13 23:49
Nooredin25-Jun-13 23:49 
AnswerRe: Can not load dlls in project Pin
Eddy Vluggen26-Jun-13 0:11
professionalEddy Vluggen26-Jun-13 0:11 
GeneralRe: Can not load dlls in project Pin
Nooredin26-Jun-13 0:24
Nooredin26-Jun-13 0:24 
GeneralRe: Can not load dlls in project Pin
Eddy Vluggen26-Jun-13 1:12
professionalEddy Vluggen26-Jun-13 1:12 
GeneralRe: Can not load dlls in project Pin
Dave Kreskowiak26-Jun-13 2:23
mveDave Kreskowiak26-Jun-13 2:23 
AnswerRe: Can not load dlls in project Pin
Nooredin26-Jun-13 2:31
Nooredin26-Jun-13 2:31 
QuestionProblem with accessing Asp.net web application through other system Pin
ven75325-Jun-13 20:49
ven75325-Jun-13 20:49 
AnswerRe: Problem with accessing Asp.net web application through other system Pin
Bernhard Hiller25-Jun-13 21:07
Bernhard Hiller25-Jun-13 21:07 
AnswerRe: Problem with accessing Asp.net web application through other system Pin
MaulikDusara26-Jun-13 8:52
MaulikDusara26-Jun-13 8:52 
AnswerRe: Problem with accessing Asp.net web application through other system Pin
Manu V Nath3-Jul-13 23:11
professionalManu V Nath3-Jul-13 23:11 
QuestionExecutable not running from the System32 directory Pin
Dotnetifier24-Jun-13 5:46
Dotnetifier24-Jun-13 5:46 
AnswerRe: Executable not running from the System32 directory Pin
Bernhard Hiller24-Jun-13 21:56
Bernhard Hiller24-Jun-13 21:56 
GeneralRe: Executable not running from the System32 directory Pin
Dotnetifier25-Jun-13 3:29
Dotnetifier25-Jun-13 3:29 
SuggestionWeb services call back in .net Pin
Member 1006655419-Jun-13 1:23
Member 1006655419-Jun-13 1:23 
GeneralRe: Web services call back in .net Pin
Pete O'Hanlon19-Jun-13 2:24
mvePete O'Hanlon19-Jun-13 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.