comparison win/dw.c @ 986:87dc0f5f96d0

Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return. Changed return values of a number of functions to be consistent across platforms and use the defines.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 07 May 2011 05:14:06 +0000
parents 52cd98b7e45c
children dfa2204e231f
comparison
equal deleted inserted replaced
985:cfc0777aceb5 986:87dc0f5f96d0
6662 /* 6662 /*
6663 * Returns the index to the item in the list currently selected. 6663 * Returns the index to the item in the list currently selected.
6664 * Parameters: 6664 * Parameters:
6665 * handle: Handle to the listbox to be queried. 6665 * handle: Handle to the listbox to be queried.
6666 */ 6666 */
6667 unsigned int API dw_listbox_selected(HWND handle) 6667 int API dw_listbox_selected(HWND handle)
6668 { 6668 {
6669 char tmpbuf[100]; 6669 char tmpbuf[100];
6670 6670
6671 GetClassName(handle, tmpbuf, 99); 6671 GetClassName(handle, tmpbuf, 99);
6672 6672
7540 lvc.iSubItem = count; 7540 lvc.iSubItem = count;
7541 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc); 7541 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc);
7542 } 7542 }
7543 } 7543 }
7544 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES); 7544 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
7545 return TRUE; 7545 return DW_ERROR_NONE;
7546 } 7546 }
7547 7547
7548 /* 7548 /*
7549 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. 7549 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
7550 * Parameters: 7550 * Parameters:
7566 else 7566 else
7567 lvc.cx = 150; 7567 lvc.cx = 150;
7568 lvc.iSubItem = count; 7568 lvc.iSubItem = count;
7569 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc); 7569 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc);
7570 dw_container_setup(handle, flags, titles, count, -1); 7570 dw_container_setup(handle, flags, titles, count, -1);
7571 return TRUE; 7571 return DW_ERROR_NONE;
7572 } 7572 }
7573 7573
7574 /* 7574 /*
7575 * Obtains an icon from a module (or header in GTK). 7575 * Obtains an icon from a module (or header in GTK).
7576 * Parameters: 7576 * Parameters:
9078 * will be filled in with the handle. 9078 * will be filled in with the handle.
9079 */ 9079 */
9080 int API dw_module_load(char *name, HMOD *handle) 9080 int API dw_module_load(char *name, HMOD *handle)
9081 { 9081 {
9082 if(!handle) 9082 if(!handle)
9083 return -1; 9083 return DW_ERROR_UNKNOWN;
9084 9084
9085 *handle = LoadLibrary(name); 9085 *handle = LoadLibrary(name);
9086 return (NULL == *handle); 9086 return (NULL == *handle);
9087 } 9087 }
9088 9088
9094 * the address. 9094 * the address.
9095 */ 9095 */
9096 int API dw_module_symbol(HMOD handle, char *name, void**func) 9096 int API dw_module_symbol(HMOD handle, char *name, void**func)
9097 { 9097 {
9098 if(!func || !name) 9098 if(!func || !name)
9099 return -1; 9099 return DW_ERROR_UNKNOWN;
9100 9100
9101 if(0 == strlen(name)) 9101 if(0 == strlen(name))
9102 return -1; 9102 return DW_ERROR_UNKNOWN;
9103 9103
9104 *func = (void*)GetProcAddress(handle, name); 9104 *func = (void*)GetProcAddress(handle, name);
9105 return (NULL == *func); 9105 return (NULL == *func);
9106 } 9106 }
9107 9107
9187 * Parameters: 9187 * Parameters:
9188 * eve: The handle to the event returned by dw_event_new(). 9188 * eve: The handle to the event returned by dw_event_new().
9189 */ 9189 */
9190 int API dw_event_post(HEV eve) 9190 int API dw_event_post(HEV eve)
9191 { 9191 {
9192 return SetEvent(eve); 9192 return (SetEvent(eve) == 0);
9193 } 9193 }
9194 9194
9195 /* 9195 /*
9196 * Waits on a semaphore created by dw_event_new(), until the 9196 * Waits on a semaphore created by dw_event_new(), until the
9197 * event gets posted or until the timeout expires. 9197 * event gets posted or until the timeout expires.
9202 { 9202 {
9203 int rc; 9203 int rc;
9204 9204
9205 rc = WaitForSingleObject(eve, timeout); 9205 rc = WaitForSingleObject(eve, timeout);
9206 if(rc == WAIT_OBJECT_0) 9206 if(rc == WAIT_OBJECT_0)
9207 return 1; 9207 return DW_ERROR_NONE;
9208 if(rc == WAIT_ABANDONED) 9208 if(rc == WAIT_ABANDONED)
9209 return -1; 9209 return DW_ERROR_TIMEOUT;
9210 return 0; 9210 return DW_ERROR_GENERAL;
9211 } 9211 }
9212 9212
9213 /* 9213 /*
9214 * Closes a semaphore created by dw_event_new(). 9214 * Closes a semaphore created by dw_event_new().
9215 * Parameters: 9215 * Parameters:
9216 * eve: The handle to the event returned by dw_event_new(). 9216 * eve: The handle to the event returned by dw_event_new().
9217 */ 9217 */
9218 int API dw_event_close(HEV *eve) 9218 int API dw_event_close(HEV *eve)
9219 { 9219 {
9220 if(eve) 9220 if(eve)
9221 return CloseHandle(*eve); 9221 return (CloseHandle(*eve) == 0);
9222 return 0; 9222 return DW_ERROR_NONE;
9223 } 9223 }
9224 9224
9225 /* Create a named event semaphore which can be 9225 /* Create a named event semaphore which can be
9226 * opened from other processes. 9226 * opened from other processes.
9227 * Parameters: 9227 * Parameters:
9260 { 9260 {
9261 int rc; 9261 int rc;
9262 9262
9263 rc = ResetEvent(eve); 9263 rc = ResetEvent(eve);
9264 if(!rc) 9264 if(!rc)
9265 return 1; 9265 return DW_ERROR_GENERAL;
9266 9266
9267 return 0; 9267 return DW_ERROR_NONE;
9268 } 9268 }
9269 9269
9270 /* Sets the posted state of an event semaphore, any threads 9270 /* Sets the posted state of an event semaphore, any threads
9271 * waiting on the semaphore will no longer block. 9271 * waiting on the semaphore will no longer block.
9272 * Parameters: 9272 * Parameters: