I use: NASM, HTML, Perl, PHP, JavaScript, Batch, TI-Basic (TI-83+), QBasic 1.1, QuickBASIC 4.5, QuickBASIC Extended 7.1, VB-WIN 6 Ent., and the rest of Visual Studio 6 Ent. And who knows what else!
Change the border style? If you change it to "sizable toolwindow" you will still have the close box but lose everything else. they will be able to resize the window still with border dragging.
Last edited by Lord Orwell; Mar 12th, 2001 at 05:57 AM.
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const GWL_WNDPROC = (-4)
Private Const WM_NCHITTEST = &H84
Private Const HTSYSMENU = 3
Private Const WM_NCLBUTTONDOWN = &HA1
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_NCLBUTTONDOWN And wParam = HTSYSMENU Then
Exit Function
End If
WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub
Add to your Form
Code:
Private Sub Form_Load()
SubClassWnd hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd hwnd
End Sub
Megatron -- Thanks for the code. It works, but in this case I want to hide the SysMenu icon as well as disable it. I will definetely use that code in the future.
Lord Orwell -- Thanks for that attachment. My question is, and this is an "API Newbie" one (hey, gotta start somewhere...):
How am I able to turn off the sysmenu with that?
Do I just try something like:
SetWindowLong(hwnd,WS_SYSMENU,0)?
I see that the sysmenu property is 80000 to use it. So what is its value to not use it? I am unfamiliar with these api's, and reading my Appleman API book fails to clear up my confusion.
I must be making this more difficult than it is.....
Yes, that will work, but it's just the same as disabling the the ControlBox property.
Just incase your interested, here's the code
Code:
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Sub Form_Load()
Dim wStyle As Long
wStyle = GetWindowLong(hwnd, GWL_STYLE)
wStyle = wStyle Xor WS_SYSMENU
SetWindowLong hwnd, GWL_STYLE, wStyle
End Sub
Hmmm... so basically I can either a) disable the whole control box or disable the sysMenu when it pops up but still show the icon? But I can't "hide" that icon and the menu?
How do programs like Word, FileMaker, even Windows clock do it? They still have the "X" at the top right and they do not have a sysMenu....
And thanks for the example Megatron... that helps my understanding of how to use the API....
Originally posted by Lord Orwell Change the border style? If you change it to "sizable toolwindow" you will still have the close box but lose everything else. they will be able to resize the window still with border dragging.
And the clock does still have the context menu. Right-click on the title bar to activate it.
The problem with the toolwindow is that it is smaller than the normal window. Know what I mean? The caption at the top is smaller, which makes the windows look somewhat "weird" to some people....
I'll resort to using that if I have to, but I just figured since I've seen programs not use the sysMenu, I figured there was a way...