Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fixed in size...???

Posted on 2000-02-20
10
Medium Priority
?
165 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 800 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

824 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