Results 1 to 3 of 3

Thread: How can I disable resizing of foreign window?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    It's a foreign window. I tried SetWindowPos with window style WS_Border but it left a thin border that can be resized.

    Thanks.
    Wade

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    No problem, what we're gonna do is change the command ID of the size menu item to an arbitary unused one, -10, when you try to resize this windows tries to call this menu by looking for its command ID, but seeing as we've changed it, when we want to let the window resize again we swap it back.

    here's some code

    Code:
    Option Explicit
    
    Private Const MF_BYCOMMAND = &H0&
    Private Const MF_GRAYED = &H1&
    Private Const SC_SIZE = &HF000&
    Private Const MF_ENABLED = &H0&
    Private Const FOOL_VB = -10
    
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
    
    Public Sub DisableResize(hwnd As Long)
    
    ModifyMenu GetSystemMenu(hwnd, 0), _
               SC_SIZE, _
               MF_BYCOMMAND Or MF_GRAYED, _
               FOOL_VB, _
               "Size"
               
    DrawMenuBar hwnd
    End Sub
    
    
    Public Sub EnableResize(hwnd As Long)
    
    ModifyMenu GetSystemMenu(hwnd, 0), _
               FOOL_VB, _
               MF_BYCOMMAND Or MF_ENABLED, _
               SC_SIZE, _
               "Size"
               
    DrawMenuBar hwnd
    End Sub
    hope this helps

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    That's beautiful Sam.

    Thanks.
    Wade

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