473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

64-bit Issue when Compiling

DJRhino1175
221 128KB
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.

Expand|Select|Wrap|Line Numbers
  1. Private Const GWL_EXSTYLE = (-20)
  2. Private Const GWL_STYLE = (-16)
  3.  
  4. Private Const WS_MAXIMIZEBOX = &H10000
  5. Private Const WS_MINIMIZEBOX = &H20000
  6. Private Const WS_SYSMENU = &H80000
  7.  
  8. Private Const HWND_TOP = 0
  9. Private Const SWP_NOMOVE = &H2
  10. Private Const SWP_NOSIZE = &H1
  11. Private Const SWP_FRAMECHANGED = &H20
  12. Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
  13.  
  14. Private Declare Function SetWindowLong Lib "user32" _
  15. Alias "SetWindowLongA" (ByVal hwnd As Long, _
  16. ByVal nIndex As Long, ByVal dwNewLong As Long) _
  17. As Long
  18. Private Declare Function GetWindowLong Lib "user32" _
  19. Alias "GetWindowLongA" (ByVal hwnd As Long, _
  20. ByVal nIndex As Long) As Long
  21. Private Declare Function SetWindowPos Lib "user32" _
  22. (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
  23. ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
  24. ByVal cy As Long, ByVal wFlags As Long) As Long
  25.  
  26. Sub HideAccessCloseButton()
  27.  
  28.    Dim lngStyle As Long
  29.  
  30.    lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
  31.    lngStyle = lngStyle And Not WS_SYSMENU
  32.    Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
  33.    Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
  34.  
  35. End Sub
What do I need to do to fix this? I get it on all 3 Private Declare Functions.
Jun 7 '19 #1

✓ answered by twinnyfo

I found it!

Here is the entire code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Declare PtrSafe Function _
  5.     GetSystemMenu _
  6.     Lib "user32" ( _
  7.     ByVal hwnd As Long, _
  8.     ByVal bRevert As Long) _
  9.     As Long
  10.  
  11. Public Declare PtrSafe Function _
  12.     EnableMenuItem _
  13.     Lib "user32" ( _
  14.     ByVal hMenu As Long, _
  15.     ByVal wIDEnableItem As Long, _
  16.     ByVal wEnable As Long) _
  17.     As Long
  18.  
  19. '******************************************************************************
  20. '* This Procedure enables or disables the 'Close' button on the Access Window *
  21. '* This prevents Users from accidentally closing the DB when they really      *
  22. '* only want to close a Report in Preview Mode.                               *
  23. '******************************************************************************
  24. Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
  25. On Error Resume Next
  26.  
  27.     Const clngMF_ByCommand  As Long = &H0&
  28.     Const clngMF_Grayed     As Long = &H1&
  29.     Const clngSC_Close      As Long = &HF060&
  30.  
  31.     Dim lngWindow   As Long
  32.     Dim lngMenu     As Long
  33.     Dim lngFlags    As Long
  34.  
  35.     lngWindow = Application.hWndAccessApp
  36.     lngMenu = GetSystemMenu(lngWindow, 0)
  37.  
  38.     If fEnabled Then
  39.         lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  40.     Else
  41.         lngFlags = clngMF_ByCommand Or clngMF_Grayed
  42.     End If
  43.  
  44.     Call EnableMenuItem(hMenu:=lngMenu, _
  45.                         wIDEnableItem:=clngSC_Close, _
  46.                         wEnable:=lngFlags)
  47.  
  48. End Sub

9 2487
twinnyfo
3,653 Expert Mod 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. '******************************************************************************
  2. '* This Procedure enables or disables the 'Close' button on the Access Window *
  3. '* This prevents Users from accidentally closing the DB when they really      *
  4. '* only want to close a Report in Preview Mode.                               *
  5. '******************************************************************************
  6. Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
  7. On Error Resume Next
  8.  
  9.     Const clngMF_ByCommand  As Long = &H0&
  10.     Const clngMF_Grayed     As Long = &H1&
  11.     Const clngSC_Close      As Long = &HF060&
  12.  
  13.     Dim lngWindow   As Long
  14.     Dim lngMenu     As Long
  15.     Dim lngFlags    As Long
  16.  
  17.     lngWindow = Application.hWndAccessApp
  18.     lngMenu = GetSystemMenu(lngWindow, 0)
  19.  
  20.     If fEnabled Then
  21.         lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  22.     Else
  23.         lngFlags = clngMF_ByCommand Or clngMF_Grayed
  24.     End If
  25.  
  26.     Call EnableMenuItem(hMenu:=lngMenu, _
  27.                         wIDEnableItem:=clngSC_Close, _
  28.                         wEnable:=lngFlags)
  29.  
  30. End Sub
I don't think it requires any additional declarations. Let me know if this works.
Jun 7 '19 #2
DJRhino1175
221 128KB
The code itself compiles, but my callout does not.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     Call AccessCloseButtonEnabled
  4.  
  5. End Sub
Compile error: Argument not optional.
Jun 7 '19 #3
twinnyfo
3,653 Expert Mod 2GB
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.
Jun 7 '19 #4
DJRhino1175
221 128KB
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

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. Call EnableMenuItem(hMenu:=lngMenu, _
  2.                         wIDEnableItem:=clngSC_Close, _
  3.                         wEnable:=lngFlags)
