-
Apr 15th, 2012, 02:05 AM
#1
Thread Starter
Addicted Member
[RESOLVED] close button
Hi friends
I have a question about these 3 buttons(min,max,close) on the top corner of form; how can I have only min button available without close button.
(the exit button that I ve on my form is not only ,unload me, or ,end , it does some other things before exit so I cant use X button)
thank you in advance
-
Apr 15th, 2012, 02:42 AM
#2
Re: close button
Try this:
vb Code:
Option Explicit Private Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" _ (ByVal hMenu As Long, _ ByVal nPosition As Long, _ ByVal wFlags As Long) As Long Private Const MF_BYPOSITION = &H400& Private Sub Form_Load() DisableCloseButton Me End Sub Public Function DisableCloseButton(frm As Form) As Boolean 'PURPOSE: Removes X button from a form 'EXAMPLE: DisableCloseButton Me 'RETURNS: True if successful, false otherwise 'NOTES: Also removes Exit Item from ' Control Box Menu Dim lHndSysMenu As Long Dim lAns1 As Long, lAns2 As Long lHndSysMenu = GetSystemMenu(frm.hwnd, 0) 'remove close button lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION) 'Remove seperator bar lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION) 'Return True if both calls were successful DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0) End Function
Last edited by Nightwalker83; Apr 15th, 2012 at 02:49 AM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Apr 15th, 2012, 04:12 AM
#3
Re: close button
It might be much cleaner to just move this blob of logic to Form_Unload and change your button event to Unload Me.
This should solve the problem without the need for any foreign UI hacking that just adds confusion for users.
-
Apr 15th, 2012, 07:24 AM
#4
Thread Starter
Addicted Member
Re: close button
thank u for help,solved now
-
Apr 15th, 2012, 02:29 PM
#5
New Member
Re: [RESOLVED] close button
I know this thread is marked as [Solved] but here's another thing you could have done/can do:
Put everything you need to be done before the program ends into
vb Code:
Private Sub Form_QueryUnload() ' Your Code Here! :] End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|