Pb Handle, GetDlgItem() et TimerProc
Bonjour à tous!
J'aimerai utiliser la fonction GetDlgItem dans une de mes fonctions CALLBACK timerproc. Comme il faut lui donner en argument le handle de la fenêtre j'ai chercher à utiliser la fonction GetSafeHwnd().
Alors j'ai fait comme ca:
Code:
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
|
InstantResult::InstantResult(CWnd* pParent /*=NULL*/)
: CDialog(InstantResult::IDD, pParent)
{
HWND hwnd;
hwnd = GetSafeHwnd();
m_IdTimer=::SetTimer(hwnd,0,1000,TimerProc); // création d'un timer qui bat à la seconde
m_IdTimer2=::SetTimer(hwnd,1,500,TimerProc2); // création d'un timer qui bat à la seconde
}
VOID CALLBACK TimerProc(HWND /*hwnd*/,UINT /*uMsg*/,UINT_PTR /*idEvent*/,DWORD /*dwTime*/)
{
// timer function
unsigned char NoAuthmov[1]={141}; // not allowed to move command
WriteFile(hcom,NoAuthmov, 1, &m, NULL);
}
VOID CALLBACK TimerProc2(HWND hwnd ,UINT /*uMsg*/,UINT_PTR /*idEvent*/,DWORD /*dwTime*/)
{
CCom::PurgeTx();
CCom::ReadBuffer();
CEdit* editFiD=(CEdit*) GetDlgItem(hwnd,IDC_EDIT4);
editFiD->SetWindowText(data);
} |
Je ne comprends pas ce que j'ai fait de travers...8O
A l'exécution j'ai un .exe has triggered a breakpoint et la ligne surlignée est Debug Break;
}
et
CWnd::SetWindowtext
ENSURE(this)
Voyez vous sinon un autre moyen d'utiliser GetDlgItem dans mon timerproc ?
Merci d'avance