Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Resizing a form

Hello again, I have written a message before but nobody seemed to reply. So, I ask again:


Is there a special property that prevents the user from resizing the form but without using the borderstyle property? For example if the form's width reaches 3000, is there a way that the borders can be blocked but without preventing the user from enlarging the form, just like the find window of Windows. I'm looking forward to your reply.


Friendly,

Rookie


Comments

  • 'Try this


    Private Sub Form_Load()

    OldWindowProc = SetWindowLong( _

    hwnd, GWL_WNDPROC, _

    AddressOf NewWindowProc)

    End Sub


    'Add module and this api code


    Public OldWindowProc As Long

    Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As WINDOWPOS) As Long

    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Const GWL_WNDPROC = (-4)


    Type WINDOWPOS

    hwnd As Long

    hWndInsertAfter As Long

    x As Long

    y As Long

    cx As Long

    cy As Long

    flags As Long

    End Type

    Public Const WM_WINDOWPOSCHANGING = &H46

    Public Const WM_WINDOWPOSCHANGED = &H47

    ' *********************************************

    ' Process messages.

    ' *********************************************

    Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As WINDOWPOS) As Long

    ' Size bounds in pixels.

    Const MIN_WIDTH = 200

    Const MAX_WIDTH = 500

    Const MIN_HEIGHT = 100

    Const MAX_HEIGHT = 300


    ' Keep the dimensions in bounds.

    If msg = WM_WINDOWPOSCHANGING Then

    If lParam.cx MAX_WIDTH Then lParam.cx = MAX_WIDTH

    If lParam.cy MAX_HEIGHT Then lParam.cy = MAX_HEIGHT

    End If



    ' Continue normal processing. VERY IMPORTANT!

    NewWindowProc = CallWindowProc( _

    OldWindowProc, hwnd, msg, wParam, _

    lParam)

    End Function




  • Shawn CarterShawn Carter Member Posts: 0

    ______ \ http://forcoder.org \ free video tutorials and ebooks about / Visual Basic .NET, Java, Perl, MATLAB, Go, PHP, Assembly, Python, C#, C++, Visual Basic, C, R, JavaScript, PL/SQL, Objective-C, Ruby, Scratch, Swift, Delphi Scala, Rust, F#, Erlang, Kotlin, Alice, COBOL, Logo, ABAP, LabVIEW, Julia, VBScript, Transact-SQL, Dart, SAS, Lua, Bash, Scheme, Lisp, Prolog, Apex, Clojure, Fortran, Ada, Awk, Hack, ML, D, Crystal, FoxPro / _____

Sign In or Register to comment.