📄 functions.h
字号:
*
* \ingroup group__library__windows_window
*/
inline ws_long_t ModifyExStyle(HWND h, ws_long_t sRem, ws_long_t sAdd)
{
return winstl__ModifyExStyle(h, sRem, sAdd);
}
/** Tests whether the given window has the given window class
*
* \ingroup group__library__windows_window
*/
inline ws_bool_t IsWindowClass(HWND hwnd, ws_char_a_t const* name)
{
return BOOL2bool(winstl__IsWindowClassA(hwnd, name));
}
/** Tests whether the given window has the given window class
*
* \ingroup group__library__windows_window
*/
inline ws_bool_t IsWindowClass(HWND hwnd, ws_char_w_t const* name)
{
return BOOL2bool(winstl__IsWindowClassW(hwnd, name));
}
/** Enables/disable a dialog item
*
* \ingroup group__library__windows_window
*/
inline void EnableDlgItem(HWND hwnd, int id, ws_bool_t bEnable)
{
winstl__EnableDlgItem(hwnd, id, bEnable);
}
/** Elicits the enable status of a dialog item
*
* \ingroup group__library__windows_window
*/
inline ws_bool_t IsDlgItemEnabled(HWND hwnd, int id)
{
return BOOL2bool(winstl__IsDlgItemEnabled(hwnd, id));
}
/** Gets the text length of a dialog item's window contents
*
* \ingroup group__library__windows_window
*/
inline ws_int_t GetDlgItemTextLength(HWND hwnd, int id)
{
return winstl__GetDlgItemTextLength(hwnd, id);
}
/** Gets the HINSTANCE associated with a given window
*
* \ingroup group__library__windows_window
*/
#ifdef GetWindowInstance
# undef GetWindowInstance
#endif /* GetWindowInstance */
inline HINSTANCE GetWindowInstance(HWND hwnd)
{
return winstl__GetWindowInstance(hwnd);
}
inline HICON set_window_icon(HWND hwnd, int iconType, HICON hicon)
{
WINSTL_ASSERT(ICON_BIG == iconType || ICON_SMALL == iconType);
# if defined(STLSOFT_COMPILER_IS_BORLAND) && \
__BORLANDC__ < 0x0564
/* This is needed here to prevent the Borland compiler from confused it with the winstl one! */
using ::SendMessage;
# endif /* compiler */
/*#if defined(_WIN64) || \
// defined(_Wp64)
// LRESULT l = ::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(iconType), HICON2LPARAM(hicon));
//
// HICON h = LRESULT2HICON(LRESULT(l));
//
// stlsoft_ns_qual(union_caster)<HICON, LRESULT, false>(0);
//
// return LRESULT2HICON(l);
//#else / * ? width */
return LRESULT2HICON(::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(iconType), HICON2LPARAM(hicon)));
/*#endif / * width */
}
inline HICON set_window_icon(HWND hwnd, int iconType, HINSTANCE hinst, LPCTSTR iconName)
{
return set_window_icon(hwnd, iconType, ::LoadIcon(hinst, iconName));
}
inline HICON set_window_icon(HWND hwnd, int iconType, HINSTANCE hinst, int iconId)
{
return set_window_icon(hwnd, iconType, ::LoadIcon(hinst, MAKEINTRESOURCE(iconId)));
}
/* ////////////////////////////////////////////////////////////////////// */
#if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
# define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1
#elif defined(STLSOFT_COMPILER_IS_BORLAND)
# define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3
#elif defined(STLSOFT_COMPILER_IS_MSVC)
# if _MSC_VER > 1200
# define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3
# else /* ? compiler */
# define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2
# endif /* compiler */
#else /* ? compiler */
# define WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1
#endif /* compiler */
/** \brief Finds the first descendant window with the given id
*
* \ingroup group__library__windows_window
*
* \param hwndParent The window whose children will be searched
* \param id The dialog id to search for
*
* \return Either the window handle of the first child window (or
* the parent itself) that matches the id, or NULL if no windows
* match
*
* \note Because several levels of windows may be searched, it's
* possible for more than one child window to have the given id.
* This function will return only the first one found. Which one
* is determined by the internals of the EnumChildWindows() API
* function.
*
* \note \c hwndParent is included in the search, so if it has the
* given id, it will be returned
*/
#if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1) || \
defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
#if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
/* declare the template function */
template <int N>
inline HWND FindFirstChildById_N(HWND hwndParent, int id);
# endif /* WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2 */
inline HWND FindFirstChildById(HWND hwndParent, int id)
#if defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2)
{
return FindFirstChildById_N<1>(hwndParent, id);
}
template <int N>
inline HWND FindFirstChildById_N(HWND hwndParent, int id)
# endif /* WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2 */
{
if(::GetDlgCtrlID(hwndParent) == id)
{
return hwndParent;
}
else
{
class ChildFind
{
public:
ss_explicit_k ChildFind(HWND hwndParent, int id)
: m_hwndChild(NULL)
, m_id(id)
{
::EnumChildWindows(hwndParent, (WNDENUMPROC)EnumProc, reinterpret_cast<LPARAM>(this));
}
public:
operator HWND() const
{
return m_hwndChild;
}
private:
static BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
{
ChildFind &find = *reinterpret_cast<ChildFind*>(lParam);
return (::GetDlgCtrlID(hwnd) == find.m_id)
? (find.m_hwndChild = hwnd, false)
: true;
}
private:
HWND m_hwndChild;
int const m_id;
} find(hwndParent, id);
return find;
}
}
#elif defined(WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3)
struct FindFirstChildById_class
{
class ChildFind
{
public:
ss_explicit_k ChildFind(HWND hwndParent, int id)
: m_hwndChild(NULL)
, m_id(id)
{
::EnumChildWindows(hwndParent, EnumProc, reinterpret_cast<LPARAM>(this));
}
public:
operator HWND() const
{
return m_hwndChild;
}
private:
static BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
{
ChildFind &find = *reinterpret_cast<ChildFind*>(lParam);
return (::GetDlgCtrlID(hwnd) == find.m_id)
? (find.m_hwndChild = hwnd, false)
: true;
}
private:
HWND m_hwndChild;
int const m_id;
private:
ChildFind& operator =(ChildFind const&);
};
static HWND FindFirstChildById_N(HWND hwndParent, int id)
{
if(::GetDlgCtrlID(hwndParent) == id)
{
return hwndParent;
}
else
{
ChildFind find(hwndParent, id);
return find;
}
}
};
inline HWND FindFirstChildById(HWND hwndParent, int id)
{
return FindFirstChildById_class/* <int> */::FindFirstChildById_N(hwndParent, id);
}
#else /* ? WINSTL_FINDFIRSTCHILDBYID_SLF_FORM?? */
# None of WINSTL_FINDFIRSTCHILDBYID_SLF_FORM1, WINSTL_FINDFIRSTCHILDBYID_SLF_FORM2 or WINSTL_FINDFIRSTCHILDBYID_SLF_FORM3 defined
#endif /* WINSTL_FINDFIRSTCHILDBYID_SLF_FORM?? */
#endif /* __cplusplus */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} /* namespace winstl */
# else
} /* namespace winstl_project */
} /* namespace stlsoft */
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* WINSTL_INCL_WINSTL_WINDOW_H_FUNCTIONS */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -