Connecting Tech Pros Worldwide Forums | Help | Site Map

Quit, Close and AccessXP

ktos
Guest
 
Posts: n/a
#1: Nov 12 '05
Hello.

Has anybody idea, how to set off Close button on top right corner of Access
Window and set the File/Close option status acMenuGray?
I wrote my Access application and I need to control exiting of this
application. I do not have idea how to do it.

Please help me.

Coolz



Terry Kreft
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Quit, Close and AccessXP


The easiest way to handle closing th eAccess app gracefully is to open a
hidden form when the application opens.

Because Access cannot close until all forms are closed you can then easily
prevent the application from closing.

When the user closes the application correctly, one of the things you do is
close this hidden form before you close the application.

The things you are asking about can be done but involves API calls and is a
bit OTT if all you want is to force a clean close down.

If you realy want to do this though heres the code for removing the control
box.
' **********************************
' Code Start
Option Explicit

Private Declare Function GetForegroundWindow Lib "user32" () 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 Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20
'----------------------------------

Public Function NoControlBox()
Dim hwnd As Long
Dim lngStyle As Long
Dim lngFlags As Long
Dim i As Long

lngFlags = SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED
hwnd = hWndAccessApp
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle And (Not WS_SYSMENU)
i = SetWindowLong(hwnd, GWL_STYLE, lngStyle)

Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, lngFlags)
End Function
' Code Start
' **********************************

On the toolbar look at creating a custom toolbar for your application


Terry



"ktos" <ktos@cos.pl> wrote in message
news:bvaglu$k9m$1@nemesis.news.tpi.pl...[color=blue]
> Hello.
>
> Has anybody idea, how to set off Close button on top right corner of[/color]
Access[color=blue]
> Window and set the File/Close option status acMenuGray?
> I wrote my Access application and I need to control exiting of this
> application. I do not have idea how to do it.
>
> Please help me.
>
> Coolz
>
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes