Mercurial > dwindows
comparison win/dw.c @ 371:e856f80e0520
Check for comboboxes in listbox functions, and handle missing events,
or return if invalid for comboboxes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Apr 2003 18:50:58 +0000 |
parents | e5156e7e5f19 |
children | 6b573770f446 |
comparison
equal
deleted
inserted
replaced
370:e5156e7e5f19 | 371:e856f80e0520 |
---|---|
5110 { | 5110 { |
5111 char tmpbuf[100]; | 5111 char tmpbuf[100]; |
5112 | 5112 |
5113 GetClassName(handle, tmpbuf, 99); | 5113 GetClassName(handle, tmpbuf, 99); |
5114 | 5114 |
5115 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5115 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5116 SendMessage(handle, | 5116 SendMessage(handle, |
5117 CB_ADDSTRING, | 5117 CB_ADDSTRING, |
5118 0, (LPARAM)text); | 5118 0, (LPARAM)text); |
5119 else | 5119 else |
5120 SendMessage(handle, | 5120 SendMessage(handle, |
5131 { | 5131 { |
5132 char tmpbuf[100]; | 5132 char tmpbuf[100]; |
5133 | 5133 |
5134 GetClassName(handle, tmpbuf, 99); | 5134 GetClassName(handle, tmpbuf, 99); |
5135 | 5135 |
5136 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5136 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5137 { | 5137 { |
5138 char *buf = dw_window_get_text(handle); | 5138 char *buf = dw_window_get_text(handle); |
5139 | 5139 |
5140 SendMessage(handle, | 5140 SendMessage(handle, |
5141 CB_RESETCONTENT, 0L, 0L); | 5141 CB_RESETCONTENT, 0L, 0L); |
5158 * index: Index into the list to be queried. | 5158 * index: Index into the list to be queried. |
5159 * buffer: Buffer where text will be copied. | 5159 * buffer: Buffer where text will be copied. |
5160 */ | 5160 */ |
5161 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | 5161 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
5162 { | 5162 { |
5163 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0); | 5163 char tmpbuf[100]; |
5164 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); | 5164 |
5165 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); | 5165 GetClassName(handle, tmpbuf, 99); |
5166 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0); | 5166 |
5167 SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel); | 5167 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5168 { | |
5169 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); | |
5170 SendMessage(handle, CB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); | |
5171 } | |
5172 else | |
5173 { | |
5174 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0); | |
5175 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); | |
5176 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); | |
5177 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0); | |
5178 SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel); | |
5179 } | |
5168 } | 5180 } |
5169 | 5181 |
5170 /* | 5182 /* |
5171 * Copies the given index item's text into buffer. | 5183 * Copies the given index item's text into buffer. |
5172 * Parameters: | 5184 * Parameters: |
5185 | 5197 |
5186 buffer[0] = 0; | 5198 buffer[0] = 0; |
5187 | 5199 |
5188 GetClassName(handle, tmpbuf, 99); | 5200 GetClassName(handle, tmpbuf, 99); |
5189 | 5201 |
5190 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5202 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5191 { | 5203 { |
5192 len = (int)SendMessage(handle, CB_GETLBTEXTLEN, (WPARAM)index, 0); | 5204 len = (int)SendMessage(handle, CB_GETLBTEXTLEN, (WPARAM)index, 0); |
5193 | 5205 |
5194 if(len < length && len != CB_ERR) | 5206 if(len < length && len != CB_ERR) |
5195 SendMessage(handle, | 5207 SendMessage(handle, |
5214 { | 5226 { |
5215 char tmpbuf[100]; | 5227 char tmpbuf[100]; |
5216 | 5228 |
5217 GetClassName(handle, tmpbuf, 99); | 5229 GetClassName(handle, tmpbuf, 99); |
5218 | 5230 |
5219 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5231 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5220 return (unsigned int)SendMessage(handle, | 5232 return (unsigned int)SendMessage(handle, |
5221 CB_GETCURSEL, | 5233 CB_GETCURSEL, |
5222 0, 0); | 5234 0, 0); |
5223 | 5235 |
5224 return (unsigned int)SendMessage(handle, | 5236 return (unsigned int)SendMessage(handle, |
5233 * where: Either the previous return or -1 to restart. | 5245 * where: Either the previous return or -1 to restart. |
5234 */ | 5246 */ |
5235 int API dw_listbox_selected_multi(HWND handle, int where) | 5247 int API dw_listbox_selected_multi(HWND handle, int where) |
5236 { | 5248 { |
5237 int *array, count, z; | 5249 int *array, count, z; |
5250 char tmpbuf[100]; | |
5251 | |
5252 GetClassName(handle, tmpbuf, 99); | |
5253 | |
5254 /* This doesn't work on comboboxes */ | |
5255 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | |
5256 return -1; | |
5238 | 5257 |
5239 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); | 5258 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); |
5240 if(count > 0) | 5259 if(count > 0) |
5241 { | 5260 { |
5242 array = malloc(sizeof(int)*count); | 5261 array = malloc(sizeof(int)*count); |
5273 { | 5292 { |
5274 char tmpbuf[100]; | 5293 char tmpbuf[100]; |
5275 | 5294 |
5276 GetClassName(handle, tmpbuf, 99); | 5295 GetClassName(handle, tmpbuf, 99); |
5277 | 5296 |
5278 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5297 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5279 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); | 5298 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); |
5280 else | 5299 else |
5281 { | 5300 { |
5282 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0); | 5301 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0); |
5283 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index); | 5302 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index); |
5291 * handle: Handle to the listbox to be set. | 5310 * handle: Handle to the listbox to be set. |
5292 * index: Item index. | 5311 * index: Item index. |
5293 */ | 5312 */ |
5294 void API dw_listbox_delete(HWND handle, int index) | 5313 void API dw_listbox_delete(HWND handle, int index) |
5295 { | 5314 { |
5296 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); | 5315 char tmpbuf[100]; |
5316 | |
5317 GetClassName(handle, tmpbuf, 99); | |
5318 | |
5319 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | |
5320 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); | |
5321 else | |
5322 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); | |
5297 } | 5323 } |
5298 | 5324 |
5299 /* | 5325 /* |
5300 * Returns the listbox's item count. | 5326 * Returns the listbox's item count. |
5301 * Parameters: | 5327 * Parameters: |
5305 { | 5331 { |
5306 char tmpbuf[100]; | 5332 char tmpbuf[100]; |
5307 | 5333 |
5308 GetClassName(handle, tmpbuf, 99); | 5334 GetClassName(handle, tmpbuf, 99); |
5309 | 5335 |
5310 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 5336 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
5311 return (int)SendMessage(handle, | 5337 return (int)SendMessage(handle, |
5312 CB_GETCOUNT,0L, 0L); | 5338 CB_GETCOUNT,0L, 0L); |
5313 | 5339 |
5314 return (int)SendMessage(handle, | 5340 return (int)SendMessage(handle, |
5315 LB_GETCOUNT,0L, 0L); | 5341 LB_GETCOUNT,0L, 0L); |
5321 * handle: Handle to the listbox to be cleared. | 5347 * handle: Handle to the listbox to be cleared. |
5322 * top: Index to the top item. | 5348 * top: Index to the top item. |
5323 */ | 5349 */ |
5324 void API dw_listbox_set_top(HWND handle, int top) | 5350 void API dw_listbox_set_top(HWND handle, int top) |
5325 { | 5351 { |
5352 char tmpbuf[100]; | |
5353 | |
5354 GetClassName(handle, tmpbuf, 99); | |
5355 | |
5356 /* This doesn't work on comboboxes */ | |
5357 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | |
5358 return; | |
5359 | |
5326 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); | 5360 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); |
5327 } | 5361 } |
5328 | 5362 |
5329 /* | 5363 /* |
5330 * Adds text to an MLE box and returns the current point. | 5364 * Adds text to an MLE box and returns the current point. |