00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef WINSTL_INCL_WINSTL_WINDOW_H_FUNCTIONS
00048 #define WINSTL_INCL_WINSTL_WINDOW_H_FUNCTIONS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define WINSTL_VER_WINSTL_WINDOW_H_FUNCTIONS_MAJOR 4
00052 # define WINSTL_VER_WINSTL_WINDOW_H_FUNCTIONS_MINOR 0
00053 # define WINSTL_VER_WINSTL_WINDOW_H_FUNCTIONS_REVISION 10
00054 # define WINSTL_VER_WINSTL_WINDOW_H_FUNCTIONS_EDIT 66
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00062 # include <winstl/winstl.h>
00063 #endif
00064 #if defined(__cplusplus)
00065 #ifndef WINSTL_INCL_WINSTL_CONVERSION_HPP_WINDOWS_TYPE_CONVERSIONS
00066 # include <winstl/conversion/windows_type_conversions.hpp>
00067 #endif
00068 #endif
00069
00070
00071
00072
00073
00074 #if !defined(_WINSTL_NO_NAMESPACE) && \
00075 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00076 # if defined(_STLSOFT_NO_NAMESPACE)
00077
00078 namespace winstl
00079 {
00080 # else
00081
00082
00083 namespace stlsoft
00084 {
00085
00086 namespace winstl_project
00087 {
00088
00089 # endif
00090 #endif
00091
00092
00093
00094
00095
00096 #ifndef NOWINOFFSETS
00097
00098
00099 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00100 STLSOFT_INLINE ws_sptrint_t winstl__get_window_sptrint_(HWND h, int index)
00101 {
00102 #if defined(WINSTL_OS_IS_WIN64) || \
00103 defined(_Wp64)
00104 return STLSOFT_NS_GLOBAL(GetWindowLongPtr)(h, index);
00105 #else
00106 return STLSOFT_NS_GLOBAL(GetWindowLong)(h, index);
00107 #endif
00108 }
00109 STLSOFT_INLINE ws_sptrint_t winstl__set_window_sptrint_(HWND h, int index, ws_sptrint_t newData)
00110 {
00111 #if defined(WINSTL_OS_IS_WIN64) || \
00112 defined(_Wp64)
00113 return STLSOFT_NS_GLOBAL(SetWindowLongPtr)(h, index, newData);
00114 #else
00115 return STLSOFT_NS_GLOBAL(SetWindowLong)(h, index, newData);
00116 #endif
00117 }
00118 #endif
00119
00120
00121
00122 STLSOFT_INLINE ws_sptrint_t winstl__GetStyle(HWND h)
00123 {
00124 return winstl__get_window_sptrint_(h, GWL_STYLE);
00125 }
00126
00131 STLSOFT_INLINE ws_sptrint_t winstl__GetExStyle(HWND h)
00132 {
00133 return winstl__get_window_sptrint_(h, GWL_EXSTYLE);
00134 }
00135
00140 STLSOFT_INLINE ws_sptrint_t winstl__SetStyle(HWND h, ws_sptrint_t s)
00141 {
00142 return winstl__set_window_sptrint_(h, GWL_STYLE, s);
00143 }
00144
00149 STLSOFT_INLINE ws_sptrint_t winstl__SetExStyle(HWND h, ws_sptrint_t x)
00150 {
00151 return winstl__set_window_sptrint_(h, GWL_EXSTYLE, x);
00152 }
00153
00158 STLSOFT_INLINE ws_sptrint_t winstl__ModifyStyle(HWND h, ws_sptrint_t sRem, ws_sptrint_t sAdd)
00159 {
00160 return winstl__SetStyle(h, (winstl__GetStyle(h) & ~sRem) | sAdd);
00161 }
00162
00167 STLSOFT_INLINE ws_sptrint_t winstl__ModifyExStyle(HWND h, ws_sptrint_t sRem, ws_sptrint_t sAdd)
00168 {
00169 return winstl__SetExStyle(h, (winstl__GetExStyle(h) & ~sRem) | sAdd);
00170 }
00171
00172 #endif
00173
00174
00179 STLSOFT_INLINE ws_int_t winstl__IsWindowClassA(HWND hwnd, ws_char_a_t const* name)
00180 {
00181 ws_char_a_t szName[256];
00182
00183 WINSTL_ASSERT(NULL != hwnd);
00184 WINSTL_ASSERT(NULL != name);
00185
00186 stlsoft_static_cast(void, STLSOFT_NS_GLOBAL(GetClassNameA)(hwnd, szName, STLSOFT_NUM_ELEMENTS(szName)));
00187
00188 return 0 == STLSOFT_NS_GLOBAL(lstrcmpiA)(szName, name);
00189 }
00190
00195 STLSOFT_INLINE ws_int_t winstl__IsWindowClassW(HWND hwnd, ws_char_w_t const* name)
00196 {
00197 ws_char_w_t szName[256];
00198
00199 WINSTL_ASSERT(NULL != hwnd);
00200 WINSTL_ASSERT(NULL != name);
00201
00202 stlsoft_static_cast(void, STLSOFT_NS_GLOBAL(GetClassNameW)(hwnd, szName, STLSOFT_NUM_ELEMENTS(szName)));
00203
00204 return 0 == STLSOFT_NS_GLOBAL(lstrcmpiW)(szName, name);
00205 }
00206
00207 #ifndef NOCTLMGR
00208
00213 STLSOFT_INLINE void winstl__EnableDlgItem(HWND hwnd, int id, BOOL bEnable)
00214 {
00215 STLSOFT_NS_GLOBAL(EnableWindow)(STLSOFT_NS_GLOBAL(GetDlgItem)(hwnd, id), bEnable);
00216 }
00217
00222 STLSOFT_INLINE ws_int_t winstl__IsDlgItemEnabled(HWND hwnd, int id)
00223 {
00224 return STLSOFT_NS_GLOBAL(IsWindowEnabled)(STLSOFT_NS_GLOBAL(GetDlgItem)(hwnd, id));
00225 }
00226
00231 STLSOFT_INLINE ws_int_t winstl__GetDlgItemTextLength(HWND hwnd, int id)
00232 {
00233 return STLSOFT_NS_GLOBAL(GetWindowTextLength)(STLSOFT_NS_GLOBAL(GetDlgItem)(hwnd, id));
00234 }
00235
00236 #endif
00237
00238 #ifndef NOWINOFFSETS
00239
00244 STLSOFT_INLINE HINSTANCE winstl__GetWindowInstance(HWND hwnd)
00245 {
00246 #if defined(WINSTL_OS_IS_WIN64) || \
00247 defined(_Wp64)
00248 const int index = GWLP_HINSTANCE;
00249 #else
00250 const int index = GWL_HINSTANCE;
00251 #endif
00252
00253 return stlsoft_reinterpret_cast(HINSTANCE, winstl__get_window_sptrint_(hwnd, index));
00254 }
00255
00256 #endif
00257
00258
00259
00260
00261
00262 #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
00263 namespace winstl
00264 {
00265 #endif
00266
00267
00268
00269
00270
00271 #ifdef __cplusplus
00272
00273 # ifndef NOWINOFFSETS
00274
00279 inline ws_sptrint_t GetStyle(HWND h)
00280 {
00281 return winstl__GetStyle(h);
00282 }
00283
00288 inline ws_sptrint_t GetExStyle(HWND h)
00289 {
00290 return winstl__GetExStyle(h);
00291 }
00292
00297 inline ws_sptrint_t SetStyle(HWND h, ws_sptrint_t s)
00298 {
00299 return winstl__SetStyle(h, s);
00300 }
00301
00306 inline ws_sptrint_t SetExStyle(HWND h, ws_sptrint_t x)
00307 {
00308 return winstl__SetExStyle(h, x);
00309 }
00310
00315 inline ws_sptrint_t ModifyStyle(HWND h, ws_sptrint_t sRem, ws_sptrint_t sAdd)
00316 {
00317 return winstl__ModifyStyle(h, sRem, sAdd);
00318 }
00319
00324 inline ws_sptrint_t ModifyExStyle(HWND h, ws_sptrint_t sRem, ws_sptrint_t sAdd)
00325 {
00326 return winstl__ModifyExStyle(h, sRem, sAdd);
00327 }
00328
00329 # endif
00330
00335 inline ws_bool_t IsWindowClass(HWND hwnd, ws_char_a_t const* name)
00336 {
00337 return BOOL2bool(winstl__IsWindowClassA(hwnd, name));
00338 }
00339
00344 inline ws_bool_t IsWindowClass(HWND hwnd, ws_char_w_t const* name)
00345 {
00346 return BOOL2bool(winstl__IsWindowClassW(hwnd, name));
00347 }
00348
00349 # ifndef NOCTLMGR
00350
00355 inline void EnableDlgItem(HWND hwnd, int id, ws_bool_t bEnable)
00356 {
00357 winstl__EnableDlgItem(hwnd, id, bEnable);
00358 }
00359
00364 inline ws_bool_t IsDlgItemEnabled(HWND hwnd, int id)
00365 {
00366 return BOOL2bool(winstl__IsDlgItemEnabled(hwnd, id));
00367 }
00368
00373 inline ws_int_t GetDlgItemTextLength(HWND hwnd, int id)
00374 {
00375 return winstl__GetDlgItemTextLength(hwnd, id);
00376 }
00377
00378 # endif
00379
00380 # ifndef NOWINOFFSETS
00381
00386 #ifdef GetWindowInstance
00387 # undef GetWindowInstance
00388 #endif
00389 inline HINSTANCE GetWindowInstance(HWND hwnd)
00390 {
00391 return winstl__GetWindowInstance(hwnd);
00392 }
00393
00394 # endif
00395
00396 # ifndef NOWINMESSAGES
00397
00398 inline HICON set_window_icon(HWND hwnd, int iconType, HICON hicon)
00399 {
00400 WINSTL_ASSERT(ICON_BIG == iconType || ICON_SMALL == iconType);
00401
00402 # if defined(STLSOFT_COMPILER_IS_BORLAND) && \
00403 __BORLANDC__ < 0x0564
00404
00405 using ::SendMessage;
00406 # endif
00407
00408 # if defined(STLSOFT_COMPILER_IS_MSVC) && \
00409 defined(_Wp64) && \
00410 !defined(_WIN64)
00411 # pragma warning(push)
00412 # pragma warning(disable : 4244)
00413 # endif
00414
00415 return LRESULT2HICON(::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(iconType), HICON2LPARAM(hicon)));
00416
00417 # if defined(STLSOFT_COMPILER_IS_MSVC) && \
00418 defined(_Wp64) && \
00419 !defined(_WIN64)
00420 # pragma warning(pop)
00421 # endif
00422 }
00423
00424 inline HICON set_window_icon(HWND hwnd, int iconType, HINSTANCE hinst, LPCTSTR iconName)
00425 {
00426 return set_window_icon(hwnd, iconType, ::LoadIcon(hinst, iconName));
00427 }
00428
00429 inline HICON set_window_icon(HWND hwnd, int iconType, HINSTANCE hinst, int iconId)
00430 {
00431 return set_window_icon(hwnd, iconType, ::LoadIcon(hinst, MAKEINTRESOURCE(iconId)));
00432 }
00433
00434 # endif
00435
00436
00437
00438 # ifndef NOCTLMGR
00439
00440 # if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00441 # define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1
00442 # elif defined(STLSOFT_COMPILER_IS_BORLAND)
00443
00444 # define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3
00445 # elif defined(STLSOFT_COMPILER_IS_MSVC)
00446 # if _MSC_VER > 1200
00447 # define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3
00448 # else
00449 # define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2
00450 # endif
00451 # else
00452 # define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1
00453 # endif
00454
00475 # if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1) || \
00476 defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
00477
00478 # if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
00479
00480 template <int N>
00481 inline HWND FindFirstChildById_N(HWND hwndParent, int id);
00482 # endif
00483
00484 inline HWND FindFirstChildById(HWND hwndParent, int id)
00485 # if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
00486 {
00487 return FindFirstChildById_N<1>(hwndParent, id);
00488 }
00489
00490 template <int N>
00491 inline HWND FindFirstChildById_N(HWND hwndParent, int id)
00492 # endif
00493 {
00494 if(::GetDlgCtrlID(hwndParent) == id)
00495 {
00496 return hwndParent;
00497 }
00498 else
00499 {
00500 class ChildFind
00501 {
00502 public:
00503 ss_explicit_k ChildFind(HWND hwndParent, int id)
00504 : m_hwndChild(NULL)
00505 , m_id(id)
00506 {
00507 ::EnumChildWindows(hwndParent, (WNDENUMPROC)EnumProc, reinterpret_cast<LPARAM>(this));
00508 }
00509
00510 public:
00511 operator HWND() const
00512 {
00513 return m_hwndChild;
00514 }
00515
00516 private:
00517 static BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
00518 {
00519 ChildFind &find = *reinterpret_cast<ChildFind*>(lParam);
00520
00521 return (::GetDlgCtrlID(hwnd) == find.m_id)
00522 ? (find.m_hwndChild = hwnd, false)
00523 : true;
00524 }
00525
00526 private:
00527 HWND m_hwndChild;
00528 int const m_id;
00529
00530 } find(hwndParent, id);
00531
00532 return find;
00533 }
00534 }
00535
00536 #elif defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3)
00537
00538 struct FindFirstChildById_class
00539 {
00540 class ChildFind
00541 {
00542 public:
00543 ss_explicit_k ChildFind(HWND hwndParent, int id)
00544 : m_hwndChild(NULL)
00545 , m_id(id)
00546 {
00547 ::EnumChildWindows(hwndParent, EnumProc, reinterpret_cast<LPARAM>(this));
00548 }
00549
00550 public:
00551 operator HWND() const
00552 {
00553 return m_hwndChild;
00554 }
00555
00556 private:
00557 static BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
00558 {
00559 ChildFind &find = *reinterpret_cast<ChildFind*>(lParam);
00560
00561 return (::GetDlgCtrlID(hwnd) == find.m_id)
00562 ? (find.m_hwndChild = hwnd, false)
00563 : true;
00564 }
00565
00566 private:
00567 HWND m_hwndChild;
00568 int const m_id;
00569
00570 private:
00571 ChildFind& operator =(ChildFind const&);
00572 };
00573
00574 static HWND FindFirstChildById_N(HWND hwndParent, int id)
00575 {
00576 if(::GetDlgCtrlID(hwndParent) == id)
00577 {
00578 return hwndParent;
00579 }
00580 else
00581 {
00582 ChildFind find(hwndParent, id);
00583
00584 return find;
00585 }
00586 }
00587 };
00588
00589 inline HWND FindFirstChildById(HWND hwndParent, int id)
00590 {
00591 return FindFirstChildById_class::FindFirstChildById_N(hwndParent, id);
00592 }
00593
00594 # else
00595 # error None of WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1, WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2 or WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3 defined
00596 # endif
00597
00598 # endif
00599
00600 #endif
00601
00602
00603
00604 #ifndef _WINSTL_NO_NAMESPACE
00605 # if defined(_STLSOFT_NO_NAMESPACE) || \
00606 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00607 }
00608 # else
00609 }
00610 }
00611 # endif
00612 #endif
00613
00614
00615
00616 #endif
00617
00618