1
0

common.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef NULLSOFT_AUTH_LOGINBOX_COMMON_HEADER
  2. #define NULLSOFT_AUTH_LOGINBOX_COMMON_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #ifndef ARRAYSIZE
  8. #define ARRAYSIZE(blah) (sizeof(blah)/sizeof(*blah))
  9. #endif
  10. #define CSTR_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
  11. #ifndef LONGX86
  12. #ifdef _WIN64
  13. #define LONGX86 LONG_PTR
  14. #else /*_WIN64*/
  15. #define LONGX86 LONG
  16. #endif /*_WIN64*/
  17. #endif // LONGX86
  18. #ifdef __cplusplus
  19. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) ::SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  20. #else
  21. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  22. #endif // __cplusplus
  23. #define MSGRESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWLP_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
  24. #ifndef GetWindowStyle
  25. #define GetWindowStyle(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_STYLE))
  26. #endif //GetWindowStyle
  27. #ifndef GetWindowStyleEx
  28. #define GetWindowStyleEx(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_EXSTYLE))
  29. #endif //GetWindowStyleEx
  30. LPWSTR LoginBox_MallocString(size_t cchLen);
  31. void LoginBox_FreeString(LPWSTR pszString);
  32. void LoginBox_FreeStringSecure(LPWSTR pszString);
  33. LPWSTR LoginBox_ReAllocString(LPWSTR pszString, size_t cchLen);
  34. LPWSTR LoginBox_CopyString(LPCWSTR pszSource);
  35. LPSTR LoginBox_MallocAnsiString(size_t cchLen);
  36. LPSTR LoginBox_CopyAnsiString(LPCSTR pszSource);
  37. void LoginBox_FreeAnsiString(LPSTR pszString);
  38. void LoginBox_FreeAnsiStringSecure(LPSTR pszString);
  39. size_t LoginBox_GetAllocSize(void *memory);
  40. size_t LoginBox_GetStringMax(LPWSTR pszString);
  41. size_t LoginBox_GetAnsiStringMax(LPSTR pszString);
  42. HRESULT LoginBox_WideCharToMultiByte(UINT codePage, DWORD dwFlags, LPCWSTR lpWideCharStr, INT cchWideChar, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar, LPSTR *ppResult);
  43. HRESULT LoginBox_MultiByteToWideChar(UINT codePage, DWORD dwFlags, LPCSTR lpMultiByteStr, INT cbMultiByte, LPWSTR *ppResult);
  44. HRESULT LoginBox_GetWindowText(HWND hwnd, LPWSTR *ppszText, UINT *pcchText);
  45. HRESULT LoginBox_GetConfigPath(LPWSTR pszConfig, BOOL fEnsureExist);
  46. HRESULT LoginBox_EnsurePathExist(LPCWSTR pszDirectory);
  47. BOOL LoginBox_PrintWindow(HWND hwnd, HDC hdc, UINT flags);
  48. BOOL LoginBox_MessageBeep(UINT beepType);
  49. HRESULT LoginBox_IsStringEqualEx(LCID locale, BOOL ignoreCase, LPCWSTR str1, LPCWSTR str2);
  50. #define LoginBox_IsStrEq(str1, str2)\
  51. LoginBox_IsStringEqualEx(LOCALE_USER_DEFAULT, FALSE, str1, str2)
  52. #define LoginBox_IsStrEqI(str1, str2)\
  53. LoginBox_IsStringEqualEx(LOCALE_USER_DEFAULT, TRUE, str1, str2)
  54. #define LoginBox_IsStrEqInv(str1, str2)\
  55. LoginBox_IsStringEqualEx(CSTR_INVARIANT, FALSE, str1, str2)
  56. #define LoginBox_IsStrEqInvI(str1, str2)\
  57. LoginBox_IsStringEqualEx(CSTR_INVARIANT, TRUE, str1, str2)
  58. UINT LoginBox_GetCurrentTime();
  59. HRESULT LoginBox_GetCurrentLang(LPSTR *ppLang);
  60. HDWP LoginBox_LayoutButtonBar(HDWP hdwp, HWND hwnd, const INT *buttonList, UINT buttonCount, const RECT *prcClient, LONG buttonHeight, LONG buttonSpace, BOOL fRedraw, RECT *prcResult);
  61. BYTE LoginBox_GetSysFontQuality();
  62. INT LoginBox_GetAveStrWidth(HDC hdc, INT cchLen);
  63. INT LoginBox_GetAveCharWidth(HDC hdc);
  64. BOOL LoginBox_GetWindowBaseUnits(HWND hwnd, INT *pBaseUnitX, INT *pBaseUnitY);
  65. INT LoginBox_GetWindowTextHeight(HWND hwnd, INT paddingDlgUnit);
  66. BOOL LoginBox_GetWindowTextSize(HWND hwnd, INT idealWidth, INT *pWidth, INT *pHeight);
  67. BOOL LoginBox_OpenUrl(HWND hOwner, LPCWSTR pszUrl, BOOL forceExternal);
  68. #endif //NULLSOFT_AUTH_LOGINBOX_COMMON_HEADER