Mercurial > dwindows
comparison win/dw.c @ 157:a07dd2e819f3
Added module support.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 12 Nov 2002 08:52:22 +0000 |
parents | 840c54766306 |
children | c555d06b6c93 |
comparison
equal
deleted
inserted
replaced
156:63258b34e70d | 157:a07dd2e819f3 |
---|---|
2301 | 2301 |
2302 if(GetCapture() == hwnd && percent) | 2302 if(GetCapture() == hwnd && percent) |
2303 { | 2303 { |
2304 POINT point; | 2304 POINT point; |
2305 RECT rect; | 2305 RECT rect; |
2306 static POINT lastpoint; | |
2306 | 2307 |
2307 GetCursorPos(&point); | 2308 GetCursorPos(&point); |
2308 GetWindowRect(hwnd, &rect); | 2309 GetWindowRect(hwnd, &rect); |
2309 | 2310 |
2310 if(PtInRect(&rect, point)) | 2311 if(memcmp(&point, &lastpoint, sizeof(POINT))) |
2311 { | 2312 { |
2312 int width = (rect.right - rect.left); | 2313 if(PtInRect(&rect, point)) |
2313 int height = (rect.bottom - rect.top); | |
2314 | |
2315 if(type == BOXHORZ) | |
2316 { | 2314 { |
2317 start = point.x - rect.left; | 2315 int width = (rect.right - rect.left); |
2318 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) | 2316 int height = (rect.bottom - rect.top); |
2319 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; | 2317 |
2318 if(type == BOXHORZ) | |
2319 { | |
2320 start = point.x - rect.left; | |
2321 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) | |
2322 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; | |
2323 } | |
2324 else | |
2325 { | |
2326 start = point.y - rect.top; | |
2327 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH) | |
2328 *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0; | |
2329 } | |
2330 _handle_splitbar_resize(hwnd, *percent, type, width, height); | |
2320 } | 2331 } |
2321 else | 2332 memcpy(&lastpoint, &point, sizeof(POINT)); |
2322 { | |
2323 start = point.y - rect.top; | |
2324 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH) | |
2325 *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0; | |
2326 } | |
2327 _handle_splitbar_resize(hwnd, *percent, type, width, height); | |
2328 } | 2333 } |
2329 } | 2334 } |
2330 break; | 2335 break; |
2331 } | 2336 } |
2332 } | 2337 } |
6400 void dw_beep(int freq, int dur) | 6405 void dw_beep(int freq, int dur) |
6401 { | 6406 { |
6402 Beep(freq, dur); | 6407 Beep(freq, dur); |
6403 } | 6408 } |
6404 | 6409 |
6410 /* Open a shared library and return a handle. | |
6411 * Parameters: | |
6412 * name: Base name of the shared library. | |
6413 * handle: Pointer to a module handle, | |
6414 * will be filled in with the handle. | |
6415 */ | |
6416 int dw_module_load(char *name, HMOD *handle) | |
6417 { | |
6418 if(!handle) | |
6419 return -1; | |
6420 | |
6421 *handle = LoadLibrary(name); | |
6422 return (NULL == *handle); | |
6423 } | |
6424 | |
6425 /* Queries the address of a symbol within open handle. | |
6426 * Parameters: | |
6427 * handle: Module handle returned by dw_module_load() | |
6428 * name: Name of the symbol you want the address of. | |
6429 * func: A pointer to a function pointer, to obtain | |
6430 * the address. | |
6431 */ | |
6432 int dw_module_symbol(HMOD handle, char *name, void**func) | |
6433 { | |
6434 if(!func || !name) | |
6435 return -1; | |
6436 | |
6437 if(0 == strlen(name)) | |
6438 return -1; | |
6439 | |
6440 *func = (void*)GetProcAddress(handle, name); | |
6441 return (NULL == *func); | |
6442 } | |
6443 | |
6444 /* Frees the shared library previously opened. | |
6445 * Parameters: | |
6446 * handle: Module handle returned by dw_module_load() | |
6447 */ | |
6448 int dw_module_close(HMOD handle) | |
6449 { | |
6450 return FreeLibrary(handle); | |
6451 } | |
6452 | |
6405 /* | 6453 /* |
6406 * Returns the handle to an unnamed mutex semaphore. | 6454 * Returns the handle to an unnamed mutex semaphore. |
6407 */ | 6455 */ |
6408 HMTX dw_mutex_new(void) | 6456 HMTX dw_mutex_new(void) |
6409 { | 6457 { |