Solved

Fixed in size...???

Posted on 2000-02-20
10
154 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
ID: 2540144
0
 
LVL 14

Accepted Solution

by:
mcrider earned 200 total points
ID: 2540146
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
ID: 2540654
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
ID: 2540686
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
ID: 2540692
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Expert Comment

by:ameba
ID: 2540792
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
ID: 2540878
I like that one ameba!
0
 
LVL 15

Expert Comment

by:ameba
ID: 2540899
Thanks, Erick37.
0
 

Author Comment

by:rng
ID: 2542760
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
ID: 2544258
Thanks for the points! Glad I could help!


Cheers!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

19 Experts available now in Live!

Get 1:1 Help Now