Mercurial > dwindows
comparison win/dw.c @ 1531:783a464afab2
Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
Fixed a number of potentially dangerous code segments on OS/2 and Windows.
Updated inaccurate comments due to cut and paste and code changes and the readme.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 07 Jan 2012 13:59:58 +0000 |
parents | 5facb5380944 |
children | 6c55d68fd08a |
comparison
equal
deleted
inserted
replaced
1530:eecfceaf581f | 1531:783a464afab2 |
---|---|
580 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) | 580 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) |
581 { | 581 { |
582 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 582 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
583 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 583 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); |
584 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); | 584 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); |
585 char tmpbuf[100]; | 585 char tmpbuf[100] = {0}; |
586 | 586 |
587 GetClassName(handle, tmpbuf, 99); | 587 GetClassName(handle, tmpbuf, 99); |
588 | 588 |
589 /* Don't try to free memory from an OLE embedded IE */ | 589 /* Don't try to free memory from an OLE embedded IE */ |
590 if(strncmp(tmpbuf, "Internet Explorer_Server", 25) == 0) | 590 if(strncmp(tmpbuf, "Internet Explorer_Server", 25) == 0) |
727 /* This function returns 1 if the window (widget) handle | 727 /* This function returns 1 if the window (widget) handle |
728 * passed to it is a valid window that can gain input focus. | 728 * passed to it is a valid window that can gain input focus. |
729 */ | 729 */ |
730 int _validate_focus(HWND handle) | 730 int _validate_focus(HWND handle) |
731 { | 731 { |
732 char tmpbuf[100]; | 732 char tmpbuf[100] = {0}; |
733 | 733 |
734 if(!handle) | 734 if(!handle) |
735 return 0; | 735 return 0; |
736 | 736 |
737 if(!IsWindowEnabled(handle)) | 737 if(!IsWindowEnabled(handle)) |
754 return 0; | 754 return 0; |
755 } | 755 } |
756 | 756 |
757 HWND _normalize_handle(HWND handle) | 757 HWND _normalize_handle(HWND handle) |
758 { | 758 { |
759 char tmpbuf[100] = ""; | 759 char tmpbuf[100] = {0}; |
760 | 760 |
761 GetClassName(handle, tmpbuf, 99); | 761 GetClassName(handle, tmpbuf, 99); |
762 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ | 762 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ |
763 { | 763 { |
764 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 764 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
849 | 849 |
850 lasthwnd = _normalize_handle(box->items[z].hwnd); | 850 lasthwnd = _normalize_handle(box->items[z].hwnd); |
851 } | 851 } |
852 else | 852 else |
853 { | 853 { |
854 char tmpbuf[100] = ""; | 854 char tmpbuf[100] = {0}; |
855 | 855 |
856 GetClassName(box->items[z].hwnd, tmpbuf, 99); | 856 GetClassName(box->items[z].hwnd, tmpbuf, 99); |
857 | 857 |
858 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 858 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) |
859 { | 859 { |
984 | 984 |
985 lasthwnd = _normalize_handle(box->items[z].hwnd); | 985 lasthwnd = _normalize_handle(box->items[z].hwnd); |
986 } | 986 } |
987 else | 987 else |
988 { | 988 { |
989 char tmpbuf[100] = ""; | 989 char tmpbuf[100] = {0}; |
990 | 990 |
991 GetClassName(box->items[z].hwnd, tmpbuf, 99); | 991 GetClassName(box->items[z].hwnd, tmpbuf, 99); |
992 | 992 |
993 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 993 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) |
994 { | 994 { |
1050 * layout and moves the current focus to it. | 1050 * layout and moves the current focus to it. |
1051 */ | 1051 */ |
1052 void _initial_focus(HWND handle) | 1052 void _initial_focus(HWND handle) |
1053 { | 1053 { |
1054 Box *thisbox; | 1054 Box *thisbox; |
1055 char tmpbuf[100]; | 1055 char tmpbuf[100] = {0}; |
1056 | 1056 |
1057 if(!handle) | 1057 if(!handle) |
1058 return; | 1058 return; |
1059 | 1059 |
1060 GetClassName(handle, tmpbuf, 99); | 1060 GetClassName(handle, tmpbuf, 99); |
1084 return 0; | 1084 return 0; |
1085 lastbox = box; | 1085 lastbox = box; |
1086 } | 1086 } |
1087 if(lastbox) | 1087 if(lastbox) |
1088 { | 1088 { |
1089 char tmpbuf[100]; | 1089 char tmpbuf[100] = {0}; |
1090 | 1090 |
1091 GetClassName(lastbox, tmpbuf, 99); | 1091 GetClassName(lastbox, tmpbuf, 99); |
1092 | 1092 |
1093 if(strncmp(tmpbuf, ClassName, strlen(ClassName)+1)==0) | 1093 if(strncmp(tmpbuf, ClassName, strlen(ClassName)+1)==0) |
1094 return lastbox; | 1094 return lastbox; |
1332 /* If the calculated size is valid... */ | 1332 /* If the calculated size is valid... */ |
1333 if(width > 0 && height > 0) | 1333 if(width > 0 && height > 0) |
1334 { | 1334 { |
1335 int pad = thisbox->items[z].pad; | 1335 int pad = thisbox->items[z].pad; |
1336 HWND handle = thisbox->items[z].hwnd; | 1336 HWND handle = thisbox->items[z].hwnd; |
1337 char tmpbuf[100]; | 1337 char tmpbuf[100] = {0}; |
1338 | 1338 |
1339 GetClassName(handle, tmpbuf, 99); | 1339 GetClassName(handle, tmpbuf, 99); |
1340 | 1340 |
1341 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 1341 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
1342 { | 1342 { |
1440 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1440 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1441 | 1441 |
1442 if(cinfo && cinfo->vcenter) | 1442 if(cinfo && cinfo->vcenter) |
1443 { | 1443 { |
1444 /* We are centered so calculate a new position */ | 1444 /* We are centered so calculate a new position */ |
1445 char tmpbuf[1024]; | 1445 char tmpbuf[1024] = {0}; |
1446 int textheight, diff, total = height; | 1446 int textheight, diff, total = height; |
1447 | 1447 |
1448 GetWindowText(handle, tmpbuf, 1023); | 1448 GetWindowText(handle, tmpbuf, 1023); |
1449 | 1449 |
1450 /* Figure out how big the text is */ | 1450 /* Figure out how big the text is */ |
1855 tmp->message == NM_RCLICK || | 1855 tmp->message == NM_RCLICK || |
1856 tmp->message == TVN_ITEMEXPANDED) | 1856 tmp->message == TVN_ITEMEXPANDED) |
1857 { | 1857 { |
1858 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2; | 1858 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2; |
1859 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2; | 1859 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2; |
1860 char tmpbuf[100]; | 1860 char tmpbuf[100] = {0}; |
1861 | 1861 |
1862 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99); | 1862 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99); |
1863 | 1863 |
1864 if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0) | 1864 if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0) |
1865 { | 1865 { |
2027 } | 2027 } |
2028 break; | 2028 break; |
2029 case WM_HSCROLL: | 2029 case WM_HSCROLL: |
2030 case WM_VSCROLL: | 2030 case WM_VSCROLL: |
2031 { | 2031 { |
2032 char tmpbuf[100] = ""; | 2032 char tmpbuf[100] = {0}; |
2033 HWND handle = (HWND)mp2; | 2033 HWND handle = (HWND)mp2; |
2034 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction; | 2034 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction; |
2035 | 2035 |
2036 if(!GetClassName(handle, tmpbuf, 99)) | 2036 if(!GetClassName(handle, tmpbuf, 99)) |
2037 { | 2037 { |
2170 break; | 2170 break; |
2171 case WM_HSCROLL: | 2171 case WM_HSCROLL: |
2172 case WM_VSCROLL: | 2172 case WM_VSCROLL: |
2173 { | 2173 { |
2174 HWND handle = (HWND)mp2; | 2174 HWND handle = (HWND)mp2; |
2175 char tmpbuf[100]; | |
2176 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT; | 2175 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT; |
2177 | 2176 |
2178 if(dw_window_get_data(handle, "_dw_scrollbar")) | 2177 if(dw_window_get_data(handle, "_dw_scrollbar")) |
2179 { | 2178 { |
2180 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); | 2179 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
2182 if(value > -1) | 2181 if(value > -1) |
2183 dw_scrollbar_set_pos(handle, value); | 2182 dw_scrollbar_set_pos(handle, value); |
2184 } | 2183 } |
2185 else | 2184 else |
2186 { | 2185 { |
2186 char tmpbuf[100] = {0}; | |
2187 | |
2187 GetClassName( hWnd, tmpbuf, 99 ); | 2188 GetClassName( hWnd, tmpbuf, 99 ); |
2188 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 ) | 2189 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 ) |
2189 { | 2190 { |
2190 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); | 2191 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
2191 } | 2192 } |
2492 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | 2493 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); |
2493 } | 2494 } |
2494 | 2495 |
2495 void _click_default(HWND handle) | 2496 void _click_default(HWND handle) |
2496 { | 2497 { |
2497 char tmpbuf[100]; | 2498 char tmpbuf[100] = {0}; |
2498 | 2499 |
2499 GetClassName(handle, tmpbuf, 99); | 2500 GetClassName(handle, tmpbuf, 99); |
2500 | 2501 |
2501 /* These are the window classes which can | 2502 /* These are the window classes which can |
2502 * obtain input focus. | 2503 * obtain input focus. |
2529 | 2530 |
2530 /* Subclass function that will handle setting colors on controls */ | 2531 /* Subclass function that will handle setting colors on controls */ |
2531 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 2532 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
2532 { | 2533 { |
2533 ColorInfo *cinfo; | 2534 ColorInfo *cinfo; |
2534 char tmpbuf[100]; | 2535 char tmpbuf[100] = {0}; |
2535 WNDPROC pOldProc = 0; | 2536 WNDPROC pOldProc = 0; |
2536 int ret = -1; | 2537 int ret = -1; |
2537 | 2538 |
2538 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); | 2539 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); |
2539 | 2540 |
4229 * Buttons/Bitmaps: Size of text or image and border. | 4230 * Buttons/Bitmaps: Size of text or image and border. |
4230 */ | 4231 */ |
4231 void _control_size(HWND handle, int *width, int *height) | 4232 void _control_size(HWND handle, int *width, int *height) |
4232 { | 4233 { |
4233 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; | 4234 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; |
4234 char tmpbuf[100], *buf = dw_window_get_text(handle); | 4235 char tmpbuf[100] = {0}, *buf = dw_window_get_text(handle); |
4235 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 4236 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
4236 HBITMAP hbm = 0; | 4237 HBITMAP hbm = 0; |
4237 | 4238 |
4238 GetClassName(handle, tmpbuf, 99); | 4239 GetClassName(handle, tmpbuf, 99); |
4239 | 4240 |
4350 */ | 4351 */ |
4351 int API dw_window_set_font(HWND handle, char *fontname) | 4352 int API dw_window_set_font(HWND handle, char *fontname) |
4352 { | 4353 { |
4353 HFONT hfont, oldfont; | 4354 HFONT hfont, oldfont; |
4354 ColorInfo *cinfo; | 4355 ColorInfo *cinfo; |
4355 char tmpbuf[100]; | 4356 char tmpbuf[100] = {0}; |
4356 | 4357 |
4357 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 4358 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
4358 | 4359 |
4359 GetClassName(handle, tmpbuf, 99); | 4360 GetClassName(handle, tmpbuf, 99); |
4360 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) | 4361 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) |
4465 char *str = NULL; | 4466 char *str = NULL; |
4466 char *bold = ""; | 4467 char *bold = ""; |
4467 char *italic = ""; | 4468 char *italic = ""; |
4468 LOGFONT lf = { 0 }; | 4469 LOGFONT lf = { 0 }; |
4469 Box *thisbox; | 4470 Box *thisbox; |
4470 char tmpbuf[100]; | 4471 char tmpbuf[100] = {0}; |
4471 | 4472 |
4472 GetClassName(handle, tmpbuf, 99); | 4473 GetClassName(handle, tmpbuf, 99); |
4473 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) | 4474 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) |
4474 { | 4475 { |
4475 /* groupbox */ | 4476 /* groupbox */ |
4511 */ | 4512 */ |
4512 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) | 4513 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
4513 { | 4514 { |
4514 ColorInfo *cinfo; | 4515 ColorInfo *cinfo; |
4515 Box *thisbox; | 4516 Box *thisbox; |
4516 char tmpbuf[100]; | 4517 char tmpbuf[100] = {0}; |
4517 | 4518 |
4518 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 4519 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
4519 | 4520 |
4520 GetClassName(handle, tmpbuf, 99); | 4521 GetClassName(handle, tmpbuf, 99); |
4521 | 4522 |
6263 * text: The text associsated with a given window. | 6264 * text: The text associsated with a given window. |
6264 */ | 6265 */ |
6265 void API dw_window_set_text(HWND handle, char *text) | 6266 void API dw_window_set_text(HWND handle, char *text) |
6266 { | 6267 { |
6267 Box *thisbox; | 6268 Box *thisbox; |
6268 char tmpbuf[100]; | 6269 char tmpbuf[100] = {0}; |
6269 | 6270 |
6270 GetClassName(handle, tmpbuf, 99); | 6271 GetClassName(handle, tmpbuf, 99); |
6271 | 6272 |
6272 SetWindowText(handle, text); | 6273 SetWindowText(handle, text); |
6273 | 6274 |
6323 * Returns: | 6324 * Returns: |
6324 * text: The text associsated with a given window. | 6325 * text: The text associsated with a given window. |
6325 */ | 6326 */ |
6326 char * API dw_window_get_text(HWND handle) | 6327 char * API dw_window_get_text(HWND handle) |
6327 { | 6328 { |
6328 char tmpbuf[100], *tempbuf; | 6329 char tmpbuf[100] = {0}, *tempbuf; |
6329 int len; | 6330 int len; |
6330 | 6331 |
6331 GetClassName(handle, tmpbuf, 99); | 6332 GetClassName(handle, tmpbuf, 99); |
6332 | 6333 |
6333 if ( strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) | 6334 if ( strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) |
6421 | 6422 |
6422 /* Internal box packing function called by the other 3 functions */ | 6423 /* Internal box packing function called by the other 3 functions */ |
6423 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) | 6424 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) |
6424 { | 6425 { |
6425 Box *thisbox = NULL; | 6426 Box *thisbox = NULL; |
6426 char tmpbuf[100]; | 6427 char tmpbuf[100] = {0}; |
6427 | 6428 |
6428 /* | 6429 /* |
6429 * If you try and pack an item into itself VERY bad things can happen; like at least an | 6430 * If you try and pack an item into itself VERY bad things can happen; like at least an |
6430 * infinite loop on GTK! Lets be safe! | 6431 * infinite loop on GTK! Lets be safe! |
6431 */ | 6432 */ |
6641 * width: Width in pixels of the item or NULL if not needed. | 6642 * width: Width in pixels of the item or NULL if not needed. |
6642 * height: Height in pixels of the item or NULL if not needed. | 6643 * height: Height in pixels of the item or NULL if not needed. |
6643 */ | 6644 */ |
6644 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) | 6645 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) |
6645 { | 6646 { |
6646 _control_size(handle, width, height); | 6647 char tmpbuf[100] = {0}; |
6648 | |
6649 GetClassName(handle, tmpbuf, 99); | |
6650 | |
6651 if(strnicmp(tmpbuf, ClassName, strlen(ClassName)+1) == 0) | |
6652 { | |
6653 unsigned long thiswidth = 0, thisheight = 0; | |
6654 | |
6655 /* Get the size with the border */ | |
6656 _get_window_for_size(handle, &thiswidth, &thisheight); | |
6657 | |
6658 /* Return what was requested */ | |
6659 if(width) *width = (int)thiswidth; | |
6660 if(height) *height = (int)thisheight; | |
6661 } | |
6662 else if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0) | |
6663 { | |
6664 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); | |
6665 | |
6666 if(thisbox) | |
6667 { | |
6668 int depth = 0; | |
6669 | |
6670 /* Calculate space requirements */ | |
6671 _resize_box(thisbox, &depth, 0, 0, 1); | |
6672 | |
6673 /* Return what was requested */ | |
6674 if(width) *width = thisbox->minwidth; | |
6675 if(height) *height = thisbox->minheight; | |
6676 } | |
6677 } | |
6678 else | |
6679 _control_size(handle, width, height); | |
6647 } | 6680 } |
6648 | 6681 |
6649 /* | 6682 /* |
6650 * Returns the width of the screen. | 6683 * Returns the width of the screen. |
6651 */ | 6684 */ |
7116 * handle: Handle to the listbox to be appended to. | 7149 * handle: Handle to the listbox to be appended to. |
7117 * text: Text to append into listbox. | 7150 * text: Text to append into listbox. |
7118 */ | 7151 */ |
7119 void API dw_listbox_append(HWND handle, char *text) | 7152 void API dw_listbox_append(HWND handle, char *text) |
7120 { | 7153 { |
7121 char tmpbuf[100]; | 7154 char tmpbuf[100] = {0}; |
7122 | 7155 |
7123 GetClassName(handle, tmpbuf, 99); | 7156 GetClassName(handle, tmpbuf, 99); |
7124 | 7157 |
7125 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7158 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7126 SendMessage(handle, | 7159 SendMessage(handle, |
7139 * text: Text strings to append into listbox. | 7172 * text: Text strings to append into listbox. |
7140 * count: Number of text strings to append | 7173 * count: Number of text strings to append |
7141 */ | 7174 */ |
7142 void API dw_listbox_list_append(HWND handle, char **text, int count) | 7175 void API dw_listbox_list_append(HWND handle, char **text, int count) |
7143 { | 7176 { |
7144 char tmpbuf[100]; | 7177 char tmpbuf[100] = {0}; |
7145 int listbox_type; | 7178 int listbox_type; |
7146 int i; | 7179 int i; |
7147 | 7180 |
7148 GetClassName(handle, tmpbuf, 99); | 7181 GetClassName(handle, tmpbuf, 99); |
7149 | 7182 |
7163 * text: Text to append into listbox. | 7196 * text: Text to append into listbox. |
7164 * pos: 0 based position to insert text | 7197 * pos: 0 based position to insert text |
7165 */ | 7198 */ |
7166 void API dw_listbox_insert(HWND handle, char *text, int pos) | 7199 void API dw_listbox_insert(HWND handle, char *text, int pos) |
7167 { | 7200 { |
7168 char tmpbuf[100]; | 7201 char tmpbuf[100] = {0}; |
7169 | 7202 |
7170 GetClassName(handle, tmpbuf, 99); | 7203 GetClassName(handle, tmpbuf, 99); |
7171 | 7204 |
7172 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7205 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7173 SendMessage(handle, | 7206 SendMessage(handle, |
7184 * Parameters: | 7217 * Parameters: |
7185 * handle: Handle to the listbox to be cleared. | 7218 * handle: Handle to the listbox to be cleared. |
7186 */ | 7219 */ |
7187 void API dw_listbox_clear(HWND handle) | 7220 void API dw_listbox_clear(HWND handle) |
7188 { | 7221 { |
7189 char tmpbuf[100]; | 7222 char tmpbuf[100] = {0}; |
7190 | 7223 |
7191 GetClassName(handle, tmpbuf, 99); | 7224 GetClassName(handle, tmpbuf, 99); |
7192 | 7225 |
7193 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7226 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7194 { | 7227 { |
7215 * index: Index into the list to be queried. | 7248 * index: Index into the list to be queried. |
7216 * buffer: Buffer where text will be copied. | 7249 * buffer: Buffer where text will be copied. |
7217 */ | 7250 */ |
7218 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | 7251 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
7219 { | 7252 { |
7220 char tmpbuf[100]; | 7253 char tmpbuf[100] = {0}; |
7221 | 7254 |
7222 GetClassName(handle, tmpbuf, 99); | 7255 GetClassName(handle, tmpbuf, 99); |
7223 | 7256 |
7224 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7257 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7225 { | 7258 { |
7244 * buffer: Buffer where text will be copied. | 7277 * buffer: Buffer where text will be copied. |
7245 * length: Length of the buffer (including NULL). | 7278 * length: Length of the buffer (including NULL). |
7246 */ | 7279 */ |
7247 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | 7280 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) |
7248 { | 7281 { |
7249 char tmpbuf[100]; | 7282 char tmpbuf[100] = {0}; |
7250 int len; | 7283 int len; |
7251 | 7284 |
7252 if(!buffer || !length) | 7285 if(!buffer || !length) |
7253 return; | 7286 return; |
7254 | 7287 |
7279 * Parameters: | 7312 * Parameters: |
7280 * handle: Handle to the listbox to be queried. | 7313 * handle: Handle to the listbox to be queried. |
7281 */ | 7314 */ |
7282 int API dw_listbox_selected(HWND handle) | 7315 int API dw_listbox_selected(HWND handle) |
7283 { | 7316 { |
7284 char tmpbuf[100]; | 7317 char tmpbuf[100] = {0}; |
7285 | 7318 |
7286 GetClassName(handle, tmpbuf, 99); | 7319 GetClassName(handle, tmpbuf, 99); |
7287 | 7320 |
7288 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7321 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7289 return (unsigned int)SendMessage(handle, | 7322 return (unsigned int)SendMessage(handle, |
7302 * where: Either the previous return or -1 to restart. | 7335 * where: Either the previous return or -1 to restart. |
7303 */ | 7336 */ |
7304 int API dw_listbox_selected_multi(HWND handle, int where) | 7337 int API dw_listbox_selected_multi(HWND handle, int where) |
7305 { | 7338 { |
7306 int *array, count, z; | 7339 int *array, count, z; |
7307 char tmpbuf[100]; | 7340 char tmpbuf[100] = {0}; |
7308 | 7341 |
7309 GetClassName(handle, tmpbuf, 99); | 7342 GetClassName(handle, tmpbuf, 99); |
7310 | 7343 |
7311 /* This doesn't work on comboboxes */ | 7344 /* This doesn't work on comboboxes */ |
7312 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7345 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7345 * index: Item index. | 7378 * index: Item index. |
7346 * state: TRUE if selected FALSE if unselected. | 7379 * state: TRUE if selected FALSE if unselected. |
7347 */ | 7380 */ |
7348 void API dw_listbox_select(HWND handle, int index, int state) | 7381 void API dw_listbox_select(HWND handle, int index, int state) |
7349 { | 7382 { |
7350 char tmpbuf[100]; | 7383 char tmpbuf[100] = {0}; |
7351 | 7384 |
7352 GetClassName(handle, tmpbuf, 99); | 7385 GetClassName(handle, tmpbuf, 99); |
7353 | 7386 |
7354 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7387 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7355 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); | 7388 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); |
7367 * handle: Handle to the listbox to be set. | 7400 * handle: Handle to the listbox to be set. |
7368 * index: Item index. | 7401 * index: Item index. |
7369 */ | 7402 */ |
7370 void API dw_listbox_delete(HWND handle, int index) | 7403 void API dw_listbox_delete(HWND handle, int index) |
7371 { | 7404 { |
7372 char tmpbuf[100]; | 7405 char tmpbuf[100] = {0}; |
7373 | 7406 |
7374 GetClassName(handle, tmpbuf, 99); | 7407 GetClassName(handle, tmpbuf, 99); |
7375 | 7408 |
7376 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7409 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7377 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); | 7410 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); |
7384 * Parameters: | 7417 * Parameters: |
7385 * handle: Handle to the listbox to be cleared. | 7418 * handle: Handle to the listbox to be cleared. |
7386 */ | 7419 */ |
7387 int API dw_listbox_count(HWND handle) | 7420 int API dw_listbox_count(HWND handle) |
7388 { | 7421 { |
7389 char tmpbuf[100]; | 7422 char tmpbuf[100] = {0}; |
7390 | 7423 |
7391 GetClassName(handle, tmpbuf, 99); | 7424 GetClassName(handle, tmpbuf, 99); |
7392 | 7425 |
7393 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7426 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7394 return (int)SendMessage(handle, | 7427 return (int)SendMessage(handle, |
7404 * handle: Handle to the listbox to be cleared. | 7437 * handle: Handle to the listbox to be cleared. |
7405 * top: Index to the top item. | 7438 * top: Index to the top item. |
7406 */ | 7439 */ |
7407 void API dw_listbox_set_top(HWND handle, int top) | 7440 void API dw_listbox_set_top(HWND handle, int top) |
7408 { | 7441 { |
7409 char tmpbuf[100]; | 7442 char tmpbuf[100] = {0}; |
7410 | 7443 |
7411 GetClassName(handle, tmpbuf, 99); | 7444 GetClassName(handle, tmpbuf, 99); |
7412 | 7445 |
7413 /* This doesn't work on comboboxes */ | 7446 /* This doesn't work on comboboxes */ |
7414 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7447 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
7830 } | 7863 } |
7831 | 7864 |
7832 /* This function unchecks all radiobuttons on a box */ | 7865 /* This function unchecks all radiobuttons on a box */ |
7833 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam) | 7866 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam) |
7834 { | 7867 { |
7835 char tmpbuf[100]; | 7868 char tmpbuf[100] = {0}; |
7836 | 7869 |
7837 GetClassName(handle, tmpbuf, 99); | 7870 GetClassName(handle, tmpbuf, 99); |
7838 | 7871 |
7839 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) | 7872 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) |
7840 { | 7873 { |