Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 15th, 2003, 10:42 AM
toughcoder toughcoder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 49 toughcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 sec
Reputation Power: 6
Send a message via Yahoo to toughcoder
Unhappy How to disable the minimize, maximize & close buttons on a form??

Greetings every1,
can any1 plz tell me if there is a way to disable the minimize,maximize and close button on a form. I dont want to use the ControlBox property, i want the buttons to be visible but they must be disabled. I know this is possible, but just dont know the method. This should be done using APIs.

Reply With Quote
  #2  
Old August 17th, 2003, 11:23 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
Code:
Disable the close button from a form
Disable the Close button on any form in your project with this handy code snippet!

First of all, you will need to add a module to your project. (Project->Add Module).

Into this module, paste the following code:


Public Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&

Public Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long

Public Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Public Sub DisableClose(hWnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(hWnd, 0)
RemoveMenu hMenu, 6, MF_BYPOSITION
RemoveMenu hMenu, 5, MF_BYPOSITION
End Sub 

Then, to disable the Close button on a form, use 
DisableClose(form.hWnd)

e.g. 
DisableClose(Me.hWnd)
will disable the close button from the current form. 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > How to disable the minimize, maximize & close buttons on a form??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway