Fixed in size...???

In my vb program, the form1.borderstyle is set to 2-sizeable. I want to disable the sizeable feature so that the user can not resize the application, but I don't want to change the borderstyle to the 3-Fixed Dialog. Because the borderstyle 2 is more suitable to my application.

Does there is any other method to disable the resizable feature of my application, so the application is fixed in size ???

Any API call can use ???

Regards,

Raymond
rngAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mcriderConnect With a Mentor Commented:
Check out this MS article:

HOWTO: Limit a Window's Minimum and Maximum Size
http://support.microsoft.com/support/kb/articles/Q185/7/33.ASP?LNG=ENG&SA=MSDN&FR=1 
 

Cheers!
0
 
RuchiCommented:
0
 
TooKoolKrisCommented:
cannot limit the form from resizing. You can trap the event and resize the form back to the size you want, but that would look cheap and so would your app.(Lots of flicking)Instead try use the Getmenu() api to find the Hwnd of the system menu. Then once you have that use the ModifyMenuByNum to disable the control box without having to change the form to a fixed window. If you need example code post another comment with your email address.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mcriderCommented:
TooKoolKris, read the microsoft article I posted... You CAN stop the form from resizing and there is no flicker.
0
 
Erick37Commented:
This may be a bit simpler.  Set the BorderStyle of the Form to 1 - Fixed Single.  This will prevent resizing.  You can then set the MinButton and MaxButton properties True if you want.  Then this code draws a fake inner border to make the form look like a sizeable one.  Make sure the Form's Autoredraw property is False so that the Paint event will fire.

Option Explicit
Const SM_CXBORDER = 5
Const BF_RIGHT = &H4
Const BF_TOP = &H2
Const BF_LEFT = &H1
Const BF_BOTTOM = &H8
Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
Const BDR_SUNKENINNER = &H8
Const BDR_SUNKENOUTER = &H2
Const EDGE_SUNKEN = (BDR_SUNKENOUTER Or BDR_SUNKENINNER)
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Declare Function DrawEdge Lib "user32" _
    (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Declare Function GetClientRect Lib "user32" _
    (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetSystemMetrics Lib "user32" _
    (ByVal nIndex As Long) As Long


Private Sub Form_Paint()
    Dim rc As RECT
    Dim lRet As Long
    Dim cx As Long
    'Get the client rect values
    lRet = GetClientRect(Me.hwnd, rc)
    'Get the system border width
    cx = GetSystemMetrics(SM_CXBORDER)
    'Adjust the rect to draw our fake inner border
    With rc
    .Left = cx
    .Top = cx
    .Right = .Right - cx
    .Bottom = .Bottom - cx
    End With
    'Draw the border
    lRet = DrawEdge(Me.hdc, rc, EDGE_SUNKEN, BF_RECT)
End Sub
0
 
amebaCommented:
Here is one more:
Set border to 2-Sizeable, add this code

Option Explicit
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
    ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
    ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&

Private Sub Form_Load()
    Dim hMenu As Long
    Dim itemCount As Long
    ' get the handle of the system menu
    hMenu = GetSystemMenu(Me.hWnd, 0)
    'remove the system menu Close menu item
    RemoveMenu hMenu, 2, MF_REMOVE Or MF_BYPOSITION
End Sub
0
 
Erick37Commented:
I like that one ameba!
0
 
amebaCommented:
Thanks, Erick37.
0
 
rngAuthor Commented:
Thanx very much ~~mcrider~~
your answer help me so much really ...

Also thanx everyone posted the comments here. TooKoolKris, Erick37, Ruchi and ameba thanx you all...

0
 
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
All Courses

From novice to tech pro — start learning today.