DirectInput: window handle



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/12/2008 at 08:01, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hi,

    I want to add support for controlling via directinput. So far no problem, I've got all the inludes and libs working. But at least one function expects a window handle:

    HRESULT SetCooperativeLevel(HWND hwnd, DWORD dwFlags)

    >> Window handle to be associated with the device. This parameter must be a valid top-level window handle that belongs to the process. The window associated with the device must not be destroyed while it is still active in a DirectInput device. <<

    Is it possible to retrieve such a window handle? Since it must be a top-level window it must be the main c4d window, true?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/12/2008 at 13:41, xxxxxxxx wrote:

    I'm using now the handle of the desktop window and don't ask for exclusive use:

    SetCooperativeLevel(GetDesktopWindow(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)

    seems to work.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/12/2008 at 15:23, xxxxxxxx wrote:

    Seems pretty dangerous to me. Mainly, how does the desktop window fit the 'handle that belongs to the process' requirement? Afaik, Cinema explicitly does not expose any HWNDs for you to use, so whatever type of hack it takes for you to get the actual Cinema window, I think you may be better off approaching it from that direction. I don't know anything about DirectInput, so maybe there is some special caveat there, but I'd want to see something specified in the docs before I'd be comfortable using GetDesktopWindow.
    Raymond Chen has an old blog post here (http://blogs.msdn.com/oldnewthing/archive/2004/02/24/79212.aspx) in which he discusses some of the ways people misuse that call, along with some of the underlying implications; maybe it will  be helpful to you.
    Cheers,
    JD



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/12/2008 at 04:49, xxxxxxxx wrote:

    Oh, thanks for this hint. It seems that the DISCL_NONEXCLUSIVE | DISCL_BACKGROUND flags make the thing work. Now NULL is also accepted as window handle.

    So for me it looks like this: If you want the input device exclusive, you have to tell your window handle otherwise any handle including NULL is accepted.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/12/2008 at 02:57, xxxxxxxx wrote:

    The void *GetEditorWindow(void) function from c4d_bitmapfilter.h returns the window handle (HWND) of the Cinema 4D main window.

    void *GetWindowHandle() of GeDialog return the handle of a dialog window.

    cheers,
    Matthias


Log in to reply