Connecting Tech Pros Worldwide Help | Site Map

Quit, Close and AccessXP

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 06:39 PM
ktos
Guest
 
Posts: n/a
Default Quit, Close and AccessXP

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



  #2  
Old November 12th, 2005, 06:40 PM
Terry Kreft
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.