Solved

Fixed in size...???

Posted on 2000-02-20
10
153 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:rng
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 9

Expert Comment

by:Ruchi
Comment Utility
0
 
LVL 14

Accepted Solution

by:
mcrider earned 200 total points
Comment Utility
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
 
LVL 9

Expert Comment

by:TooKoolKris
Comment Utility
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
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
TooKoolKris, read the microsoft article I posted... You CAN stop the form from resizing and there is no flicker.
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:ameba
Comment Utility
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
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
I like that one ameba!
0
 
LVL 15

Expert Comment

by:ameba
Comment Utility
Thanks, Erick37.
0
 

Author Comment

by:rng
Comment Utility
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
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
Thanks for the points! Glad I could help!


Cheers!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now