IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

[ATL] Faire réagir une application ATL à un message "user-defined"


Sujet :

MFC

  1. #1
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut [ATL] Faire réagir une application ATL à un message "user-defined"
    Bonjour à tous,

    j'ai une application ATL , en fait RemoteSkin du Windows Media Player SDK 11, qui tourne parfaitement.

    D'autre part, j'ai une boîte de dialogue MFC, qui reçoit des messages user-defined en provenance d'un driver USB (HID, le driver des souris et claviers USB).
    Pour cela, la boîte MFC reçoit un message WM_HID_EVENT définit par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    #define WM_HID_EVENT     WM_APP + 200
    dans CMaBoite.cpp, j'ai
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    	BEGIN_MESSAGE_MAP(CMaBoite, CDialog)
    ON_MESSAGE(WM_HID_EVENT, OnHIDEvent)
    END_MESSAGE_MAP()
    dans CMaBoite.h, j'ai
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    	afx_msg LRESULT OnHIDEvent(WPARAM wParam, LPARAM lParam);
    + le corps de OnHIDEvent(...) qui traite les évènements.

    La boite MFC fonctionne parfaitement et reçoit bien les messages WM_HID_EVENT.

    Ma question:
    comment intégrer cette gestion des messages WM_HID_EVENT dans l'application ATL ? par exemple, par quoi remplacer le ON_MESSAGE des MFC en ATL?

    Merci d'avance

  2. #2
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Je n'ai pas le sample sous les yeux. Peux-tu m'en dire plus dessus? (type d'application, interface utilisateur)

  3. #3
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    RemoteSkin est une application qui lance une boite de dialogue, celle-ci créant un contrôle Active X Windows Media Player : voici les extraits qui j'espère t'aideront à comprendre :
    MainDlg.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
     
    // MainDlg.cpp : Implementation of CMainDlg
    //
    // Copyright (c) Microsoft Corporation. All rights reserved.
    //
     
    #include "stdafx.h"
    #include "resource.h"		// main symbols
     
    #include "MainDlg.h"
    #include "OpenURLDlg.h"
     
     
    // This constant is copied from wmp_i.c which can be generated from wmp.idl
    const IID DIID__WMPOCXEvents = {0x6BF52A51,0x394A,0x11d3,{0xB1,0x53,0x00,0xC0,0x4F,0x79,0xFA,0xA6}};
     
    /////////////////////////////////////////////////////////////////////////////
    // CMainDlg
     
    //***************************************************************************
    // Constructor
    //
    //***************************************************************************
    CMainDlg::CMainDlg()
    {
        m_pView = NULL;
    }
     
    //***************************************************************************
    // Destructor
    //
    //***************************************************************************
    CMainDlg::~CMainDlg()
    {
    }
     
    //***************************************************************************
    // OnInitDialog()
    // Initialize the dialog and create WMP OCX
    //
    //***************************************************************************
    LRESULT CMainDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        HRESULT                             hr = S_OK;
        RECT                                rcClient;
        CComPtr<IObjectWithSite>            spHostObject;
        CComPtr<IAxWinHostWindow>           spHost;
        CComObject<CRemoteHost>             *pRemoteHost = NULL;
     
     
        // Create an ActiveX control container
        AtlAxWinInit();
        m_pView = new CAxWindow();  
        if(!m_pView)
        {
            hr = E_OUTOFMEMORY;
        }
     
        if(SUCCEEDED(hr))
        {
            ::GetWindowRect(GetDlgItem(IDC_RANGE), &rcClient);
            ScreenToClient(&rcClient);
            m_pView->Create(m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
     
            if(::IsWindow(m_pView->m_hWnd))
            {
                hr = m_pView->QueryHost(IID_IObjectWithSite, (void **)&spHostObject);
    			if(!spHostObject.p)
    			{
    				hr = E_POINTER;
    			}
            }
        }
     
        // Create remote host which implements IServiceProvider and IWMPRemoteMediaServices
        if(SUCCEEDED(hr))
        {
            hr = CComObject<CRemoteHost>::CreateInstance(&pRemoteHost);
            if(pRemoteHost)
            {
                pRemoteHost->AddRef();
            }
    		else
    		{
    			hr = E_POINTER;
    		}
        }
     
        // Set site to the remote host
        if(SUCCEEDED(hr))
        {
            hr = spHostObject->SetSite((IWMPRemoteMediaServices *)pRemoteHost);
        }
     
        if(SUCCEEDED(hr))
        {
            hr = m_pView->QueryHost(&spHost);
    		if(!spHost.p)
    		{
    			hr = E_NOINTERFACE;
    		}
        }
     
        // Create WMP Control here
        if(SUCCEEDED(hr))
        {
            hr = spHost->CreateControl(CComBSTR(L"{6BF52A52-394A-11d3-B153-00C04F79FAA6}"), m_pView->m_hWnd, NULL);
        }
     
        if(SUCCEEDED(hr))
        {
            hr = m_pView->QueryControl(&m_spPlayer);
    		if(!m_spPlayer.p)
    		{
    			hr = E_NOINTERFACE;
    		}
        }
     
        // Set skin to be custom skin
        if(SUCCEEDED(hr))
        {
            // Hook the event listener
            DispEventAdvise(m_spPlayer);
            // Put the UI mode to be a skin
            hr = m_spPlayer->put_uiMode(CComBSTR(_T("custom")));
        }
     
        // Release remote host object
        if(pRemoteHost)
        {
            pRemoteHost->Release();
        }
     
     
    	return 1;  // Let the system set the focus
    }
     
     
     
    //***************************************************************************
    // OnDestroy()
    // Release WMP OCX and its container here
    //
    //***************************************************************************
    LRESULT CMainDlg::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        if(m_spPlayer)
        {
            // Unhook the event listener
            DispEventUnadvise(m_spPlayer);
            m_spPlayer.Release();
        }
        if(m_pView != NULL)
        {
            delete m_pView;
        }
     
        return 1;  // Let the system set the focus
    }
     
    //***************************************************************************
    // OnCancel()
    // When users click close button or press Esc, this function is called
    // to close main dialog
    //
    //***************************************************************************
    LRESULT CMainDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        EndDialog(wID);
        return 0;
    }
     
    //***************************************************************************
    // OnOpenURL()
    // When users click OpenURL button, this function is called to open
    // a dialog so that users can give URL to play
    //
    //***************************************************************************
    LRESULT CMainDlg::OnOpenURL(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        COpenURLDlg dlg;
        if(IDOK == dlg.DoModal() && m_spPlayer.p)
        {
            m_spPlayer->put_URL(dlg.m_bstrURL);
     
            CComPtr<IWMPControls>   spControls;
            m_spPlayer->get_controls(&spControls);
            if(spControls.p)
            {
                spControls->play();
            }
        }
     
        return 0;
    }
    (je n'ai pas repris TOUS les traitements de messages, seulement le OnOpenURL

    et le MainDlg.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
     
    // MainDlg.h : Declaration of the CMainDlg
    //
    // Copyright (c) Microsoft Corporation. All rights reserved.
    //
     
    #ifndef __MAINDLG_H_
    #define __MAINDLG_H_
     
    #include "resource.h"       // main symbols
    #include <atlhost.h>
    #include "wmp.h"
    #include "wmpids.h"
    #include "RemoteHost.h"
     
    static  _ATL_FUNC_INFO  PlayStateChangeInfo = { CC_STDCALL, VT_EMPTY, 1, {VT_I4} };
     
    /////////////////////////////////////////////////////////////////////////////
    // CMainDlg
    class CMainDlg : 
        public IDispEventSimpleImpl<IDC_WMP, CMainDlg, &DIID__WMPOCXEvents>,
        public CAxDialogImpl<CMainDlg>
    {
    public:
        CMainDlg();
        ~CMainDlg();
     
        enum { IDD = IDD_MAINDLG };
     
    BEGIN_MSG_MAP(CMainDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
    	COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
        COMMAND_ID_HANDLER(IDC_OPENURL, OnOpenURL)
        COMMAND_ID_HANDLER(IDC_GOTOML, OnGoToML)
    	COMMAND_HANDLER(IDC_NEXT, BN_CLICKED, OnBnClickedNext)
    	COMMAND_HANDLER(IDC_PREVIOUS, BN_CLICKED, OnBnClickedPrevious)
    	COMMAND_HANDLER(IDC_VOLUMEPLUS, BN_CLICKED, OnBnClickedVolumeplus)
    	COMMAND_HANDLER(IDC_VOLUMEMOINS, BN_CLICKED, OnBnClickedVolumemoins)
    	COMMAND_HANDLER(IDC_MORCEAUPLUS, BN_CLICKED, OnBnClickedMorceauplus)
    	COMMAND_HANDLER(IDC_VOLUME0, BN_CLICKED, OnBnClickedVolume0)
    	MESSAGE_HANDLER(WM_CREATE, OnCreate)
    END_MSG_MAP()
     
    BEGIN_SINK_MAP(CMainDlg)
        SINK_ENTRY_INFO(IDC_WMP, DIID__WMPOCXEvents, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, OnPlayStateChange, &PlayStateChangeInfo)
    END_SINK_MAP()
     
        LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
        LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
        LRESULT OnOpenURL(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
        LRESULT OnGoToML(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
        HRESULT STDMETHODCALLTYPE OnPlayStateChange(long NewState);
    private:
        CAxWindow                       *m_pView;
        CComPtr<IWMPPlayer4>            m_spPlayer; 
    public:
    	LRESULT OnBnClickedNext(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnBnClickedPrevious(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnBnClickedVolumeplus(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnBnClickedVolumemoins(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnBnClickedMorceauplus(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnBnClickedVolume0(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
     
    private:
    	void SendSomeData();
    public:
    };
     
    #endif //__MAINDLG_H_
    (désolé pour ce code fleuve)

    j'ai ajouté
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     MESSAGE_HANDLER(WM_HID_EVENT, OnHIDEvent)
    dans le BEGIN_MSG_MAP(CMainDlg)

    mais je n'atteins jamais OnHIDEvent.

    En revanche, dans mon code MFC similaire (boite de dialogue), le message WM_HID_EVENT, émis par le driver (identique dans les 2 applications) est bien aiguillé vers OnHIDEvent

    J'espère être suffisament clair

  4. #4
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Je peux voir ton OnHIDEvent?

  5. #5
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    voilà voilà:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
     
    /*
    *******************************************************************************
    * Name  : OnHIDEvent                                                          *
    * Notes : Message handler for all HID events                                  *
    *******************************************************************************
    */
    LRESULT CMainDlg::OnHIDEvent(UINT uMsg,WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
    //	CWindow Label = (CWindow) GetDlgItem(IDC_STATIC); // get dialog label
    	char NomProduit[255];                                    // text buffer
    	char Text[255];                                    // text buffer
    	UINT DevHandle;                                     // HID device handle
    	HIDBufferIn BufferIn;                               // HID read buffer
     
    	ATLTRACE("HIDEvent\n");
     
    	DevHandle = lParam;
    	switch(wParam)
    	{
    		// a HID device has been plugged in...
    	case NOTIFY_PLUGGED:
    		{
     
    			// is it our HID device...
    			if (GetVendorID(DevHandle) == VENDOR_ID && GetProductID(DevHandle) == PRODUCT_ID)
    			{
    				GetProductName(DevHandle,NomProduit,0xFF);
    				sprintf(Text,"Périph. USB %s connecté",NomProduit);
    				SetDlgItemText(IDC_ETAT_USB,Text);
    				ATLTRACE(Text);
    			}
    			return 1;
    		}
     
    		// a HID device has been removed...
    	case NOTIFY_UNPLUGGED:
    		{
    			// is it our HID device...
    			if (GetVendorID(DevHandle) == VENDOR_ID && GetProductID(DevHandle) == PRODUCT_ID)
    		//		Label.SetWindowText("USB Device has been UNPLUGGED");
    			strcpy(Text,"Périph. USB déconnecté");
    			SetDlgItemText(IDC_ETAT_USB,Text);
    			ATLTRACE(Text);
     
    			return 1;
    		}
     
    		// a HID device has been pluggined in or removed - this event
    		// is fired after all PLUGGED and UNPLUGGED messages have
    		// been dispatched...
    	case NOTIFY_CHANGED:
    		{
    			// we want our device to send read notification messages...
    			DevHandle = GetHandle(VENDOR_ID, PRODUCT_ID);
    			SetReadNotify(DevHandle, TRUE);
    			return 1;
    		}
     
    		// a HID device has sent some data...
    	case NOTIFY_READ:
    		{
    			// read the data...
    			Read(DevHandle, BufferIn);
     
    			// *** process data here ***
    			for (int i=0;i<8;i++) {
     
    				ATLTRACE("%02X ",BufferIn[i]);
     
    			}
    			ATLTRACE("\n");
     
    			// first element BufferIn[0] is the report ID, the
    			// rest of the buffer contains the data sent from 
    			// the HID device
    			return 1;
    		}
    	}
    	return 0;   
    }

  6. #6
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    C'est bizarre que ça ne marche pas...
    Le message, il est envoyé à ta boîte de dialogue en particulier, ou il est envoyé en broadcast?

  7. #7
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    Aie... aucune idée, je ne gère par l'émission du message :
    il est envoyé par une dll spécifique, mcHID.dll, dont voici le .h:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    #include <windows.h>
     
    // HID specific...
    //#define VENDOR_ID        0x046D	//1240
    //#define PRODUCT_ID       0xC215	//0005
    //HID
    #define VENDOR_ID        0x0461
    #define PRODUCT_ID       0x0020
     
    #define BUFFER_IN_SIZE   64
    #define BUFFER_OUT_SIZE  64
    typedef unsigned char HIDBufferIn  [BUFFER_IN_SIZE];
    typedef unsigned char HIDBufferOut [BUFFER_OUT_SIZE];
     
    // HID events...
    #define WM_HID_EVENT     WM_APP + 200
    #define NOTIFY_PLUGGED   0x0001
    #define NOTIFY_UNPLUGGED 0x0002
    #define NOTIFY_CHANGED   0x0003
    #define NOTIFY_READ      0x0004
     
    // HID interface...
    typedef BOOL (WINAPI *CONNECT) (HWND pHostWin);
    typedef BOOL (WINAPI *DISCONNECT) ();
    typedef UINT (WINAPI *GET_ITEM) (UINT);
    typedef UINT (WINAPI *GET_ITEM_COUNT) ();
    typedef BOOL (WINAPI *READ) (UINT, LPVOID);
    typedef BOOL (WINAPI *WRITE) (UINT, LPVOID);
    typedef BOOL (WINAPI *READ_EX) (UINT, UINT, LPVOID);
    typedef BOOL (WINAPI *WRITE_EX) (UINT, UINT, LPVOID);
    typedef UINT (WINAPI *GET_HANDLE) (UINT, UINT);
    typedef UINT (WINAPI *GET_VENDOR_ID) (UINT pHandle);
    typedef UINT (WINAPI *GET_PRODUCT_ID) (UINT pHandle);
    typedef UINT (WINAPI *GET_VERSION_ID) (UINT);
    typedef UINT (WINAPI *GET_VENDOR_NAME) (UINT, LPSTR, UINT);
    typedef UINT (WINAPI *GET_PRODUCT_NAME) (UINT, LPSTR, UINT);
    typedef UINT (WINAPI *GET_SERIAL_NUMBER) (UINT, LPSTR, UINT);
    typedef UINT (WINAPI *GET_INPUT_REPORT_LENGTH) (UINT);
    typedef UINT (WINAPI *GET_OUTPUT_REPORT_LENGTH) (UINT);
    typedef void (WINAPI *SET_READ_NOTIFY) (UINT, BOOL);
    typedef BOOL (WINAPI *IS_READ_NOTIFY_ENABLED) ();
    typedef BOOL (WINAPI *IS_AVAILABLE) ();
     
    extern CONNECT Connect;
    extern DISCONNECT Disconnect;
    extern GET_ITEM GetItem;
    extern GET_ITEM_COUNT GetItemCount;
    extern READ Read;
    extern WRITE Write;
    extern READ_EX ReadEx;
    extern WRITE_EX WriteEx;
    extern GET_HANDLE GetHandle;
    extern GET_VENDOR_ID GetVendorID;
    extern GET_PRODUCT_ID GetProductID;
    extern GET_VERSION_ID GetVersionID;
    extern GET_VENDOR_NAME GetVendorName;
    extern GET_PRODUCT_NAME GetProductName;
    extern GET_SERIAL_NUMBER GetSerialNumber;
    extern GET_INPUT_REPORT_LENGTH GetInputReportLength;
    extern GET_OUTPUT_REPORT_LENGTH GetOutputReportLength;
    extern SET_READ_NOTIFY SetReadNotify;
    extern IS_READ_NOTIFY_ENABLED IsReadNotifyEnabled;
    extern IS_AVAILABLE IsAvailable;
     
    extern int LoadHID();
    la partie envoie fonctionne bien, car, j'me répète, ça marche en MFC

  8. #8
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Est-ce normal que l'appel à la fonction Connect() ne soit pas dans le code posté?
    Car si j'ai bien compris, le message ne sera envoyé qu'au HWND passé en paramètre à Connect()...

  9. #9
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    désolé, j'ai oublié de te poster le OnCreate : le voici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    //***************************************************************************
    // OnCreate()
    // 
    //
    //***************************************************************************
     
    LRESULT CMainDlg::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    {
    	// TODO: Add your message handler code here and/or call default
     
     
    	// connect to the HID DLL
    	ATLTRACE("OnCreate\n");
     
    	if (LoadHID() == 0) { Connect(m_hWnd);
    ATLTRACE("Connection HID\n");
    	} //if
     
     
     
    	return 0;
    }
    j'ai bien le message "ConnectionHID" qui s'affiche
    j'ai essayé m_hWnd, this->m_hWnd et m_pView->m_hWnd comme argument,
    sans succès

  10. #10
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Connect() retourne bien une valeur non-nulle?

  11. #11
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    YYYEEEEEEEEEEESSSSSSSSSSSSS!

    Ca MARCHE !!!!
    en fait 2 erreurs:
    je ne passe jamais par OnCreate (j'sais pas pourquoi), mais je l'avais déjà remarqué, et j'avais doublé le code à la fin de InitDialog sans m'en rappeler

    ce qui fait que mes essais m_hWnd, this->m_hWnd et m_pView->m_hWnd comme argument à Connect dans OnCreate ne servaient à rien

    en fait, il fallait lui passer m_hWnd, et non pas m_pView->m_hWnd pour que les messages soient bien adressés à la boite de dialogue

    OUF, mon projet continue
    Merci Medinoc de m'avoir mis sur la voie et surtout de l'après-midi passé à m'aider
    A+

  12. #12
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Ah oui, les boîtes de dialogue ne reçoivent pas WM_CREATE ni WM_NCCREATE. Enfin plus précisément, elles les reçoivent, mais la WindowProc cachée ne les transmet pas à la DialogProc.

  13. #13
    Membre régulier Avatar de Philippe320
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    179
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 179
    Points : 99
    Points
    99
    Par défaut
    merci de l'info
    je retire donc le OnCreate

    Bonne soirée

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 14
    Dernier message: 20/02/2007, 09h26
  2. Faire réapparaitre une application
    Par cquadjul dans le forum C++Builder
    Réponses: 8
    Dernier message: 05/05/2006, 10h11
  3. Faire fonctionner une application monoposte en réseau
    Par obon dans le forum Bases de données
    Réponses: 3
    Dernier message: 30/04/2006, 10h26
  4. Réponses: 1
    Dernier message: 22/11/2005, 11h00
  5. Faire tourner une Application en Taches de fond
    Par ArkAng3 dans le forum MFC
    Réponses: 3
    Dernier message: 26/08/2005, 14h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo