Found this code off a google search to remove the close "X" from the title bar. But when I go to compile it throws an error.
Compile error: The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them PtrSafe attribute. - 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
-
-
Sub HideAccessCloseButton()
-
-
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 Sub
What do I need to do to fix this? I get it on all 3 Private Declare Functions.
I found it!
Here is the entire code: - Option Compare Database
-
Option Explicit
-
-
Public Declare PtrSafe Function _
-
GetSystemMenu _
-
Lib "user32" ( _
-
ByVal hwnd As Long, _
-
ByVal bRevert As Long) _
-
As Long
-
-
Public Declare PtrSafe Function _
-
EnableMenuItem _
-
Lib "user32" ( _
-
ByVal hMenu As Long, _
-
ByVal wIDEnableItem As Long, _
-
ByVal wEnable As Long) _
-
As Long
-
-
'******************************************************************************
-
'* This Procedure enables or disables the 'Close' button on the Access Window *
-
'* This prevents Users from accidentally closing the DB when they really *
-
'* only want to close a Report in Preview Mode. *
-
'******************************************************************************
-
Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
-
On Error Resume Next
-
-
Const clngMF_ByCommand As Long = &H0&
-
Const clngMF_Grayed As Long = &H1&
-
Const clngSC_Close As Long = &HF060&
-
-
Dim lngWindow As Long
-
Dim lngMenu As Long
-
Dim lngFlags As Long
-
-
lngWindow = Application.hWndAccessApp
-
lngMenu = GetSystemMenu(lngWindow, 0)
-
-
If fEnabled Then
-
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
-
Else
-
lngFlags = clngMF_ByCommand Or clngMF_Grayed
-
End If
-
-
Call EnableMenuItem(hMenu:=lngMenu, _
-
wIDEnableItem:=clngSC_Close, _
-
wEnable:=lngFlags)
-
-
End Sub
9 2487
DJ - Try this instead. It simply disables the button (or enables it).
Much easier to use. Put it in a standalone module and call it from anywhere else in your project. - '******************************************************************************
-
'* This Procedure enables or disables the 'Close' button on the Access Window *
-
'* This prevents Users from accidentally closing the DB when they really *
-
'* only want to close a Report in Preview Mode. *
-
'******************************************************************************
-
Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
-
On Error Resume Next
-
-
Const clngMF_ByCommand As Long = &H0&
-
Const clngMF_Grayed As Long = &H1&
-
Const clngSC_Close As Long = &HF060&
-
-
Dim lngWindow As Long
-
Dim lngMenu As Long
-
Dim lngFlags As Long
-
-
lngWindow = Application.hWndAccessApp
-
lngMenu = GetSystemMenu(lngWindow, 0)
-
-
If fEnabled Then
-
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
-
Else
-
lngFlags = clngMF_ByCommand Or clngMF_Grayed
-
End If
-
-
Call EnableMenuItem(hMenu:=lngMenu, _
-
wIDEnableItem:=clngSC_Close, _
-
wEnable:=lngFlags)
-
-
End Sub
I don't think it requires any additional declarations. Let me know if this works.
The code itself compiles, but my callout does not. - Private Sub Form_Load()
-
-
Call AccessCloseButtonEnabled
-
-
End Sub
Compile error: Argument not optional.
Argument again! I’ll ask the mods to let you figure this one out for now.
Easy solution. Just read some of your previous posts.
Your right it was an easy solution, so I got that fixed, still doesn't compile, but do to another spot in the public function - lngMenu = GetSystemMenu(lngWindow, 0)
Throws an error of:
Compile error:
Sub or function not defined
Any Idea on why this is doing this?
If I comment this out I get an error here: - Call EnableMenuItem(hMenu:=lngMenu, _
-
wIDEnableItem:=clngSC_Close, _
-
wEnable:=lngFlags)
Same error as above.
This should do it. I couldn’t remember the other declaration associated with it. But, you did a good job of troubleshooting to identify where the problem was. All part of the process. - Option Compare Database
-
Option Explicit
-
-
Private Declare PtrSafe Function GetSystemMenu Lib "user32" ( _
-
ByVal hwnd As Long, _
-
ByVal bRevert As Long) _
-
As Long
-
-
'******************************************************************************
-
'* This Procedure enables or disables the 'Close' button on the Access Window *
-
'* This prevents Users from accidentally closing the DB when they really *
-
'* only want to close a Report in Preview Mode. *
-
'******************************************************************************
-
Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
-
On Error Resume Next
-
-
Const clngMF_ByCommand As Long = &H0&
-
Const clngMF_Grayed As Long = &H1&
-
Const clngSC_Close As Long = &HF060&
-
-
Dim lngWindow As Long
-
Dim lngMenu As Long
-
Dim lngFlags As Long
-
-
lngWindow = Application.hWndAccessApp
-
lngMenu = GetSystemMenu(lngWindow, 0)
-
-
If fEnabled Then
-
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
-
Else
-
lngFlags = clngMF_ByCommand Or clngMF_Grayed
-
End If
-
-
Call EnableMenuItem(hMenu:=lngMenu, _
-
wIDEnableItem:=clngSC_Close, _
-
wEnable:=lngFlags)
-
-
End Sub
I will have to get back to this on Monday. I am missing a function that I have at work.
I found it!
Here is the entire code: - Option Compare Database
-
Option Explicit
-
-
Public Declare PtrSafe Function _
-
GetSystemMenu _
-
Lib "user32" ( _
-
ByVal hwnd As Long, _
-
ByVal bRevert As Long) _
-
As Long
-
-
Public Declare PtrSafe Function _
-
EnableMenuItem _
-
Lib "user32" ( _
-
ByVal hMenu As Long, _
-
ByVal wIDEnableItem As Long, _
-
ByVal wEnable As Long) _
-
As Long
-
-
'******************************************************************************
-
'* This Procedure enables or disables the 'Close' button on the Access Window *
-
'* This prevents Users from accidentally closing the DB when they really *
-
'* only want to close a Report in Preview Mode. *
-
'******************************************************************************
-
Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
-
On Error Resume Next
-
-
Const clngMF_ByCommand As Long = &H0&
-
Const clngMF_Grayed As Long = &H1&
-
Const clngSC_Close As Long = &HF060&
-
-
Dim lngWindow As Long
-
Dim lngMenu As Long
-
Dim lngFlags As Long
-
-
lngWindow = Application.hWndAccessApp
-
lngMenu = GetSystemMenu(lngWindow, 0)
-
-
If fEnabled Then
-
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
-
Else
-
lngFlags = clngMF_ByCommand Or clngMF_Grayed
-
End If
-
-
Call EnableMenuItem(hMenu:=lngMenu, _
-
wIDEnableItem:=clngSC_Close, _
-
wEnable:=lngFlags)
-
-
End Sub
- Public Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hwnd As LongPtr, ByVal bRevert As Long) As LongPtr
-
Public Declare PtrSafe Function EnableMenuItem Lib "user32" (ByVal hMenu As LongPtr, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
- Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
-
On Error Resume Next
-
Const clngMF_ByCommand As Long = &H0&
-
Const clngMF_Grayed As Long = &H1&
-
Const clngSC_Close As Long = &HF060&
-
Dim lngWindow As Long
-
Dim lngMenu As Long
-
Dim lngFlags As Long
-
-
lngWindow = Application.hWndAccessApp
-
lngMenu = GetSystemMenu(lngWindow, 0)
-
-
If pfEnabled Then
-
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
-
Else
-
lngFlags = clngMF_ByCommand Or clngMF_Grayed
-
End If
-
-
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
-
End Sub
- Call AccessCloseButtonEnabled(True)
- Call AccessCloseButtonEnabled(False)
Thanks everyone, works perfectly with no issues. You guys are the best. Hope everyone was a great week.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vetrivel |
last post by:
Application architecture : Develop interface between two existing
systems,
a. Enterprise CRM system
b. Web based intranet system.
Environment : Intranet
Server : IIS and ASP.
Script :...
|
by: David Gamble |
last post by:
I am having problems with long timeouts when connecting to
or executing commands in SQL Server 2000 SP3. I am
writing an application that will be used on laptops within
an environment that is...
|
by: Paul Mateer |
last post by:
Hi,
I have been running some queries against a table in a my database and
have noted an odd (at least it seems odd to me) performance issue.
The table has approximately 5 million rows and...
|
by: bob |
last post by:
Currently i'm writing some low level communication modules in C++ and
is thinking of putting it into a library so that it can be used in C#.
My concern is the performance issue when putting C++...
|
by: Dominic via DotNetMonster.com |
last post by:
With a little help from someone in this forum, I am currently creating forms
and then embedding them into tabpages, so that I get a display similar to
Lotus Notes. I have one container window, so I...
|
by: Dominic via DotNetMonster.com |
last post by:
With a little help from someone in this forum, I am currently creating forms
and then embedding them into tabpages, so that I get a display similar to
Lotus Notes. I have one container window, so I...
|
by: ronscottlangham |
last post by:
I have a WCF Web Service that I develop using the ASP.NET Development
Server in Visual Studio. In release, the web service will support both
HTTP and HTTPS. Initially I had only HTTP configured in...
|
by: SRK |
last post by:
Hi,
I have installed free TDS ODBC driver on Linux and from there I am
trying to connect to MS SQLSERVER installed on Windows machine. But it
gives me following error -
tsql -H ps6312 -p 1433...
|
by: robertybob |
last post by:
Hi
I have a label which has text that changes dependent on user input using the paint command. Say it says 'Hello World'.
When I drag the form around such that any part of the label goes...
|
by: fmwsvc |
last post by:
We are facing an issue when adding a client uri context in httpd.conf
we are migrating iplanet to apache
source OS version: Oracle Solaris on SPARC (64-bit) version 10
Source web server:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |