Results 1 to 7 of 7

Thread: Last hWnd

  1. #1
    NOMADMAN
    Guest

    Last hWnd

    Is ther an API call or something to let me know the hWnd number for the last window? Or if I could get the hWnd number for the current window and I'll just keep track of it by myself. Thanks!

    Extra Credit Question: How do I now send text to that window, by its hWnd. Or another method works.

    NOMAD

  2. #2
    What do you mean by "last window?" Is it one of your forms?

    BTW, I remember reading somewhere that you should never store handles in variables because they are always changing, so you might want to record something other than a handle, such as the window's title.

  3. #3
    NOMADMAN
    Guest
    no it not one of my forms. could I send information to a form some other way? I guess I'm not explaining myself very well

    My over all goal is to capture the key presses before the application with the focus displays the symbol my application changes the keypressed to something else and sends a character or more to the application that has the focus... possible?

  4. #4
    Tygur
    Guest
    Well GetForegroundWindow will get the window that is in the foreground (and has focus).

    So you're looking to grab the keypresses sent to anothher app and change them before it receives them? If that's true, it can be done, but not in VB.

  5. #5
    Tygur
    Guest
    Originally posted by filburt1
    What do you mean by "last window?" Is it one of your forms?

    BTW, I remember reading somewhere that you should never store handles in variables because they are always changing, so you might want to record something other than a handle, such as the window's title.
    There is nothing wrong with storing a handle in a variable.

    I think you read what the MSDN Library says about storing the handle returned by the hWnd property of the form and various controls:
    Note Because the value of this property can change while a program is running, never store the hWnd value in a variable.
    The reason why they don't want you storing that in a variable is because in some cases, the hWnd can change, such as when a form is unloaded and reloaded. I would listen to that advice and always rely on the hWnd property instead of storing that in a variable. I believe it is also the same way for the hDC property. But for any other kind of handle, you have to store it in a variable if you're gonna use it.

  6. #6
    NOMADMAN
    Guest
    Tygur,

    Yes, that is what I'm trying to do... What language and how? I know Java and a bit of C++, either of those do any good?

    The KeyPreview option for my form in VB, does it let my app/form get the keypress before another app? I tried some stuff and it doesn't seem to. I don't think it does but if I can some how use that I'd rather make this program in VB (my strongest language)... but if this is a job for C++ then so be it.

    THANKS both of you

    NOMAD

  7. #7
    Tygur
    Guest
    C++

    I can't tell you how, because I've never done it. If you know C++, look into the SetWindowsHookEx API function. If you don't know C++, maybe someone else can help you out.

Posting Permissions

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



Click Here to Expand Forum to Full Width