Option Compare Database
Option Explicit
--------------------------------------
'Why use GetForGroundWindow to get the hWnd of Access, why not use
'hWndAccessApp? <-- Terry, how?
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_SYSMENU = &H80000
----------------------------------
Function NoControlBox()
Dim hwnd As Long
Dim lngStyle As Long
Dim i As Long
hwnd = GetForegroundWindow()
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle And (Not WS_SYSMENU)
i = SetWindowLong(hwnd, GWL_STYLE, lngStyle)
lngStyle = lngStyle And (Not WS_MAXIMIZEBOX)
lngStyle = lngStyle And (Not WS_MINIMIZEBOX)
End Function
'Access repaints itself on next function - open form
----------------------------------------------
Can anyone make this so that the Exit is removed but not the icon???
Thankies Spankies :)
Aequi
The only way I can think to do this and keep the icon is to use
GetSystemMenu to return hWnd for the Control Box (System Menu). Then use
something like ModifyMenu or RemoveMenu to either disable Exit or remove the
menu all together. I haven't tried this and I rather suspect you may have to
get into some fairly heavy duty subclassing.
Hope this points you in the right direction.
Calum
Aequi wrote in message <36c47038...@news.pm.iconz.co.nz>...
Perhaps you can remove the title bar completely and create your own
faux title bar (with icon) in Form Builder?
Thank you,
Joshua Rehman
--
-=Access Wizardry=- Extraordinary database designs.
Please send enquiries to wizard @ ioc.net (remove spaces, please).
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) As Long
Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
'*********************
Sub DisAbleTitleBarControls()
Dim lngAccessWindowHandle As Long, lngWindowStatus As Long
lngAccessWindowHandle = Access.hWndAccessApp
lngWindowStatus = GetWindowLong(lngAccessWindowHandle, GWL_STYLE)
lngWindowStatus = lngWindowStatus And (Not WS_CAPTION)
Call SetWindowLong(lngAccessWindowHandle, GWL_STYLE, lngWindowStatus)
MsgBox "Title Bar Icons and Control Box Disabled", vbInformation
End Sub
'******
Sub EnableTitleBarControls()
Dim lngAccessWindowHandle As Long, lngWindowStatus As Long
lngAccessWindowHandle = Access.hWndAccessApp
lngWindowStatus = GetWindowLong(lngAccessWindowHandle, GWL_STYLE)
lngWindowStatus = lngWindowStatus Or WS_CAPTION
Call SetWindowLong(lngAccessWindowHandle, GWL_STYLE, lngWindowStatus)
MsgBox "Title Bar Icons and Control Box Enabled", vbInformation
End Sub
'******
Aequi <Ae...@home.co.nz> wrote in message
news:36c47038...@news.pm.iconz.co.nz...
Calum
Option Compare Database
Option Explicit
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetSystemMenu& Lib "user32" (ByVal hWnd As Long, ByVal
bRevert As Long)
Public Const MF_BYPOSITION = &H400&
Function ChangeSysMenu()
Dim SyshWnd As Long
Dim hWnd As Long
Dim ret As Long
hWnd = GetForegroundWindow()
SyshWnd = GetSystemMenu&(hWnd, False)
ret = RemoveMenu&(SyshWnd, 5, MF_BYPOSITION) ' removes line
ret = RemoveMenu&(SyshWnd, 5, MF_BYPOSITION) ' removes close
End Function
Option Compare Database
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" _
(ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As
Long
Private Const MF_BYCOMMAND = &H0&
Private Const MF_ENABLED = &H0&
Private Const MF_GRAYED = &H1&
Private Const SC_CLOSE = &HF060&
Sub EnableCloseButton()
Dim lngSystemMenuHandle As Long
lngSystemMenuHandle = GetSystemMenu(Access.hWndAccessApp, False)
Call EnableMenuItem(lngSystemMenuHandle, SC_CLOSE, MF_BYCOMMAND Or
MF_ENABLED)
End Sub
Sub DisableCloseButton()
Dim lngSystemMenuHandle As Long
lngSystemMenuHandle = GetSystemMenu(Access.hWndAccessApp, False)
Call EnableMenuItem(lngSystemMenuHandle, SC_CLOSE, MF_BYCOMMAND Or
MF_GRAYED)
End Sub
--
Lyle
Lyle Fairfield <lyle...@cgocable.net> wrote in message
news:7a2e4b$5l3$1...@usenet41.supernews.com...
>>Option Compare Database
>>Option Explicit
I have no idea why anyone Would_Want to do this. (I'm assuming there must be
some way to close, so why not let Access do it in what appears to be a safe
way)?I'm just taking any opportunity I can to learn a bit about using the
Windows API.
--
Lyle
Dev Ashish <das...@hotmail.com> wrote in message
news:7a5dqb$e...@bgtnsc01.worldnet.att.net...
> I've been lurking thus far and the code's been nice, but now I feel like I
>must be the devil's advocate.
>
> Why on _earth_ would you want to mess with an MDI app like that,
especially
>since it's not yours. I can understand such steps if you were using
>CreateWindow or with your own forms etc., but _come on_, not with the
>default window of a standard Windows app. Or am I being just plain stupid
>here? And how does one know for a fact (other than looking at the source)
>that Access hasn't put some code behind what-you-just-disabled to perform
>pre-quit-clean-up.
>
>But then I get ticked off by other apps auto-activating their window, even
>from background, so it must be me. <sigh>
>
> -- Dev ($.001)
>
>
>
Btw - my modLyle works very well thankies Lyle .. and the icon was
disappearing on my task bar because i was running another function to
set the database icon.
Thanks Peoples
Aequi
On 14 Feb 1999 02:04:04 GMT, c.gr...@worldnet.att.net (Chuck
Grimsby) wrote:
>
>You know, ya'll are getin' real mean here...
>
>Arvin's kicking people out of his DB's, Dev's throwing me out of
>windows, and now....
>
>Lyle, I want my dang buttons back!
>
><grin>
>
>Of course, now that they can't "close" the db, you better hide it from
>the task list so they can't alt-ctrl-delete the db:
>
>Private Declare Function RegisterServiceProcess Lib _
> "kernel32" (ByVal ProcessID As Long, _
> ByVal Flag As Long) As Long
>Private Declare Function GetCurrentProcessId Lib _
> "kernel32" () As Long
>
>Sub HideMe(Hide As Boolean)
>Dim r As Long
>Select Case Hide
>Case True
> ' Hide me:
> r = RegisterServiceProcess(GetCurrentProcessId(), 1)
>Case False
> ' Show me:
> r = RegisterServiceProcess(GetCurrentProcessId(), 0)
>End Select
>End Sub
>Sorry, If you're too lazy to check the group for a reply, I'm too lazy to cc this to you.
The Min/Max/Restore buttons can stay as far as I'm concerned
Lyle's little grey-out is perfect - actually hiding the buttons
themselves caused other problems, such as double-clicking on the title
bar .. watch your app disappear off screen <g>
Agreed Dev, too much messing :)
Aequi
-- (paranoid) Dev
Lyle Fairfield wrote in message <7a5eil$pim$1...@usenet49.supernews.com>...
:I think you are talking partly to me, Dev, about graying out the Close
:Button?
:
:I have no idea why anyone Would_Want to do this. (I'm assuming there must
be
:some way to close, so why not let Access do it in what appears to be a safe
:way)?I'm just taking any opportunity I can to learn a bit about using the
:Windows API.
:
:--
:Lyle
:Dev Ashish <das...@hotmail.com> wrote in message
:news:7a5dqb$e...@bgtnsc01.worldnet.att.net...
:> I've been lurking thus far and the code's been nice, but now I feel like
:>
:>
:>
:
:
Without taking away anything from Lyle's or other's efforts, I would suggest
instead that you follow more conventional methods of tracking a boolean
variable's state from a form's OnUnload event. My rule of thumb is, don't
mess with the app itself unless it's absolutely needed and unavoidable.
FWIW
-- Dev
Aequi wrote in message <36d143ee...@news.pm.iconz.co.nz>...
:Sorry guys, I started that thread, and the reason being was simply
:that i want to force all users to quit via the correct Exit button on
:the custom Toolbar .. for whatever reasons as specified by the nature
:of the db itself.
:
:The Min/Max/Restore buttons can stay as far as I'm concerned
:
:Lyle's little grey-out is perfect - actually hiding the buttons
:themselves caused other problems, such as double-clicking on the title
:bar .. watch your app disappear off screen <g>
:
:Agreed Dev, too much messing :)
:
:Aequi
:
:On Sat, 13 Feb 1999 22:05:54 -0500, "Lyle Fairfield"
:<lyle...@cgocable.net> wrote:
:
:>I think you are talking partly to me, Dev, about graying out the Close