Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Attn James, Dev, Terry, Ken, Arvin, Michael, Pete B, Henry .. Lyle & others .. re messing with the access window

16 views
Skip to first unread message

Aequi

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
This code came from James and this works .. quite nice, BUT .. it
steals away the icon .. both on the title bar and in the task bar

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

Calum Reay

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
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>...

Joshua Rehman

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
Hello,

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).

Lyle Fairfield

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
Seems to me the setting the Caption bit off disables the boxes in the title
bar but leaves them and the icon visible. They are still enabled in the
toolbar icon. I have not experimented with this enough to know what grief it
might bring.
I can hope that someone will offer something more complete then this.
--
Lyle

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 Reay

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
I coudnt get this out of my mind so I sat down and wrote this (who needs
sleep!). I think this should give you what you need, it was rather more
simple than I first thought.

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


Lyle Fairfield

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
another way

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

Lyle Fairfield

unread,
Feb 13, 1999, 3:00:00 AM2/13/99
to
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 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)
>
>
>

Dev Ashish

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to

Aequi

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to
Better disable the restore event when double-clicking on the title bar
as well <g>

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.


Aequi

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to
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

Dev Ashish

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to
Sorry Lyle, I'm against the idea, not the posts that followed. I myself
posted similar code long ago I think, but not any more. These days I have
to point out such UI things to a few people at work quite regularly, and it
takes it's toll. <g> After all, who knows, next thing you know, folks will
want to block the three fingure salute, disable app switching,
and-who-knows-what.

-- (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

:>
:>
:>
:
:

Dev Ashish

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to
Hi Aequi,

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

0 new messages