Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 21st, 2006, 09:35 AM
Wayne
Guest
 
Posts: n/a
Default Disable Application Restore Button

I have found the following code on this newsgroup that removes the
Access Application minimize, restore and close buttons.

Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)


Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000


Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED


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


Function NoCloseInAccess()
Dim lngStyle As Long


lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE Or SWP_DRAWFRAME)
End Function


Function DoCloseInAccess()
Dim lngStyle As Long


lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle Or WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE Or SWP_DRAWFRAME)
End Function

The code works well but it is overkill for what I am wanting to do. I
only need to remove or disable the restore button of the application
window. Is this possible?

Any help is appreciated.

  #2  
Old January 21st, 2006, 10:05 AM
Wayne Gillespie
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

On 21 Jan 2006 01:24:54 -0800, "Wayne" <cqdigital@volcanomail.com> wrote:
[color=blue]
>I have found the following code on this newsgroup that removes the
>Access Application minimize, restore and close buttons.
>
>Private Const GWL_EXSTYLE = (-20)
>Private Const GWL_STYLE = (-16)
>
>
>Private Const WS_MAXIMIZEBOX = &H10000
>Private Const WS_MINIMIZEBOX = &H20000
>Private Const WS_SYSMENU = &H80000
>
>
>Private Const HWND_TOP = 0
>Private Const SWP_NOMOVE = &H2
>Private Const SWP_NOSIZE = &H1
>Private Const SWP_FRAMECHANGED = &H20
>Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
>
>
>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 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
>'
>
>
>Function NoCloseInAccess()
> Dim lngStyle As Long
>
>
> lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
> lngStyle = lngStyle And Not WS_SYSMENU
> Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
> Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or
>SWP_NOSIZE Or SWP_DRAWFRAME)
>End Function
>
>
>Function DoCloseInAccess()
> Dim lngStyle As Long
>
>
> lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
> lngStyle = lngStyle Or WS_SYSMENU
> Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
> Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or
>SWP_NOSIZE Or SWP_DRAWFRAME)
>End Function
>
>The code works well but it is overkill for what I am wanting to do. I
>only need to remove or disable the restore button of the application
>window. Is this possible?
>
>Any help is appreciated.[/color]

See this thread. (Watch for word wrap)

http://groups.google.com/group/comp....1445b0712088ab


Wayne Gillespie
Gosford NSW Australia
  #3  
Old January 21st, 2006, 10:35 AM
Wayne
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

Thanks Wayne. This is exactly what I was looking for. Much
appreciated.

  #4  
Old January 21st, 2006, 11:25 AM
Wayne
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

I have a similar problem with the restore button on my custom report
menu bar. I can tell the report that I don't want minimise, maximise
or close buttons (I have a custom menu item to close the report), but
I'm still left with the annoying restore button on the report menu bar.
Is there a way to remove this?

  #5  
Old January 21st, 2006, 01:35 PM
Wayne Gillespie
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

On 21 Jan 2006 03:09:16 -0800, "Wayne" <cqdigital@volcanomail.com> wrote:
[color=blue]
>I have a similar problem with the restore button on my custom report
>menu bar. I can tell the report that I don't want minimise, maximise
>or close buttons (I have a custom menu item to close the report), but
>I'm still left with the annoying restore button on the report menu bar.
> Is there a way to remove this?[/color]

You need to pass the hWnd of the report to a variation of the fActivateMaximizeBox function which passes the report's
name as an argument.

Add this function to the standard module containg the API functions from the other thread.

Public Function fActivateReportMaximizeBox(Enable As Boolean, strName As String)
Dim CurStyle As Long
Dim hWnd As Long

hWnd = Reports(strName).hWnd '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MAXIMIZEBOX) Then
CurStyle = CurStyle Or WS_MAXIMIZEBOX
End If
Else
If (CurStyle And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
CurStyle = CurStyle - WS_MAXIMIZEBOX
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)

End Function

Add this line to the OnOpen event of the report(s) you want to

Call fActivateReportMaximizeBox(False, Me.Name)

You can make the same basic change to anyone of the fumctions contained in the module.
If you want to also manipulate the buttons on forms, change -

hWnd = Reports(strName).hWnd
to
hWnd = Forms(strName).hWnd


Wayne Gillespie
Gosford NSW Australia
  #6  
Old January 21st, 2006, 09:05 PM
Wayne
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

Thanks again for the reply Wayne. Not sure what the problem is but the
restore button is still available on my custom menu bar, even after
calling the new function in the OnOpen event of the report.

  #7  
Old January 22nd, 2006, 12:15 AM
Wayne Gillespie
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

On 21 Jan 2006 12:54:52 -0800, "Wayne" <cqdigital@volcanomail.com> wrote:
[color=blue]
>Thanks again for the reply Wayne. Not sure what the problem is but the
>restore button is still available on my custom menu bar, even after
>calling the new function in the OnOpen event of the report.[/color]

I misread you you were after, the code will only affect the max/min/close buttons on the window the report is displayed
in, not the menu bar.

Can you not remove the restore button from the menu bar manually? Right click on the menu bar and select Customize.
Click on the restore button and drag it off the menu bar. Then close the Customize form.


Wayne Gillespie
Gosford NSW Australia
  #8  
Old January 22nd, 2006, 03:55 AM
Wayne
Guest
 
Posts: n/a
Default Re: Disable Application Restore Button

No, the restore button isn't there in "customise" view. It's weird
really. As I posted earlier, I have set the minimise, maximise and
close buttons to "none" in the report's properties. If I enable the
minimise and maximise buttons, the minimise button is visible next to
the restore button on the custom menu bar. If I disable the
minimise/maximise buttons, only the minimise button is removed, with
the restore button still being visible.

I think that these properties are primarily for the report window of a
non-maximised report with a sizeable border style - at least that is
what my experiments seem to suggest, because on the sizeable window of
a non-maximised report the buttons are removed as expected if the
properties are set to none, the restore button included. When a report
is opened maximised, the buttons are tranferred to the menu bar, with
the restore button apparently not being able to be removed by using the
properties sheet. Maybe this is a bug - I don't really know.

What I am trying to achieve is to stop the user from accidentally
clicking the restore button and being confronted with a report that is
less than full screen. If reports had a "OnResize" event as forms do,
I assume it would be a simple matter of maximising the report on this
event.

Anyhow, I think I may just have to live with the restore button unless
anyone has a workaround to get rid of it.

 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles