return _id;
}
private:
HWND _hwnd;
int _id;
};
We'll put the timer in our Controller object and initialize it there.
class Controller {
public:
Controller(HWND hwnd, CREATESTRUCT* pCreate);
~Controller();
void Timer(int id);
void Size(int x, int y);
void Paint();
void Command(int cmd);
private:
HWND _hwnd;
WinTimer _timer;
View _view;
};
Controller::Controller(HWND hwnd, CREATESTRUCT * pCreate) : _hwnd (hwnd), _timer (hwnd, 1), _view(pCreate->hInstance) {
_timer.Set (100);
}
Once set, the timer sends our program timer messages and we have to process them.
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
Controller* pCtrl = WinGetLong<Controller*>(hwnd);
switch (message) {
...
case WM_TIMER:
pCtrl->Timer(wParam);