Consulting

Results 1 to 6 of 6

Thread: HinstancePtr vs Hwnd?

  1. #1

    HinstancePtr vs Hwnd?

    How are they different?

    In Excel 2016:

    ?Application.Hwnd
    67444
    https://docs.microsoft.com/en-us/off...plication.hwnd

    ?Application.HinstancePtr
    140700483846144
    https://docs.microsoft.com/en-us/off...n.hinstanceptr

    ?Application.Hinstance
    "Automation error
    Catastrophic failure"
    https://docs.microsoft.com/en-us/off...tion.hinstance

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    1. HInstance / HInstancePt --


    Returns a handle to the instance of Excel represented by the Application object. Read-only Long.


    This property returns a correct handle only in the 32-bit version of Excel. In Excel, the HinstancePtr property was introduced, which works correctly in both 32-bit and 64-bit versions of Excel.




    2. Hwnd --


    Returns a Long indicating the top-level window handle of the Microsoft Excel window. Read-only.




    Basically I believe that the first is the handle of the application that was started by the O/S and which you see in ask Manager, and the second is the window and replated items that you see on the screen.





    Over simplified, but Task Manager closed the first, and Minimize, etc. changes the second (or so I think
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Bump to myself
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    Quote Originally Posted by SamT View Post
    Bump to myself
    @SamT, what does it mean to bump to yourself?
    Also, you forgot a comma in your signature.

  5. #5
    Quote Originally Posted by Paul_Hossler View Post
    1. HInstance / HInstancePt -- the instance of Excel started by the O/S, represented by the Application object.

    2. Hwnd -- the top-level window of Excel and replated items
    Great answer!

    Questions:

    • Started by the O/S? You mean started by the user? What if started by VBA? Does it matter what started it?
    • "replated"?


    thx
    Last edited by johnywhy; 07-22-2021 at 01:00 PM.

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    A1 - Probably doesn't matter what started it: User, CreateObject, etc.

    A2 - related
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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