|
-
Feb 3rd, 2004, 11:52 AM
#1
Thread Starter
Fanatic Member
minimize + maximize + X *RESOLVED*
Ok, I have searched through several threads looking for info on minimizing, maximize and X for forms. I have found several interesting threads, but I can't seem to find what I am looking for.
I have two forms open, one is my main form. If I click the minimize control, I want both form to minimize and and only show as one form in the task bar.
If I open the form up again, I want everything to open up as it was before. Now the part I seem to be missing is how to indicate in my code that the minimize or maximize or X control has been clicked.
I know for example if I don't want my other form in the task bar to use something like this and to open the forms together with this.
VB Code:
frmOtherForm.show, frmMain
ShowInTaskBar = false
Last edited by Navarone; Feb 3rd, 2004 at 03:50 PM.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 12:20 PM
#2
Supreme User
This should get you going:
VB Code:
if me.windowstate = vbminimized then
'---
end if
You should get the rest figured out from that
-
Feb 3rd, 2004, 02:07 PM
#3
Thread Starter
Fanatic Member
this question is also related why can't I do this in VB6
VB Code:
frmIntro.MaxButton = False
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 02:11 PM
#4
Supreme User
Im not sure, but maybe because its a read only property, meaning you can only set the caption buttons at design time. Does it error when you try that code, if so what error do you get?
That code is perfect you see
-
Feb 3rd, 2004, 02:15 PM
#5
Thread Starter
Fanatic Member
yes, I get a compile error:
Code:
Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic
The only reason I tried it, is I found it a thread during a Google search.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 02:17 PM
#6
Supreme User
Well it must be only set at design time then
-
Feb 3rd, 2004, 02:21 PM
#7
You can't set that during Runtime.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Feb 3rd, 2004, 02:25 PM
#8
Originally posted by Navarone
this question is also related why can't I do this in VB6
VB Code:
frmIntro.MaxButton = False
You need to use APIs to remove the Max button from a form during runtime.
VB 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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYCOMMAND = &H0&
Private Const SC_MAXIMIZE As Long = &HF030
Private sub Form_Load()
Dim hMenu as long
hMenu = GetSystemMenu(Me.hwnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar(Me.hwnd)
End sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 02:32 PM
#9
This will NOT give the Max button the disabled look, but it will be
removed from the system menu. Thus, disabling the Max button.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 02:36 PM
#10
Thread Starter
Fanatic Member
RobDog888
I tried using the code snippet you posted but when My form loads I get a compile error for this line, "sub or function not declared"
VB Code:
hMenu = GetSystemMenu(Me.hwnd, False)
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 02:40 PM
#11
Can you post your form load procedure?
The APIs need to be declared in either the forms general
declarations section or in a module and change the APIs to be
Public instead of Private.
If you copy and paste the code I posted into another new
standard vb project it will run and you can see the results.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 02:49 PM
#12
Here is the complete effect of a disabled Max button set during runtime.
Paste into a new vb project and run.
VB 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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const MF_BYCOMMAND = &H0&
Private Const SC_MAXIMIZE As Long = &HF030
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const GWL_STYLE As Long = -16
Private Sub Form_Load()
Dim hMenu As Long
Dim lstyle As Long
hMenu = GetSystemMenu(Me.hwnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar(Me.hwnd)
lstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lstyle = lstyle - WS_MAXIMIZEBOX
Call SetWindowLong(Me.hwnd, GWL_STYLE, lstyle)
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 02:59 PM
#13
Thread Starter
Fanatic Member
Ok, Cool.
I tried this in a new project and I see what you mean. When I copied the code into my project, I put all the private declarations in my module and made them public the same with the private Const, they are now public too.
I then put the Sub Form_load code in my forms Sub and when I run the app, the maximize button is disabled, but it's not grayed out.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 03:09 PM
#14
Strange, try putting the code at the end of the Form_Load.
Maybe there is something that is changing it back? Post you
Form_Load procedure if you can.
What is the Form borderstyle?
If it is set to none then this will not work.
It needs to be either 1 - Fixed or 2 - Sizable
Are there any forms that this works on in your project?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 03:17 PM
#15
Thread Starter
Fanatic Member
ok, on the off-chance that there is something wierd going on, I took everything out of the module, put stuff back to Private and added it to the top declaration of my form. The form by the way is set to 2-sizable. This is my sub routine
VB Code:
Private Sub Form_Load()
'disable the maximize button from the form
Dim hMenu As Long
Dim lstyle As Long
hMenu = GetSystemMenu(Me.hwnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar(Me.hwnd)
lstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lstyle = lstyle - WS_MAXIMIZEBOX
Call SetWindowLong(Me.hwnd, GWL_STYLE, lstyle)
'load background image
frmIntro.Picture = LoadPicture(App.Path & "\" & "Pictures" & "\" & "mainBackground.jpg")
'set top menu to invisible
frmIntro.HoverCommand6.Visible = False
frmIntro.HoverCommand7.Visible = False
frmIntro.HoverCommand8.Visible = False
frmIntro.HoverCommand9.Visible = False
frmIntro.HoverCommand10.Visible = False
'set caption for form at runtime
frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
'set label for copywrite
frmIntro.Label11.Caption = "© Copyright 2004 Virtual Horizons,Inc. All rights reserved."
'create directories if they do not already exist
If Dir(App.Path & "\" & "CDTypes", vbDirectory) = "" Then
'MsgBox "Directory doesn't exist"
MkDir (App.Path & "\" & "CDTypes") ' make new directory
MkDir (App.Path & "\" & "Images") 'make images directory
MkDir (App.Path & "\" & "WavFiles") 'make wavFile directory
MkDir (App.Path & "\" & "pdfs") 'make pdf directory
Else
'MsgBox "Directory Exist"
End If
End Sub
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 03:22 PM
#16
If you had this code in the module then the me.hwnd will be incorrect.
VB Code:
hMenu = GetSystemMenu([color=red]Me[/color].hwnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar([color=red]Me[/color].hwnd)
lstyle = GetWindowLong([color=red]Me[/color].hwnd, GWL_STYLE)
lstyle = lstyle - WS_MAXIMIZEBOX
Call SetWindowLong([color=red]Me[/color].hwnd, GWL_STYLE, lstyle)
Try changing the Me keyword to your form name - frmIntro.hwnd
and move the code to be the last lines of code in the Form_Load event.
VB Code:
'set caption for form at runtime
frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
May have something to do with it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 03:26 PM
#17
So it should look like this.
VB Code:
Private Sub Form_Load()
'disable the maximize button from the form
Dim hMenu As Long
Dim lstyle As Long
'load background image
frmIntro.Picture = LoadPicture(App.Path & "\" & "Pictures" & "\" & "mainBackground.jpg")
'set top menu to invisible
frmIntro.HoverCommand6.Visible = False
frmIntro.HoverCommand7.Visible = False
frmIntro.HoverCommand8.Visible = False
frmIntro.HoverCommand9.Visible = False
frmIntro.HoverCommand10.Visible = False
'set caption for form at runtime
frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
'set label for copywrite
frmIntro.Label11.Caption = "© Copyright 2004 Virtual Horizons,Inc. All rights reserved."
'create directories if they do not already exist
If Dir(App.Path & "\" & "CDTypes", vbDirectory) = "" Then
'MsgBox "Directory doesn't exist"
MkDir (App.Path & "\" & "CDTypes") ' make new directory
MkDir (App.Path & "\" & "Images") 'make images directory
MkDir (App.Path & "\" & "WavFiles") 'make wavFile directory
MkDir (App.Path & "\" & "pdfs") 'make pdf directory
Else
'MsgBox "Directory Exist"
End If
hMenu = GetSystemMenu(frmIntro.hWnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar(frmIntro.hWnd)
lstyle = GetWindowLong(frmIntro.hWnd, GWL_STYLE)
lstyle = lstyle - WS_MAXIMIZEBOX
Call SetWindowLong(frmIntro.hWnd, GWL_STYLE, lstyle)
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 03:33 PM
#18
Thread Starter
Fanatic Member
ok, I removed everything from my module and put it in my form. and changed the code to this:
VB Code:
'disable the maximize button from the form
Dim hMenu As Long
Dim lstyle As Long
hMenu = GetSystemMenu(frmIntro.hwnd, False)
Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
Call DrawMenuBar(frmIntro.hwnd)
lstyle = GetWindowLong(frmIntro.hwnd, GWL_STYLE)
lstyle = lstyle - WS_MAXIMIZEBOX
Call SetWindowLong(frmIntro.hwnd, GWL_STYLE, lstyle)
The results were the same, the button itself is disabled, it's just not grayed out.
However, if I comment out this line as you implied, it works.
VB Code:
'set caption for form at runtime
frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
So, I then tried moving the code to the last lines in the form, and it appears to be working correctly now. So, thnks.
In the future, if I want to change the minimize or close button, how would I do that?
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 03:43 PM
#19
The close button is -
VB Code:
Private Const WM_CLOSE = &H10
'and in your load procedure.
Call RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
For the minimize button follow the same logic as the Max button but use the consts.
VB Code:
Private Const SC_MINIMIZE As Long = &HF020
Private Const WS_MINIMIZEBOX As Long = &H20000
I thought that the setting of the form caption was reverting the
Max button setting.
Glad its working for you.
PS. you could create a Public function and pass the form byref so
you can centralize the function instead of having it in every form.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 04:24 PM
#20
Thread Starter
Fanatic Member
One last question. Can I control the arrows that allow me to resize the window with this code.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 04:28 PM
#21
If you are asking about making the form non-resizeable, you can
just set the form's borderstyle to Fixed or remove the size system
menu item. If you are asking about only letting a user resize the
form vertically or something like that then you have to sub-class
the form. It could be a pain.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 04:39 PM
#22
Thread Starter
Fanatic Member
I want the user to beable to minimize the form and close it, but no resize of any kind.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 04:42 PM
#23
Easiest way is to change the forms borderstyle to fixed in design
mode. It will not allow any resizing of any direction. Only
minimize, move, and close.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 04:43 PM
#24
Thread Starter
Fanatic Member
If I do that though, I can't minimize, can I?
He who never made a mistake never made a discovery?
-
Feb 3rd, 2004, 04:46 PM
#25
Whenever you change the form's borderstyle property in design
mode, it will remove the max and min buttons. Just set the min
property to true after you change the borderstyle to fixed and
you can minimize.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2004, 04:54 PM
#26
Thread Starter
Fanatic Member
Hmm. I didn't know that I learned something new today!
He who never made a mistake never made a discovery?
-
Feb 16th, 2004, 05:12 PM
#27
Supreme User
How about disabling the X button? I had the code, but lost it
-
Feb 16th, 2004, 05:21 PM
#28
VB Code:
Public Declare Function GetMenuItemCount _
Lib "user32" (ByVal hMenu As Long) As _
Long
Public Declare Function GetSystemMenu Lib _
"user32" (ByVal hwnd As Long, ByVal _
bRevert As Long) As Long
Public Declare Function RemoveMenu Lib _
"user32" (ByVal hMenu As Long, ByVal _
nPosition As Long, ByVal wFlags As Long) _
As Long
Public Declare Function DrawMenuBar Lib _
"user32" (ByVal hwnd As Long) As Long
Public Const MF_REMOVE = &H1000&
Public Const MF_INSERT = &H0&
Public Const MF_ENABLED = &H0&
Public Const MF_BYPOSITION = &H400&
Public Sub DisableX(frm As Form, blnDisabled As Boolean)
Dim hMenu As Long
Dim nCount As Long
If blnDisabled = True Then
hMenu = GetSystemMenu(frm.hwnd, 0)
nCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)
DrawMenuBar frm.hwnd
Else
hMenu = GetSystemMenu(frm.hwnd, True)
DrawMenuBar frm.hwnd
End If
End Sub
Has someone helped you? Then you can Rate their helpful post. 
-
Feb 16th, 2004, 05:23 PM
#29
Supreme User
-
Feb 16th, 2004, 05:29 PM
#30
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
|