Mercurial > dwindows
comparison win/dw.c @ 1799:165f6ffa8176
Attempted fix at dw_window_set_focus() from non-main threads on Windows.
Also change to allow dw_window_function() to be called on non-toplevel windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 27 Sep 2012 03:08:03 +0000 |
parents | 7f549994b633 |
children | 5ed9f7ea3882 |
comparison
equal
deleted
inserted
replaced
1798:9fb8339ae458 | 1799:165f6ffa8176 |
---|---|
11593 { | 11593 { |
11594 *year = *month = *day = 0; | 11594 *year = *month = *day = 0; |
11595 } | 11595 } |
11596 } | 11596 } |
11597 | 11597 |
11598 /* Internal function to set the focus from the window thread */ | |
11599 void _dw_set_focus(HWND handle) | |
11600 { | |
11601 SetFocus(handle); | |
11602 } | |
11603 | |
11598 /* | 11604 /* |
11599 * Sets the current focus item for a window/dialog. | 11605 * Sets the current focus item for a window/dialog. |
11600 * Parameters: | 11606 * Parameters: |
11601 * handle: Handle to the dialog item to be focused. | 11607 * handle: Handle to the dialog item to be focused. |
11602 * Remarks: | 11608 * Remarks: |
11603 * This is for use after showing the window/dialog. | 11609 * This is for use after showing the window/dialog. |
11604 */ | 11610 */ |
11605 void API dw_window_set_focus(HWND handle) | 11611 void API dw_window_set_focus(HWND handle) |
11606 { | 11612 { |
11607 SetFocus(handle); | 11613 if(_dwtid == (DWTID)-1) |
11614 SetFocus(handle); | |
11615 else | |
11616 dw_window_function(handle, (void *)_dw_set_focus, handle); | |
11608 } | 11617 } |
11609 | 11618 |
11610 /* | 11619 /* |
11611 * Sets the default focus item for a window/dialog. | 11620 * Sets the default focus item for a window/dialog. |
11612 * Parameters: | 11621 * Parameters: |
12159 * function: Function pointer to be called. | 12168 * function: Function pointer to be called. |
12160 * data: Pointer to the data to be passed to the function. | 12169 * data: Pointer to the data to be passed to the function. |
12161 */ | 12170 */ |
12162 void API dw_window_function(HWND handle, void *function, void *data) | 12171 void API dw_window_function(HWND handle, void *function, void *data) |
12163 { | 12172 { |
12164 SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data); | 12173 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data); |
12165 } | 12174 } |
12166 | 12175 |
12167 /* Functions for managing the user data lists that are associated with | 12176 /* Functions for managing the user data lists that are associated with |
12168 * a given window handle. Used in dw_window_set_data() and | 12177 * a given window handle. Used in dw_window_set_data() and |
12169 * dw_window_get_data(). | 12178 * dw_window_get_data(). |