1 /* Written by Krzysztof Kowalczyk (http://blog.kowalczyk.info)
2 The author disclaims copyright to this source code. */
7 /* Utilities to help in common windows programming tasks */
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
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)
41 void rect_set(RECT
*r
, int x
, int y
, int dx
, int dy
);
43 void win_set_font(HWND hwnd
, HFONT font
);
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
);
49 void win_edit_set_selection(HWND hwnd
, DWORD selStart
, DWORD selEnd
);
50 void win_edit_select_all(HWND hwnd
);
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
);
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
);
71 int font_get_dy(HWND hwnd
, HFONT font
);
72 int font_get_dy_from_dc(HDC hdc
, HFONT font
);
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);
81 void sip_completion_disable(void);
82 void sip_completion_enable(void);
85 void launch_url(const TCHAR
*url
);
87 TCHAR
* get_app_data_folder_path(BOOL f_create
);
89 TCHAR
* load_string_dup(int str_id
);
90 const TCHAR
*load_string(int str_id
);
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
);
95 void paint_round_rect_around_hwnd(HDC hdc
, HWND hwnd_edit_parent
, HWND hwnd_edit
, COLORREF col
);
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};
110 m_abd
.uEdge
= ABE_TOP
;
111 SHAppBarMessage(ABM_GETTASKBARPOS
, &m_abd
);
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(); }