Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 15th, 2005, 01:26 PM
easy easy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 34 sec
Reputation Power: 0
(VBA) API calls - disable close report

hi all, sorry if this is a repost, but didn't find anything in searches.

in Access 2000 I have some reports for which I want the close button to be disabled. If it were as easy as a form I could just set the property, but reports don't have that property.

Here's what i have so far:

Code:
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 Declare Function GetMenuItemInfo Lib "user32" Alias _
"GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As _
Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Type MENUITEMINFO
	cbSize As Long
	fMask As Long
	fType As Long
	fState As Long
	wID As Long
	hSubMenu As Long
	hbmpChecked As Long
	hbmpUnchecked As Long
	dwItemData As Long
	dwTypeData As String
	cch As Long
End Type
Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&
 
Public Property Get Enabled() As Boolean
	Dim hWnd As Long
	Dim hMenu As Long
	Dim result As Long
	Dim MI As MENUITEMINFO
	MI.cbSize = Len(MI)
	MI.dwTypeData = String(80, 0)
	MI.cch = Len(MI.dwTypeData)
	MI.fMask = MF_GRAYED
	MI.wID = SC_CLOSE
	hWnd = Application.Reports("rptCommissionsEdit").hWnd
	hMenu = GetSystemMenu(hWnd, 0)
	result = GetMenuItemInfo(hMenu, MI.wID, 0, MI)
	Enabled = (MI.fState And MF_GRAYED) = 0
End Property
Public Property Let Enabled(boolClose As Boolean)
	Dim hWnd As Long
	Dim wFlags As Long
	Dim hMenu As Long
	Dim result As Long
	hWnd = Application.Reports("rptCommissionsEdit").hWnd
	hMenu = GetSystemMenu(hWnd, 0)
	If Not boolClose Then
		wFlags = MF_BYCOMMAND Or MF_GRAYED
	Else
		wFlags = MF_BYCOMMAND And Not MF_GRAYED
	End If
	result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Property


This is working as long as my report is not maximized. I think maybe the parts that are bold may have something to do with it, but I'm not sure.
Once the report is maximized, the close button becomes enabled again.

How can I make it so the close button is not enabled when the report is maximized?
thank you for any help you can give me. I'm frustrated.

Reply With Quote
  #2  
Old February 16th, 2005, 09:18 AM
Dumbo Dumbo is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 29 Dumbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 31 sec
Reputation Power: 0
Access report

Strange my Access Report does give you the option to set that the close button should not be shown.

Reply With Quote
  #3  
Old February 16th, 2005, 01:08 PM
easy easy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by Dumbo
Strange my Access Report does give you the option to set that the close button should not be shown.


what version of Access? I'm using 2000 and the option is not there

Reply With Quote
  #4  
Old February 16th, 2005, 03:23 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
What exactly are you trying to accomplish, maybe there is a another way to do what you are after.

S-
__________________
If you have found a particular post helpful, show your appreciation by adding reputation points to that user by clicking the "scales" image in the upper right had corner of their post.

Reply With Quote
  #5  
Old February 17th, 2005, 12:16 PM
easy easy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 34 sec
Reputation Power: 0
The main thing I want to do is control what happens when a user wants to close a report.

I have some reports that are basically an edit view: showing the user which records are going to be updated. When the user closes the report, I want him to be able to:

1- change is mind and keep the report open
2- close and allow updates to the records
3- close but do not update the records

Reply With Quote
  #6  
Old February 17th, 2005, 01:50 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
Assuming you are use a seperate unbound form (or bound form to a temp table) where the user actually makes the editing changes and the report shows records that he has changed for the purpose of previewing the changes.


I would use the OnClose event of the report to do what you are after, in conjuction with either another form (give you the ability for multiple options), or the inputbox function.

S-

Reply With Quote
  #7  
Old February 17th, 2005, 04:16 PM
easy easy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 34 sec
Reputation Power: 0
yeah, that's how I was handling it before I decided I should eliminate the close button. If it were possible to cancel the close event, that would be great, but since that's not possible, I just didn't like the options.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > (VBA) API calls - disable close report


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT