Change the translation of the "Help" menu item to "?", so that the menu can be displa...
[reactos.git] / rosapps / smartpdf / baseutils / win_util.h
1 /* Written by Krzysztof Kowalczyk (http://blog.kowalczyk.info)
2 The author disclaims copyright to this source code. */
3 #ifndef WIN_UTIL_H_
4 #define WIN_UTIL_H_
5 #include <commctrl.h>
6
7 /* Utilities to help in common windows programming tasks */
8
9 #ifdef __cplusplus
10 extern "C"
11 {
12 #endif
13
14 /* constant to make it easier to return proper LRESULT values when handling
15 various windows messages */
16 #define WM_KILLFOCUS_HANDLED 0
17 #define WM_SETFOCUS_HANDLED 0
18 #define WM_KEYDOWN_HANDLED 0
19 #define WM_KEYUP_HANDLED 0
20 #define WM_LBUTTONDOWN_HANDLED 0
21 #define WM_LBUTTONUP_HANDLED 0
22 #define WM_PAINT_HANDLED 0
23 #define WM_DRAWITEM_HANDLED TRUE
24 #define WM_MEASUREITEM_HANDLED TRUE
25 #define WM_SIZE_HANDLED 0
26 #define LVN_ITEMACTIVATE_HANDLED 0
27 #define WM_VKEYTOITEM_HANDLED_FULLY -2
28 #define WM_VKEYTOITEM_NOT_HANDLED -1
29 #define WM_CREATE_OK 0
30 #define WM_CREATE_FAILED -1
31
32 #define WIN_COL_RED RGB(255,0,0)
33 #define WIN_COL_WHITE RGB(255,255,255)
34 #define WIN_COL_BLACK RGB(0,0,0)
35 #define WIN_COL_BLUE RGB(0,0,255)
36 #define WIN_COL_GREEN RGB(0,255,0)
37 #define WIN_COL_GRAY RGB(215,215,215)
38
39 int rect_dx(RECT *r);
40 int rect_dy(RECT *r);
41 void rect_set(RECT *r, int x, int y, int dx, int dy);
42
43 void win_set_font(HWND hwnd, HFONT font);
44
45 int win_get_text_len(HWND hwnd);
46 TCHAR * win_get_text(HWND hwnd);
47 void win_set_text(HWND hwnd, const TCHAR *txt);
48
49 void win_edit_set_selection(HWND hwnd, DWORD selStart, DWORD selEnd);
50 void win_edit_select_all(HWND hwnd);
51
52 LRESULT lv_delete_all_items(HWND hwnd);
53 LRESULT lv_set_items_count(HWND hwnd, int items_count);
54 int lv_get_items_count(HWND hwnd);
55 LRESULT lv_insert_column(HWND hwnd, int col, LVCOLUMN *lvc);
56 LRESULT lv_set_column(HWND hwnd, int col, LVCOLUMN *lvc);
57 LRESULT lv_set_column_dx(HWND hwnd, int col, int dx);
58 LRESULT lv_insert_item(HWND hwnd, int row, LVITEM *lvi);
59 LRESULT lv_insert_item_text(HWND hwnd, int row, const TCHAR *txt);
60 int lv_get_selection_pos(HWND hwnd);
61 LRESULT lb_delete_all_items(HWND hwnd);
62 #if 0 /* doesn't seem to be supported under wince */
63 LRESULT lb_set_items_count(HWND hwnd, int items_count);
64 #endif
65 LRESULT lb_insert_item_text(HWND hwnd, int row, const TCHAR *txt);
66 LRESULT lb_append_string_no_sort(HWND hwnd, const TCHAR *txt);
67 LRESULT lb_get_items_count(HWND hwnd);
68 LRESULT lb_set_selection(HWND hwnd, int item);
69 LRESULT lb_get_selection(HWND hwnd);
70
71 int font_get_dy(HWND hwnd, HFONT font);
72 int font_get_dy_from_dc(HDC hdc, HFONT font);
73
74 void screen_get_dx_dy(int *dx_out, int *dy_out);
75 int screen_get_dx(void);
76 int screen_get_dy(void);
77 int screen_get_menu_dy(void);
78 int screen_get_caption_dy(void);
79
80 #ifdef _WIN32_WCE
81 void sip_completion_disable(void);
82 void sip_completion_enable(void);
83 #endif
84
85 void launch_url(const TCHAR *url);
86
87 TCHAR * get_app_data_folder_path(BOOL f_create);
88
89 TCHAR * load_string_dup(int str_id);
90 const TCHAR *load_string(int str_id);
91
92 int regkey_set_dword(HKEY key_class, TCHAR *key_path, TCHAR *key_name, DWORD key_value);
93 int regkey_set_str(HKEY key_class, TCHAR *key_path, TCHAR *key_name, TCHAR *key_value);
94
95 void paint_round_rect_around_hwnd(HDC hdc, HWND hwnd_edit_parent, HWND hwnd_edit, COLORREF col);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #ifdef __cplusplus
102 class AppBarData {
103 public:
104 AppBarData() {
105 m_abd.cbSize = sizeof(m_abd);
106 /* default values for the case of SHAppBarMessage() failing
107 (shouldn't really happen) */
108 RECT rc = {0, 0, 0, 0};
109 m_abd.rc = rc;
110 m_abd.uEdge = ABE_TOP;
111 SHAppBarMessage(ABM_GETTASKBARPOS, &m_abd);
112 }
113 int dx() { return rect_dx(&m_abd.rc); }
114 int dy() { return rect_dy(&m_abd.rc); }
115 int x() { return m_abd.rc.left; }
116 int y() { return m_abd.rc.top; }
117 bool atTop() { return ABE_TOP == m_abd.uEdge; }
118 bool atBottom() { return ABE_BOTTOM == m_abd.uEdge; }
119 bool atLeft() { return ABE_LEFT == m_abd.uEdge; }
120 bool atRight() { return ABE_RIGHT == m_abd.uEdge; }
121 bool isHorizontal() { return atLeft() || atRight(); }
122 bool isVertical() { return atBottom() || atTop(); }
123 private:
124 APPBARDATA m_abd;
125 };
126 #endif
127
128 #endif