You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

732 lines
24 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/controls/functions.h
  3. *
  4. * Purpose: Various Windows control functions.
  5. *
  6. * Created: 13th November 2002
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file winstl/controls/functions.h
  40. *
  41. * \brief [C, C++] Various Windows control functions
  42. * (\ref group__library__windows_controls "Windows Controls" Library).
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_CONTROLS_H_FUNCTIONS
  45. #define WINSTL_INCL_WINSTL_CONTROLS_H_FUNCTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_CONTROLS_H_FUNCTIONS_MAJOR 4
  48. # define WINSTL_VER_WINSTL_CONTROLS_H_FUNCTIONS_MINOR 2
  49. # define WINSTL_VER_WINSTL_CONTROLS_H_FUNCTIONS_REVISION 3
  50. # define WINSTL_VER_WINSTL_CONTROLS_H_FUNCTIONS_EDIT 51
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  56. # include <winstl/winstl.h>
  57. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  58. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS
  59. # include <winstl/window/message_functions.h>
  60. #endif /* !WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS */
  61. #ifdef __cplusplus
  62. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
  63. # include <stlsoft/shims/access/string.hpp>
  64. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
  65. #endif /* __cplusplus */
  66. /* /////////////////////////////////////////////////////////////////////////
  67. * Namespace
  68. */
  69. #if !defined(_WINSTL_NO_NAMESPACE) && \
  70. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  71. # if defined(_STLSOFT_NO_NAMESPACE)
  72. /* There is no stlsoft namespace, so must define ::winstl */
  73. namespace winstl
  74. {
  75. # else
  76. /* Define stlsoft::winstl_project */
  77. namespace stlsoft
  78. {
  79. namespace winstl_project
  80. {
  81. # endif /* _STLSOFT_NO_NAMESPACE */
  82. #endif /* !_WINSTL_NO_NAMESPACE */
  83. /* /////////////////////////////////////////////////////////////////////////
  84. * C functions
  85. */
  86. /** \brief Adds an ANSI string to a combo-box
  87. *
  88. * \ingroup group__library__windows_controls
  89. */
  90. STLSOFT_INLINE ws_int_t winstl__combobox_addstring_a(HWND hwnd, ws_char_a_t const* s)
  91. {
  92. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, CB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  93. }
  94. /** \brief Adds a Unicode string to a combo-box
  95. *
  96. * \ingroup group__library__windows_controls
  97. */
  98. STLSOFT_INLINE ws_int_t winstl__combobox_addstring_w(HWND hwnd, ws_char_w_t const* s)
  99. {
  100. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, CB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  101. }
  102. /** \brief Adds a string (in the ambient char-encoding) to a combo-box
  103. *
  104. * \ingroup group__library__windows_controls
  105. */
  106. STLSOFT_INLINE ws_int_t winstl__combobox_addstring(HWND hwnd, LPCTSTR s)
  107. {
  108. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, CB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  109. }
  110. /** \brief Inserts an ANSI string into a combo-box at the given index
  111. *
  112. * \ingroup group__library__windows_controls
  113. */
  114. STLSOFT_INLINE ws_int_t winstl__combobox_insertstring_a(HWND hwnd, ws_char_a_t const* s, int index)
  115. {
  116. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, CB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  117. }
  118. /** \brief Inserts a Unicode string into a combo-box at the given index
  119. *
  120. * \ingroup group__library__windows_controls
  121. */
  122. STLSOFT_INLINE ws_int_t winstl__combobox_insertstring_w(HWND hwnd, ws_char_w_t const* s, int index)
  123. {
  124. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, CB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  125. }
  126. /** \brief Inserts a string (in the ambient char-encoding) into a combo-box at the given index
  127. *
  128. * \ingroup group__library__windows_controls
  129. */
  130. STLSOFT_INLINE ws_int_t winstl__combobox_insertstring(HWND hwnd, LPCTSTR s, int index)
  131. {
  132. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, CB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  133. }
  134. /** \brief Gets the text length of an item in a combo-box
  135. *
  136. * \ingroup group__library__windows_controls
  137. */
  138. STLSOFT_INLINE ws_int_t winstl__combobox_gettextlen(HWND hwnd, ws_int_t index)
  139. {
  140. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, CB_GETLBTEXTLEN, stlsoft_static_cast(WPARAM, index), 0L));
  141. }
  142. /** \brief Gets the text (in ANSI encoding) of an item in a combo-box
  143. *
  144. * \ingroup group__library__windows_controls
  145. */
  146. STLSOFT_INLINE ws_int_t winstl__combobox_gettext_a(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  147. {
  148. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, CB_GETLBTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  149. }
  150. /** \brief Gets the text (in Unicode encoding) of an item in a combo-box
  151. *
  152. * \ingroup group__library__windows_controls
  153. */
  154. STLSOFT_INLINE ws_int_t winstl__combobox_gettext_w(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  155. {
  156. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, CB_GETLBTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  157. }
  158. /** \brief Gets the text (in the ambient char-encoding) of an item in a combo-box
  159. *
  160. * \ingroup group__library__windows_controls
  161. */
  162. STLSOFT_INLINE ws_int_t winstl__combobox_gettext(HWND hwnd, ws_int_t index, LPCSTR s)
  163. {
  164. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, CB_GETLBTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  165. }
  166. /** \brief Gets the data value associated with an item in a combo-box
  167. *
  168. * \ingroup group__library__windows_controls
  169. */
  170. STLSOFT_INLINE ws_dword_t winstl__combobox_getitemdata(HWND hwnd, ws_int_t index)
  171. {
  172. return stlsoft_static_cast(ws_dword_t, winstl__SendMessage(hwnd, CB_GETITEMDATA, stlsoft_static_cast(WPARAM, index), 0L));
  173. }
  174. /** \brief Gets the number of items in a combo-box
  175. *
  176. * \ingroup group__library__windows_controls
  177. */
  178. STLSOFT_INLINE ws_int_t winstl__combobox_getcount(HWND hwnd)
  179. {
  180. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, CB_GETCOUNT, 0, 0L));
  181. }
  182. /* LISTBOX functions
  183. */
  184. /** \brief Adds an ANSI string to a list-box
  185. *
  186. * \ingroup group__library__windows_controls
  187. */
  188. STLSOFT_INLINE ws_int_t winstl__listbox_addstring_a(HWND hwnd, ws_char_a_t const* s)
  189. {
  190. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, LB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  191. }
  192. /** \brief Adds a Unicode string to a list-box
  193. *
  194. * \ingroup group__library__windows_controls
  195. */
  196. STLSOFT_INLINE ws_int_t winstl__listbox_addstring_w(HWND hwnd, ws_char_w_t const* s)
  197. {
  198. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, LB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  199. }
  200. /** \brief Adds a string (in the ambient char-encoding) to a list-box
  201. *
  202. * \ingroup group__library__windows_controls
  203. */
  204. STLSOFT_INLINE ws_int_t winstl__listbox_addstring(HWND hwnd, LPCTSTR s)
  205. {
  206. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, LB_ADDSTRING, 0, stlsoft_reinterpret_cast(LPARAM, s)));
  207. }
  208. /** \brief Inserts an ANSI string into a list-box at the given index
  209. *
  210. * \ingroup group__library__windows_controls
  211. */
  212. STLSOFT_INLINE ws_int_t winstl__listbox_insertstring_a(HWND hwnd, ws_char_a_t const* s, int index)
  213. {
  214. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, LB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  215. }
  216. /** \brief Inserts a Unicode string into a list-box at the given index
  217. *
  218. * \ingroup group__library__windows_controls
  219. */
  220. STLSOFT_INLINE ws_int_t winstl__listbox_insertstring_w(HWND hwnd, ws_char_w_t const* s, int index)
  221. {
  222. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, LB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  223. }
  224. /** \brief Inserts a string (in the ambient char-encoding) into a list-box at the given index
  225. *
  226. * \ingroup group__library__windows_controls
  227. */
  228. STLSOFT_INLINE ws_int_t winstl__listbox_insertstring(HWND hwnd, LPCTSTR s, int index)
  229. {
  230. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, LB_INSERTSTRING, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  231. }
  232. /** \brief Gets the text length of an item in a list-box
  233. *
  234. * \ingroup group__library__windows_controls
  235. */
  236. STLSOFT_INLINE ws_int_t winstl__listbox_gettextlen(HWND hwnd, ws_int_t index)
  237. {
  238. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, LB_GETTEXTLEN, stlsoft_static_cast(WPARAM, index), 0L));
  239. }
  240. /** \brief Gets the text (in ANSI encoding) of an item in a list-box
  241. *
  242. * \ingroup group__library__windows_controls
  243. */
  244. STLSOFT_INLINE ws_int_t winstl__listbox_gettext_a(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  245. {
  246. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, LB_GETTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  247. }
  248. /** \brief Gets the text (in Unicode encoding) of an item in a list-box
  249. *
  250. * \ingroup group__library__windows_controls
  251. */
  252. STLSOFT_INLINE ws_int_t winstl__listbox_gettext_w(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  253. {
  254. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, LB_GETTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  255. }
  256. /** \brief Gets the text (in the ambient char-encoding) of an item in a list-box
  257. *
  258. * \ingroup group__library__windows_controls
  259. */
  260. STLSOFT_INLINE ws_int_t winstl__listbox_gettext(HWND hwnd, ws_int_t index, LPCSTR s)
  261. {
  262. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, LB_GETTEXT, stlsoft_static_cast(WPARAM, index), stlsoft_reinterpret_cast(LPARAM, s)));
  263. }
  264. /** \brief Gets the data value associated with an item in a list-box
  265. *
  266. * \ingroup group__library__windows_controls
  267. */
  268. STLSOFT_INLINE ws_dword_t winstl__listbox_getitemdata(HWND hwnd, ws_int_t index)
  269. {
  270. return stlsoft_static_cast(ws_dword_t, winstl__SendMessage(hwnd, LB_GETITEMDATA, stlsoft_static_cast(WPARAM, index), 0L));
  271. }
  272. /** \brief Gets the number of items in a list-box
  273. *
  274. * \ingroup group__library__windows_controls
  275. */
  276. STLSOFT_INLINE ws_int_t winstl__listbox_getcount(HWND hwnd)
  277. {
  278. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, LB_GETCOUNT, 0, 0L));
  279. }
  280. /** \brief Gets the number of lines in an edit-box
  281. *
  282. * \ingroup group__library__windows_controls
  283. */
  284. STLSOFT_INLINE ws_int_t winstl__edit_getcount(HWND hwnd)
  285. {
  286. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, EM_GETLINECOUNT, 0, 0L));
  287. }
  288. /** \brief Gets the length of the line in which the given character resides.
  289. *
  290. * \ingroup group__library__windows_controls
  291. */
  292. STLSOFT_INLINE ws_int_t winstl__edit_linelength(HWND hwnd, ws_int_t charIndex)
  293. {
  294. return stlsoft_static_cast(ws_int_t, winstl__SendMessage(hwnd, EM_LINELENGTH, stlsoft_static_cast(WPARAM, charIndex), 0L));
  295. }
  296. /** \brief Gets a copy of the text of the given line.
  297. *
  298. * \ingroup group__library__windows_controls
  299. */
  300. STLSOFT_INLINE ws_int_t winstl__edit_getline_a(HWND hwnd, ws_int_t lineIndex, ws_char_a_t *buffer, ws_size_t cchBuffer)
  301. {
  302. WINSTL_ASSERT(NULL != buffer);
  303. *stlsoft_reinterpret_cast(int*, buffer) = stlsoft_static_cast(int, cchBuffer);
  304. return stlsoft_static_cast(ws_int_t, winstl__SendMessageA(hwnd, EM_GETLINE, stlsoft_static_cast(WPARAM, lineIndex), stlsoft_reinterpret_cast(LPARAM, buffer)));
  305. }
  306. /** \brief Gets a copy of the text of the given line.
  307. *
  308. * \ingroup group__library__windows_controls
  309. */
  310. STLSOFT_INLINE ws_int_t winstl__edit_getline_w(HWND hwnd, ws_int_t lineIndex, ws_char_w_t *buffer, ws_size_t cchBuffer)
  311. {
  312. WINSTL_ASSERT(NULL != buffer);
  313. *stlsoft_reinterpret_cast(int*, buffer) = stlsoft_static_cast(int, cchBuffer);
  314. return stlsoft_static_cast(ws_int_t, winstl__SendMessageW(hwnd, EM_GETLINE, stlsoft_static_cast(WPARAM, lineIndex), stlsoft_reinterpret_cast(LPARAM, buffer)));
  315. }
  316. /* /////////////////////////////////////////////////////////////////////////
  317. * Namespace
  318. */
  319. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  320. namespace winstl
  321. {
  322. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  323. /* /////////////////////////////////////////////////////////////////////////
  324. * C++ functions
  325. */
  326. #ifdef __cplusplus
  327. /* COMBOBOX functions
  328. */
  329. /** \brief Adds an ANSI string to a combo-box
  330. *
  331. * \ingroup group__library__windows_controls
  332. */
  333. inline ws_int_t combobox_addstring_a(HWND hwnd, ws_char_a_t const* s)
  334. {
  335. return winstl__combobox_addstring_a(hwnd, s);
  336. }
  337. /** \brief Adds a Unicode string to a combo-box
  338. *
  339. * \ingroup group__library__windows_controls
  340. */
  341. inline ws_int_t combobox_addstring_w(HWND hwnd, ws_char_w_t const* s)
  342. {
  343. return winstl__combobox_addstring_w(hwnd, s);
  344. }
  345. /** \brief Adds a string to a combo-box
  346. *
  347. * \ingroup group__library__windows_controls
  348. */
  349. inline ws_int_t combobox_addstring(HWND hwnd, ws_char_a_t const* s)
  350. {
  351. return winstl__combobox_addstring_a(hwnd, s);
  352. }
  353. /** \brief Adds a string to a combo-box
  354. *
  355. * \ingroup group__library__windows_controls
  356. */
  357. inline ws_int_t combobox_addstring(HWND hwnd, ws_char_w_t const* s)
  358. {
  359. return winstl__combobox_addstring_w(hwnd, s);
  360. }
  361. /** \brief Adds a string to a combo-box
  362. *
  363. * \ingroup group__library__windows_controls
  364. */
  365. template <ss_typename_param_k S>
  366. inline ws_int_t combobox_addstring(HWND hwnd, S const& s)
  367. {
  368. return combobox_addstring(hwnd, stlsoft_ns_qual(c_str_ptr)(s));
  369. }
  370. /** \brief Inserts an ANSI string into a combo-box at the given index
  371. *
  372. * \ingroup group__library__windows_controls
  373. */
  374. inline ws_int_t combobox_insertstring_a(HWND hwnd, ws_char_a_t const* s, int index)
  375. {
  376. return winstl__combobox_insertstring_a(hwnd, s, index);
  377. }
  378. /** \brief Inserts a Unicode string into a combo-box at the given index
  379. *
  380. * \ingroup group__library__windows_controls
  381. */
  382. inline ws_int_t combobox_insertstring_w(HWND hwnd, ws_char_w_t const* s, int index)
  383. {
  384. return winstl__combobox_insertstring_w(hwnd, s, index);
  385. }
  386. /** \brief Inserts a string into a combo-box at the given index
  387. *
  388. * \ingroup group__library__windows_controls
  389. */
  390. inline ws_int_t combobox_insertstring(HWND hwnd, ws_char_a_t const* s, int index)
  391. {
  392. return winstl__combobox_insertstring_a(hwnd, s, index);
  393. }
  394. /** \brief Inserts a string into a combo-box at the given index
  395. *
  396. * \ingroup group__library__windows_controls
  397. */
  398. inline ws_int_t combobox_insertstring(HWND hwnd, ws_char_w_t const* s, int index)
  399. {
  400. return winstl__combobox_insertstring_w(hwnd, s, index);
  401. }
  402. /** \brief Inserts a string into a combo-box at the given index
  403. *
  404. * \ingroup group__library__windows_controls
  405. */
  406. template <ss_typename_param_k S>
  407. inline ws_int_t combobox_insertstring(HWND hwnd, S const& s, int index)
  408. {
  409. return combobox_insertstring_a(hwnd, stlsoft_ns_qual(c_str_ptr)(s), index);
  410. }
  411. /** \brief Gets the text length of an item in a combo-box
  412. *
  413. * \ingroup group__library__windows_controls
  414. */
  415. inline ws_int_t combobox_gettextlen(HWND hwnd, ws_int_t index)
  416. {
  417. return winstl__combobox_gettextlen(hwnd, index);
  418. }
  419. /** \brief Gets the text (in ANSI encoding) of an item in a combo-box
  420. *
  421. * \ingroup group__library__windows_controls
  422. */
  423. inline ws_int_t combobox_gettext_a(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  424. {
  425. return winstl__combobox_gettext_a(hwnd, index, s);
  426. }
  427. /** \brief Gets the text (in Unicode encoding) of an item in a combo-box
  428. *
  429. * \ingroup group__library__windows_controls
  430. */
  431. inline ws_int_t combobox_gettext_w(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  432. {
  433. return winstl__combobox_gettext_w(hwnd, index, s);
  434. }
  435. /** \brief Gets the text of an item in a combo-box
  436. *
  437. * \ingroup group__library__windows_controls
  438. */
  439. inline ws_int_t combobox_gettext(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  440. {
  441. return combobox_gettext_a(hwnd, index, s);
  442. }
  443. /** \brief Gets the text (in Unicode encoding) of an item in a combo-box
  444. *
  445. * \ingroup group__library__windows_controls
  446. */
  447. inline ws_int_t combobox_gettext(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  448. {
  449. return combobox_gettext_w(hwnd, index, s);
  450. }
  451. /** \brief Gets the data value associated with an item in a combo-box
  452. *
  453. * \ingroup group__library__windows_controls
  454. */
  455. inline ws_dword_t combobox_getitemdata(HWND hwnd, ws_int_t index)
  456. {
  457. return winstl__combobox_getitemdata(hwnd, index);
  458. }
  459. /** \brief Gets the number of items in a combo-box
  460. *
  461. * \ingroup group__library__windows_controls
  462. */
  463. inline ws_int_t combobox_getcount(HWND hwnd)
  464. {
  465. return winstl__combobox_getcount(hwnd);
  466. }
  467. /* LISTBOX functions
  468. */
  469. /** \brief Adds an ANSI string to a list-box
  470. *
  471. * \ingroup group__library__windows_controls
  472. */
  473. inline ws_int_t listbox_addstring_a(HWND hwnd, ws_char_a_t const* s)
  474. {
  475. return winstl__listbox_addstring_a(hwnd, s);
  476. }
  477. /** \brief Adds a Unicode string to a list-box
  478. *
  479. * \ingroup group__library__windows_controls
  480. */
  481. inline ws_int_t listbox_addstring_w(HWND hwnd, ws_char_w_t const* s)
  482. {
  483. return winstl__listbox_addstring_w(hwnd, s);
  484. }
  485. /** \brief Adds a string to a list-box
  486. *
  487. * \ingroup group__library__windows_controls
  488. */
  489. inline ws_int_t listbox_addstring(HWND hwnd, ws_char_a_t const* s)
  490. {
  491. return winstl__listbox_addstring_a(hwnd, s);
  492. }
  493. /** \brief Adds a string to a list-box
  494. *
  495. * \ingroup group__library__windows_controls
  496. */
  497. inline ws_int_t listbox_addstring(HWND hwnd, ws_char_w_t const* s)
  498. {
  499. return winstl__listbox_addstring_w(hwnd, s);
  500. }
  501. /** \brief Adds a string to a list-box
  502. *
  503. * \ingroup group__library__windows_controls
  504. */
  505. template <ss_typename_param_k S>
  506. inline ws_int_t listbox_addstring(HWND hwnd, S const& s)
  507. {
  508. return listbox_addstring(hwnd, stlsoft_ns_qual(c_str_ptr)(s));
  509. }
  510. /** \brief Inserts an ANSI string into a list-box at the given index
  511. *
  512. * \ingroup group__library__windows_controls
  513. */
  514. inline ws_int_t listbox_insertstring_a(HWND hwnd, ws_char_a_t const* s, int index)
  515. {
  516. return winstl__listbox_insertstring_a(hwnd, s, index);
  517. }
  518. /** \brief Inserts a Unicode string into a list-box at the given index
  519. *
  520. * \ingroup group__library__windows_controls
  521. */
  522. inline ws_int_t listbox_insertstring_w(HWND hwnd, ws_char_w_t const* s, int index)
  523. {
  524. return winstl__listbox_insertstring_w(hwnd, s, index);
  525. }
  526. /** \brief Inserts a string into a list-box at the given index
  527. *
  528. * \ingroup group__library__windows_controls
  529. */
  530. inline ws_int_t listbox_insertstring(HWND hwnd, ws_char_a_t const* s, int index)
  531. {
  532. return winstl__listbox_insertstring_a(hwnd, s, index);
  533. }
  534. /** \brief Inserts a string into a list-box at the given index
  535. *
  536. * \ingroup group__library__windows_controls
  537. */
  538. inline ws_int_t listbox_insertstring(HWND hwnd, ws_char_w_t const* s, int index)
  539. {
  540. return winstl__listbox_insertstring_w(hwnd, s, index);
  541. }
  542. /** \brief Inserts a string into a list-box at the given index
  543. *
  544. * \ingroup group__library__windows_controls
  545. */
  546. template <ss_typename_param_k S>
  547. inline ws_int_t listbox_insertstring(HWND hwnd, S const& s, int index)
  548. {
  549. return listbox_insertstring_a(hwnd, stlsoft_ns_qual(c_str_ptr)(s), index);
  550. }
  551. /** \brief Gets the text length of an item in a list-box
  552. *
  553. * \ingroup group__library__windows_controls
  554. */
  555. inline ws_int_t listbox_gettextlen(HWND hwnd, ws_int_t index)
  556. {
  557. return winstl__listbox_gettextlen(hwnd, index);
  558. }
  559. /** \brief Gets the text (in ANSI encoding) of an item in a list-box
  560. *
  561. * \ingroup group__library__windows_controls
  562. */
  563. inline ws_int_t listbox_gettext_a(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  564. {
  565. return winstl__listbox_gettext_a(hwnd, index, s);
  566. }
  567. /** \brief Gets the text (in Unicode encoding) of an item in a list-box
  568. *
  569. * \ingroup group__library__windows_controls
  570. */
  571. inline ws_int_t listbox_gettext_w(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  572. {
  573. return winstl__listbox_gettext_w(hwnd, index, s);
  574. }
  575. /** \brief Gets the text of an item in a list-box
  576. *
  577. * \ingroup group__library__windows_controls
  578. */
  579. inline ws_int_t listbox_gettext(HWND hwnd, ws_int_t index, ws_char_a_t *s)
  580. {
  581. return listbox_gettext_a(hwnd, index, s);
  582. }
  583. /** \brief Gets the text (in Unicode encoding) of an item in a list-box
  584. *
  585. * \ingroup group__library__windows_controls
  586. */
  587. inline ws_int_t listbox_gettext(HWND hwnd, ws_int_t index, ws_char_w_t *s)
  588. {
  589. return listbox_gettext_w(hwnd, index, s);
  590. }
  591. /** \brief Gets the data value associated with an item in a list-box
  592. *
  593. * \ingroup group__library__windows_controls
  594. */
  595. inline ws_dword_t listbox_getitemdata(HWND hwnd, ws_int_t index)
  596. {
  597. return winstl__listbox_getitemdata(hwnd, index);
  598. }
  599. /** \brief Gets the number of items in a list-box
  600. *
  601. * \ingroup group__library__windows_controls
  602. */
  603. inline ws_int_t listbox_getcount(HWND hwnd)
  604. {
  605. return winstl__listbox_getcount(hwnd);
  606. }
  607. /** \brief Gets the number of lines in an edit-box.
  608. *
  609. * \ingroup group__library__windows_controls
  610. */
  611. inline ws_int_t edit_getcount(HWND hwnd)
  612. {
  613. return winstl__edit_getcount(hwnd);
  614. }
  615. /** \brief Gets the length of the line in which the given character resides.
  616. *
  617. * \ingroup group__library__windows_controls
  618. */
  619. inline ws_int_t edit_linelength(HWND hwnd, ws_int_t charIndex)
  620. {
  621. return winstl__edit_linelength(hwnd, charIndex);
  622. }
  623. /** \brief Gets a copy of the text of the given line.
  624. *
  625. * \ingroup group__library__windows_controls
  626. */
  627. inline ws_int_t edit_getline(HWND hwnd, ws_int_t lineIndex, ws_char_a_t *buffer, ws_size_t cchBuffer)
  628. {
  629. return winstl__edit_getline_a(hwnd, lineIndex, buffer, cchBuffer);
  630. }
  631. /** \brief Gets a copy of the text of the given line.
  632. *
  633. * \ingroup group__library__windows_controls
  634. */
  635. inline ws_int_t edit_getline(HWND hwnd, ws_int_t lineIndex, ws_char_w_t *buffer, ws_size_t cchBuffer)
  636. {
  637. return winstl__edit_getline_w(hwnd, lineIndex, buffer, cchBuffer);
  638. }
  639. #endif /* __cplusplus */
  640. /* /////////////////////////////////////////////////////////////////////////
  641. * Unit-testing
  642. */
  643. #ifdef STLSOFT_UNITTEST
  644. # include "./unittest/functions_unittest_.h"
  645. #endif /* STLSOFT_UNITTEST */
  646. /* ////////////////////////////////////////////////////////////////////// */
  647. #ifndef _WINSTL_NO_NAMESPACE
  648. # if defined(_STLSOFT_NO_NAMESPACE) || \
  649. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  650. } /* namespace winstl */
  651. # else
  652. } /* namespace winstl_project */
  653. } /* namespace stlsoft */
  654. # endif /* _STLSOFT_NO_NAMESPACE */
  655. #endif /* !_WINSTL_NO_NAMESPACE */
  656. /* ////////////////////////////////////////////////////////////////////// */
  657. #endif /* WINSTL_INCL_WINSTL_CONTROLS_H_FUNCTIONS */
  658. /* ///////////////////////////// end of file //////////////////////////// */