Results 1 to 7 of 7

Thread: Enable/disable form resizing at run-time...

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Question Enable/disable form resizing at run-time...

    How can I enable/disable the ability to resize a form at runtime?
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  2. #2
    Matthew Gates
    Guest
    Use the RemoveMenu API function.


    VB Code:
    1. Private Declare Function GetSystemMenu Lib "User32" _
    2. (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer
    3.  
    4. Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu _
    5. As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) _
    6. As Integer
    7.  
    8. Const MF_BYPOSITION = &H400
    9.  
    10. Private Sub Form_Load()
    11.     RemoveMenu GetSystemMenu(hWnd, 0), 2, MF_BYPOSITION
    12. End Sub

  3. #3
    Matthew Gates
    Guest
    Actually, here's full code to both enable and disable resizing.


    Try this:


    VB Code:
    1. Private Declare Function GetSystemMenu Lib "user32" _
    2. (ByVal hwnd As Integer, ByVal bRevert As Integer) As _
    3. Integer
    4.  
    5. Private Declare Function RemoveMenu Lib "user32" _
    6. (ByVal hMenu As Integer, ByVal nPosition As Integer, _
    7. ByVal wFlags As Integer) As Integer
    8.  
    9. Const MF_BYPOSITION = &H400
    10. Const MF_APPEND = &H100&
    11.  
    12.  
    13. Private Sub Command1_Click()
    14.     RemoveMenu GetSystemMenu(hwnd, MF_APPEND), 2, MF_BYPOSITION
    15. End Sub
    16.  
    17. Private Sub Form_Load()
    18.     RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
    19. End Sub

  4. #4

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Probs...

    The suggestion you offered MAtthew returns an OVerflow error at Form_Load, and at COmmand1_Click. Why might this be happening?
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  5. #5
    jimbo11883
    Guest
    Change "Integer" to "Long" as I have done below and it will work

    Private Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long

    Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

  6. #6
    New Member
    Join Date
    Jul 2021
    Posts
    3

    Re: Enable/disable form resizing at run-time...

    I get a compile coding error with a variable not declared...
    BC30451: "hwnd" as not declared. It may be inaccessible due to its
    protection level.

    How do I correct this?

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,469

    Re: Enable/disable form resizing at run-time...

    Quote Originally Posted by VMcElwee View Post
    I get a compile coding error with a variable not declared...
    BC30451: "hwnd" as not declared. It may be inaccessible due to its
    protection level.

    How do I correct this?
    You start by not replying to a 20 year old thread. Then you have to understand how to read an API declaration. hwnd relates to a Handle to a WiNDow... so you get the window handle that you want to manipulate, and you pass that in as the hwnd value. It doesn't need to be specifically called hwnd... it could be called qwerty or asdf or windwHandle or what ever.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width