Same error as above.
Jun 7 '19 #5
twinnyfo
3,653 Expert Mod 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Declare PtrSafe Function GetSystemMenu Lib "user32" ( _
  5.     ByVal hwnd As Long, _
  6.     ByVal bRevert As Long) _
  7.     As Long
  8.  
  9. '******************************************************************************
  10. '* This Procedure enables or disables the 'Close' button on the Access Window *
  11. '* This prevents Users from accidentally closing the DB when they really      *
  12. '* only want to close a Report in Preview Mode.                               *
  13. '******************************************************************************
  14. Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
  15. On Error Resume Next
  16.  
  17.     Const clngMF_ByCommand  As Long = &H0&
  18.     Const clngMF_Grayed     As Long = &H1&
  19.     Const clngSC_Close      As Long = &HF060&
  20.  
  21.     Dim lngWindow   As Long
  22.     Dim lngMenu     As Long
  23.     Dim lngFlags    As Long
  24.  
  25.     lngWindow = Application.hWndAccessApp
  26.     lngMenu = GetSystemMenu(lngWindow, 0)
  27.  
  28.     If fEnabled Then
  29.         lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  30.     Else
  31.         lngFlags = clngMF_ByCommand Or clngMF_Grayed
  32.     End If
  33.  
  34.     Call EnableMenuItem(hMenu:=lngMenu, _
  35.                         wIDEnableItem:=clngSC_Close, _
  36.                         wEnable:=lngFlags)
  37.  
  38. End Sub
Jun 7 '19 #6
twinnyfo
3,653 Expert Mod 2GB
I will have to get back to this on Monday. I am missing a function that I have at work.
Jun 8 '19 #7
twinnyfo
3,653 Expert Mod 2GB
I found it!

Here is the entire code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Declare PtrSafe Function _
  5.     GetSystemMenu _
  6.     Lib "user32" ( _
  7.     ByVal hwnd As Long, _
  8.     ByVal bRevert As Long) _
  9.     As Long
  10.  
  11. Public Declare PtrSafe Function _
  12.     EnableMenuItem _
  13.     Lib "user32" ( _
  14.     ByVal hMenu As Long, _
  15.     ByVal wIDEnableItem As Long, _
  16.     ByVal wEnable As Long) _
  17.     As Long
  18.  
  19. '******************************************************************************
  20. '* This Procedure enables or disables the 'Close' button on the Access Window *
  21. '* This prevents Users from accidentally closing the DB when they really      *
  22. '* only want to close a Report in Preview Mode.                               *
  23. '******************************************************************************
  24. Public Sub AccessCloseButtonEnabled(fEnabled As Boolean)
  25. On Error Resume Next
  26.  
  27.     Const clngMF_ByCommand  As Long = &H0&
  28.     Const clngMF_Grayed     As Long = &H1&
  29.     Const clngSC_Close      As Long = &HF060&
  30.  
  31.     Dim lngWindow   As Long
  32.     Dim lngMenu     As Long
  33.     Dim lngFlags    As Long
  34.  
  35.     lngWindow = Application.hWndAccessApp
  36.     lngMenu = GetSystemMenu(lngWindow, 0)
  37.  
  38.     If fEnabled Then
  39.         lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  40.     Else
  41.         lngFlags = clngMF_ByCommand Or clngMF_Grayed
  42.     End If
  43.  
  44.     Call EnableMenuItem(hMenu:=lngMenu, _
  45.                         wIDEnableItem:=clngSC_Close, _
  46.                         wEnable:=lngFlags)
  47.  
  48. End Sub
Jun 8 '19 #8
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Public Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hwnd As LongPtr, ByVal bRevert As Long) As LongPtr
  2. Public Declare PtrSafe Function EnableMenuItem Lib "user32" (ByVal hMenu As LongPtr, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Expand|Select|Wrap|Line Numbers
  1. Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
  2. On Error Resume Next
  3. Const clngMF_ByCommand As Long = &H0&
  4. Const clngMF_Grayed As Long = &H1&
  5. Const clngSC_Close As Long = &HF060&
  6. Dim lngWindow As Long
  7. Dim lngMenu As Long
  8. Dim lngFlags As Long
  9.  
  10. lngWindow = Application.hWndAccessApp
  11. lngMenu = GetSystemMenu(lngWindow, 0)
  12.  
  13. If pfEnabled Then
  14.   lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  15. Else
  16.   lngFlags = clngMF_ByCommand Or clngMF_Grayed
  17. End If
  18.  
  19. Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
  20. End Sub
Expand|Select|Wrap|Line Numbers
  1. Call AccessCloseButtonEnabled(True)
Expand|Select|Wrap|Line Numbers
  1. Call AccessCloseButtonEnabled(False)
Jun 8 '19 #9
DJRhino1175
221 128KB
Thanks everyone, works perfectly with no issues. You guys are the best. Hope everyone was a great week.
Jun 10 '19 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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 :...
1
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...
3
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...
1
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++...
1
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...
1
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...
0
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...
6
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...
12
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...
0
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:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.