+ Reply to Thread
Results 1 to 18 of 18

Converting the 32-bit version of a code to 64-bit Versions

  1. #1
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Question Converting the 32-bit version of a code to 64-bit Versions

    Hello,

    I'm having some problems regarding the editing and making the code to compile successfully on 64-bit Versions

    I've followed the differences of the code using the site here were each declaration can be saw on both version, but somehow the module will display an error about the different versions.
    https://www.jkp-ads.com/articles/apideclarations.asp

    Piece of code (also the entire document has been attached)

    Please Login or Register  to view this content.
    Is the Long vs LongPtr so important between versions? That's the problem?
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Quote Originally Posted by alexgoaga View Post
    Is the Long vs LongPtr so important between versions? That's the problem?
    Yes, it is essential to get that right, and you don't seem to have made any of the required changes from Jan Karel's site.
    Rory

  3. #3
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    ok, so I made the required changes to the code after reading every info I had about the x64 code. New one attached with a mismatch issue that i can't solve
    Attached Files Attached Files

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Converting the 32-bit version of a code to 64-bit Versions

    If I recall correctly this mouse scroll issue was looked at in depth last year but I don't remember any satisfactory outcome being posted. I think in 64bit "one direction" scrolling was the furthest I saw it taken to....(hope i'm wrong but ??)

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    In 64bit, Private hhkLowLevelMouse As Long needs to be Private hhkLowLevelMouse As LongPtr since that is what SetWindowsHookEx returns, so you need to put the declarations into the conditional compilation sections too.

  6. #6
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Changing the code for the 64bit, from Private hhkLowLevelMouse As Long to Private hhkLowLevelMouse As LongPtr results in the module will cause a new issue type mismatch at the line : LowLevelMouseProc = CallNextHookEx(0, nCode, wParam, ByVal lParam) and after a few seconds, excel will crash

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    And that's why I said it was essential to get them right!

    Callnexthookex also returns a LongPtr, not Long in 64bit, so your callback function needs to return a LongPtr too. I suggest you repeat the entire code inside the conditional compilation and replace the necessary Longs in the 64 bit section. It's a bit repetitive but should be easier to grasp and maintain.

  8. #8
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    i've tried that method but still the same issue is present.

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Then post all of the revised code for us to have a look at.

  10. #10
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Sure, added to the attachments with every test
    Attached Files Attached Files

  11. #11
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Found the previous thread if it helps

    https://www.excelforum.com/showthrea...89900#poststop

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    You haven't done what I suggested at all in that workbook.

    You should repeat all of the code inside each part of the conditional compilation clause. Then adjust the 64bit code section to use LongPtr for the variables and functions as necessary.

  13. #13
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Quote Originally Posted by rorya View Post
    You haven't done what I suggested at all in that workbook.

    You should repeat all of the code inside each part of the conditional compilation clause. Then adjust the 64bit code section to use LongPtr for the variables and functions as necessary.
    I have no idea what are you asking me to switch / move / replace can you submit a model?

  14. #14
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Completely untested.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Quote Originally Posted by rorya View Post
    Completely untested.
    Tested the file on a "faster" PC and after opening and trying to run the hook code, the excel instant closes without any warnings
    On a low-end PC an automation error is displayed for 1-2 seconds then immediately closes

  16. #16
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Told you it was untested (I don't have 64bit here). Try this one.

    I've never understood why people think this is worth it.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    04-13-2017
    Location
    Buchares
    MS-Off Ver
    2016
    Posts
    117

    Re: Converting the 32-bit version of a code to 64-bit Versions

    Quote Originally Posted by rorya View Post
    Told you it was untested (I don't have 64bit here). Try this one.

    I've never understood why people think this is worth it.
    I know that the code was untested i just wanna provide as much info and clearance for you / others in order to try and pin - point the problem exactly.

    As for the second idea : It's a nice feature to have on any available form that contains a large number of informations in a "tiny spot"

    Regarding the last attachment, works like a charm, perfectly on any available device.

    I reviewed the modifications you had made and i don't understand what or why or what the reason for spitting the code in 2 wide chucks / blocks of code separated by the excel version and why it didn't worked in the first place when the declarations were spitted in half (it's just for my personal knowledge )

    Thank you.

  18. #18
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Converting the 32-bit version of a code to 64-bit Versions

    You had a load of stuff declared incorrectly. Repeating all the code is messy but easier to make sure you have all the Long vs LongPtr declarations being used in the right places.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Formulas not working in higher version, 2010 Version to 2013 version
    By thilag in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-19-2015, 09:09 PM
  2. Get code that works on excel version 2007 to work on version 2010
    By Agent1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2014, 01:23 AM
  3. Replies: 2
    Last Post: 05-19-2014, 12:10 PM
  4. Replies: 1
    Last Post: 02-28-2014, 10:57 AM
  5. Replies: 7
    Last Post: 08-09-2008, 04:32 AM
  6. VBA code for different versions of Excel
    By AndersW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2006, 07:25 AM
  7. VBA Code Only Works in Some Excel Versions
    By mta37 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2005, 03:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1