Mercurial > dwindows
comparison win/dw.c @ 461:12ba7e744560
Fixes timer problems on Windows, however this may break Win95 support.
The Microsoft documentation is contradictory regarding this and I don't
have a copy of Win95 to test on here.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 09 Jul 2003 07:20:17 +0000 |
parents | 935436731b41 |
children | c3dfa117b080 |
comparison
equal
deleted
inserted
replaced
460:65bc397a7233 | 461:12ba7e744560 |
---|---|
1895 } | 1895 } |
1896 if(result != -1) | 1896 if(result != -1) |
1897 return result; | 1897 return result; |
1898 else | 1898 else |
1899 return DefWindowProc(hWnd, msg, mp1, mp2); | 1899 return DefWindowProc(hWnd, msg, mp1, mp2); |
1900 } | |
1901 | |
1902 VOID CALLBACK _TimerProc(HWND hwnd, UINT msg, UINT_PTR idEvent, DWORD dwTime) | |
1903 { | |
1904 _wndproc(hwnd, msg, (WPARAM)idEvent, 0); | |
1900 } | 1905 } |
1901 | 1906 |
1902 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 1907 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
1903 { | 1908 { |
1904 switch( msg ) | 1909 switch( msg ) |
3128 | 3133 |
3129 _dwtid = dw_thread_id(); | 3134 _dwtid = dw_thread_id(); |
3130 | 3135 |
3131 while(GetMessage(&msg, NULL, 0, 0)) | 3136 while(GetMessage(&msg, NULL, 0, 0)) |
3132 { | 3137 { |
3133 if(msg.hwnd == NULL && msg.message == WM_TIMER) | |
3134 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); | |
3135 TranslateMessage(&msg); | 3138 TranslateMessage(&msg); |
3136 DispatchMessage(&msg); | 3139 DispatchMessage(&msg); |
3137 } | 3140 } |
3138 } | 3141 } |
3139 | 3142 |
3150 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) | 3153 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) |
3151 { | 3154 { |
3152 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) | 3155 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) |
3153 { | 3156 { |
3154 GetMessage(&msg, NULL, 0, 0); | 3157 GetMessage(&msg, NULL, 0, 0); |
3155 if(msg.hwnd == NULL && msg.message == WM_TIMER) | |
3156 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); | |
3157 TranslateMessage(&msg); | 3158 TranslateMessage(&msg); |
3158 DispatchMessage(&msg); | 3159 DispatchMessage(&msg); |
3159 } | 3160 } |
3160 else | 3161 else |
3161 Sleep(1); | 3162 Sleep(1); |
3171 | 3172 |
3172 _dwtid = dw_thread_id(); | 3173 _dwtid = dw_thread_id(); |
3173 | 3174 |
3174 if(GetMessage(&msg, NULL, 0, 0)) | 3175 if(GetMessage(&msg, NULL, 0, 0)) |
3175 { | 3176 { |
3176 if(msg.hwnd == NULL && msg.message == WM_TIMER) | |
3177 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); | |
3178 TranslateMessage(&msg); | 3177 TranslateMessage(&msg); |
3179 DispatchMessage(&msg); | 3178 DispatchMessage(&msg); |
3180 } | 3179 } |
3181 } | 3180 } |
3182 | 3181 |
8066 */ | 8065 */ |
8067 int API dw_timer_connect(int interval, void *sigfunc, void *data) | 8066 int API dw_timer_connect(int interval, void *sigfunc, void *data) |
8068 { | 8067 { |
8069 if(sigfunc) | 8068 if(sigfunc) |
8070 { | 8069 { |
8071 int timerid = SetTimer(NULL, 0, interval, NULL); | 8070 int timerid = SetTimer(NULL, 0, interval, _TimerProc); |
8072 | 8071 |
8073 if(timerid) | 8072 if(timerid) |
8074 { | 8073 { |
8075 _new_signal(WM_TIMER, NULL, timerid, sigfunc, data); | 8074 _new_signal(WM_TIMER, NULL, timerid, sigfunc, data); |
8076 return timerid; | 8075 return timerid; |