HRESULT WINAPI DirectDrawEnumerate( LPDDENUMCALLBACK lpCallback, LPVOID lpContext);
static BOOL WINAPI DriverAvailable(LPGUID guid, LPSTR desc, LPSTR name, LPVOID p );
qtdlg::qtdlg(QWidget *parent):QDialog(parent) { DirectDrawEnumerate((LPDDENUMCALLBACK)DriverAvailable, this);}
BOOL mfcdlg::OnInitDialog() { ..... // to do: your extra initialization code here DirectDrawEnumerate((LPDDENUMCALLBACK)DriverAvailable, this); ......}
BOOL WINAPI classname::DriverAvailable(LPGUID guid, LPSTR desc, LPSTR name, LPVOID p ){ DirectDrawWin* win = (DirectDrawWin*)p; if (win->totaldrivers >= MAXDRIVERS) return DDENUMRET_CANCEL; DriverInfo& info = win->driver[win->totaldrivers]; if (guid) { info.guid = (GUID*)new BYTE[sizeof(GUID)]; memcpy(info.guid, guid, sizeof(GUID)); } else info.guid=0; info.desc = strdup(desc); info.name = strdup(name); win->totaldrivers++; return DDENUMRET_OK;}
clаss MyDlg : public QDialog{ ... static BOOL WINAPI DriverAvailable(LPGUID guid, LPSTR desc, LPSTR name, LPVOID p ); BOOL MyDriverAvailable(LPGUID guid, LPSTR desc, LPSTR name); ...};
BOOL WINAPI MyDlg::DriverAvailable(LPGUID guid, LPSTR desc, LPSTR name, LPVOID p ){ return ((MyDlg*)p)->MyDriverAvailable(guid, desc, name);}BOOL MyDlg::MyDriverAvailable(LPGUID guid, LPSTR desc, LPSTR name){ ... // Это уже не статик метод ...}
BOOL WINAPI MyDlg::DriverAvailable(LPGUID guid, LPSTR desc, LPSTR name, LPVOID p ){ return ((MyDlg*)p)->MyDriverAvailable(guid, desc, name);}