Проблема MFC ON_WM_TIMER() со статическим приведениемC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Проблема MFC ON_WM_TIMER() со статическим приведением

Сообщение Anonymous »

Проблемы с ON_WM_TIMER в моем классе CDatabaseApplicationApp, который расширяет CWinApp

Код: Выделить всё

> 1>c:\programs\databaseapplication\databaseapplication\databaseapplication.cpp(20):
> error C2440: 'static_cast' : cannot convert from 'void (__thiscall
> CDatabaseApplicationApp::* )(UINT_PTR)' to 'void (__thiscall CWnd::*
> )(UINT_PTR)' 1>          Types pointed to are unrelated; conversion
> requires reinterpret_cast, C-style cast or function-style cast
Я включил функцию OnTimer:

Код: Выделить всё

class CLifescanDatabaseApplicationApp : public CWinApp
{
public:
CLifescanDatabaseApplicationApp();
protected:
CLifescanDatabaseApplicationDlg * m_ptheWindow;
// Overrides
public:
virtual BOOL InitInstance();

// Implementation
afx_msg void OnTimer(UINT_PTR nTimerID);
DECLARE_MESSAGE_MAP()
};
это просто:

Код: Выделить всё

void CDatabaseApplicationApp::OnTimer(UINT_PTR nTimerID)
{
AfxMessageBox(_T("Help"));
}
Таймер устанавливается с помощью определения в верхней части исходного файла:

Код: Выделить всё

#define ID_TIMER_DATABASEQUERY 1
и SetTimer определены в

Код: Выделить всё

BOOL CDatabaseApplicationApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles.  Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);

CWinApp::InitInstance();

AfxEnableControlContainer();
AfxInitRichEdit2();
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));

m_ptheWindow = new CDatabaseApplicationDlg();
m_pMainWnd = m_ptheWindow;
if(m_ptheWindow!=nullptr)
{
m_ptheWindow->Create(CDatabaseApplicationDlg::IDD,CWnd::GetDesktopWindow());
m_ptheWindow->ShowWindow(SW_SHOW);
}
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}

if(!m_ptheWindow->SetTimer(ID_TIMER_DATABASEQUERY,10000,nullptr))
{
return false;
}
// Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return TRUE;
}
Есть идеи, как решить эту проблему?

Подробнее здесь: https://stackoverflow.com/questions/124 ... tatic-cast
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»