В болшенстве случаев достаточно определить метод класса как static:
Da, ja by perefraziroval - v men'shinstve sluchaev. V seti sushchestvuet kakoe - to kolichestvo statej, sejchas u menja ix net pod rukoj, no esli nado to najdu. Ja sdelal eto ne ochen' krasivo, no rabotaet, tak kak static bylo dlja menja ochen' sil'nym ogranicheniem. Vyrezal i privozhu kod, sut' zadachi - v dll chto - to pojavljaetsja i nado dergat' app, nel'zja bylo s pomoshch'ju Win Message i COM - point( poslednee na RSDN xorosho opisano):
// iz DLL
typedef void ( WINCALLBACKBCOM) (int nStatus, int nTracks);
WINCALLBACKBCOM* cb_func;
int openReadDevice( int typ, WINCALLBACKBCOM* cbf, void* param=NULL)
{
cb_func = NULL;
if( cbf != NULL)
{
cb_func = cbf;
...
}
else
{
...
}
return ...
}
// na App storone: dialog - bazirte prilozhenie
CUsbComAppDlg* own_win = NULL;
volatile int m_err, m_track;
UINT DisconnectThread( LPVOID param)
{
TRACE("DisconnectThread %d %d\n", m_err, m_track);
if( own_win != NULL)
{
own_win->WorkEvent( m_err, m_track) ;
}
return 0;
}
void call_back_event( int err, int track)
{
TRACE("call_back_event start %d %d\n", err, track);
m_err = err;
m_track = track;
if( own_win != NULL)
{
AfxBeginThread( DisconnectThread, NULL);
}
}
/////////////////////////////////////////////////////////////////////////////
BOOL CUsbComAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
...
own_win = this;
...
// otkryvaju dll i zooovy s peredachej
int err = openReadDevice( 0, call_back_event, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CUsbComAppDlg::WorkEvent( int err, int track)
{
// chto - to delaju s DLL-Funkcijami
}
Esli chto - to zabyl, to voprosy ili prjamo v mylo.
vetoshkin@lycos.de