comparison win/dw.c @ 534:222b0f32e7c9

More Timer cleanups, but it still stops for no apparent reason!
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Mar 2004 22:37:21 +0000
parents 79696a852401
children 8f80ed604a89
comparison
equal deleted inserted replaced
533:a284fde5d471 534:222b0f32e7c9
2209 * occured and to update it's window title. 2209 * occured and to update it's window title.
2210 */ 2210 */
2211 if(cinfo && cinfo->buddy) 2211 if(cinfo && cinfo->buddy)
2212 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); 2212 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
2213 2213
2214 KillTimer(hWnd, 100); 2214 if(hWnd)
2215 KillTimer(hWnd, 100);
2215 2216
2216 return ret; 2217 return ret;
2217 } 2218 }
2218 break; 2219 break;
2219 case WM_TIMER: 2220 case WM_TIMER:
2333 _wndproc(hWnd, msg, mp1, mp2); 2334 _wndproc(hWnd, msg, mp1, mp2);
2334 break; 2335 break;
2335 case WM_KEYDOWN: 2336 case WM_KEYDOWN:
2336 case WM_KEYUP: 2337 case WM_KEYUP:
2337 { 2338 {
2338 if(mp1 == VK_UP || mp1 == VK_DOWN) 2339 if(hWnd && (mp1 == VK_UP || mp1 == VK_DOWN))
2339 { 2340 {
2340 BOOL ret; 2341 BOOL ret;
2341 2342
2342 if(!cinfo || !cinfo->pOldProc) 2343 if(!cinfo || !cinfo->pOldProc)
2343 ret = DefWindowProc(hWnd, msg, mp1, mp2); 2344 ret = DefWindowProc(hWnd, msg, mp1, mp2);
3054 NULL); 3055 NULL);
3055 3056
3056 dw_window_set_font(hwndBubble, DefaultFont); 3057 dw_window_set_font(hwndBubble, DefaultFont);
3057 dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW); 3058 dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW);
3058 3059
3059 SetTimer(hwnd, 1, 3000, NULL);
3060
3061 hFont = (HFONT)SendMessage(hwndBubble, WM_GETFONT, 0, 0); 3060 hFont = (HFONT)SendMessage(hwndBubble, WM_GETFONT, 0, 0);
3062 3061
3063 hdc = GetDC(hwndBubble); 3062 hdc = GetDC(hwndBubble);
3064 3063
3065 if(hFont) 3064 if(hFont)
3275 3274
3276 _dwtid = dw_thread_id(); 3275 _dwtid = dw_thread_id();
3277 3276
3278 while(GetMessage(&msg, NULL, 0, 0)) 3277 while(GetMessage(&msg, NULL, 0, 0))
3279 { 3278 {
3280 TranslateMessage(&msg); 3279 if(msg.hwnd == NULL && msg.message == WM_TIMER)
3281 DispatchMessage(&msg); 3280 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
3281 else
3282 {
3283 TranslateMessage(&msg);
3284 DispatchMessage(&msg);
3285 }
3282 } 3286 }
3283 } 3287 }
3284 3288
3285 /* 3289 /*
3286 * Runs a message loop for Dynamic Windows, for a period of milliseconds. 3290 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
3295 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) 3299 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
3296 { 3300 {
3297 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) 3301 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
3298 { 3302 {
3299 GetMessage(&msg, NULL, 0, 0); 3303 GetMessage(&msg, NULL, 0, 0);
3304 if(msg.hwnd == NULL && msg.message == WM_TIMER)
3305 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
3306 else
3307 {
3308 TranslateMessage(&msg);
3309 DispatchMessage(&msg);
3310 }
3311 }
3312 else
3313 Sleep(1);
3314 }
3315 }
3316
3317 /*
3318 * Processes a single message iteration and returns.
3319 */
3320 void API dw_main_iteration(void)
3321 {
3322 MSG msg;
3323
3324 _dwtid = dw_thread_id();
3325
3326 if(GetMessage(&msg, NULL, 0, 0))
3327 {
3328 if(msg.hwnd == NULL && msg.message == WM_TIMER)
3329 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
3330 else
3331 {
3300 TranslateMessage(&msg); 3332 TranslateMessage(&msg);
3301 DispatchMessage(&msg); 3333 DispatchMessage(&msg);
3302 } 3334 }
3303 else
3304 Sleep(1);
3305 }
3306 }
3307
3308 /*
3309 * Processes a single message iteration and returns.
3310 */
3311 void API dw_main_iteration(void)
3312 {
3313 MSG msg;
3314
3315 _dwtid = dw_thread_id();
3316
3317 if(GetMessage(&msg, NULL, 0, 0))
3318 {
3319 TranslateMessage(&msg);
3320 DispatchMessage(&msg);
3321 } 3335 }
3322 } 3336 }
3323 3337
3324 /* 3338 /*
3325 * Free's memory allocated by dynamic windows. 3339 * Free's memory allocated by dynamic windows.
3378 3392
3379 while (GetMessage(&msg,NULL,0,0)) 3393 while (GetMessage(&msg,NULL,0,0))
3380 { 3394 {
3381 if(msg.hwnd == NULL && msg.message == WM_TIMER) 3395 if(msg.hwnd == NULL && msg.message == WM_TIMER)
3382 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); 3396 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
3383 TranslateMessage(&msg); 3397 else
3384 DispatchMessage(&msg); 3398 {
3399 TranslateMessage(&msg);
3400 DispatchMessage(&msg);
3401 }
3385 if(dialog->done) 3402 if(dialog->done)
3386 break; 3403 break;
3387 } 3404 }
3388 dw_event_close(&dialog->eve); 3405 dw_event_close(&dialog->eve);
3389 tmp = dialog->result; 3406 tmp = dialog->result;