// function: windows utilities // // author: Gongbing // // date: 2018-11-05 // // #pragma once #include #ifndef _INCLUDED_REF_ #define _INCLUDED_REF_ #include "../ref/ref.h" #endif #define MINI_BUF_LEN 40 namespace win_util { // parameters of result: // data: HWND value // len: unused, always be ZERO // total: unused, always be ZERO // flag: always be DATA_FLAG_FINAL // param: as same as user_data PORT_API(void) find_window(inter_module_data::set_data result, void* user_data); // find window decided by one or more parameters in following // found - to receive the result // num - array number of found // parent - the parent window, not check if NULL // cls_name - class name of the window, not check if NULL // title - title of the window, not check if NULL // proc_id - process id that the window belong, not check if ZERO // thrd_id - thread id that the window belong, not check if ZERO // win_id - the window ID, not check if ZERO // // return - number of found window PORT_API(int) find_window(HWND *found, DWORD num, HWND parent = NULL, const wchar_t* cls_name = NULL, const wchar_t* title = NULL, DWORD proc_id = 0, DWORD thrd_id = 0, DWORD win_id = 0); PORT_API(bool) bring_window_topmost(HWND hwnd, DWORD persist_milliseconds = -1); PORT_API(bool) attr_str_2_id(const wchar_t* id_str, int* id); // return 0 is none PORT_API(bool) attr_str_from_id(int attr_id, wchar_t buf[MINI_BUF_LEN]); // return NULL is none PORT_API(bool) get_attr_by_index(int index, int* attr_id, wchar_t style_str[MINI_BUF_LEN]); PORT_API(bool) style_str_2_id(const wchar_t* style_str, int* id); PORT_API(bool) style_id_2_str(int style, wchar_t buf[MINI_BUF_LEN]); PORT_API(bool) get_style_by_index(int index, int* style_id, wchar_t style_str[MINI_BUF_LEN]); // return false if index out of range PORT_API(bool) styleex_str_2_id(const wchar_t* styleex_str, int* id); PORT_API(bool) styleex_id_2_str(int style, wchar_t buf[MINI_BUF_LEN]); PORT_API(bool) get_styleex_by_index(int index, int* styleex_id, wchar_t styleex_str[MINI_BUF_LEN]); // return false if index out of range PORT_API(bool) msg_str_2_id(const wchar_t* msg_str, int* id); PORT_API(bool) msg_id_2_str(int style, wchar_t buf[MINI_BUF_LEN]); PORT_API(bool) get_msg_by_index(int index, int* msg_id, wchar_t msg_str[MINI_BUF_LEN]); // return false if index out of range // snap enum _finger_print_pos { FINGER_PRINT_POS_LT = 1, // left-top FINGER_PRINT_POS_LB, // left-bottom FINGER_PRINT_POS_RT, // right-top FINGER_PRINT_POS_RB, // right-bottom FINGER_PRINT_POS_MID, // center of horizontal and vertical }; PORT_API(HBITMAP) snap_window_by_gdi(HWND hwnd = NULL, const wchar_t* finger_print = NULL, _finger_print_pos pos = FINGER_PRINT_POS_LT); // call DeleteObject to free the returned object PORT_API(bool) save_bitmap_to_file(HBITMAP hbmp, const wchar_t* path_file, const wchar_t* img_type = L"png"); PORT_API(ATOM) register_window(const wchar_t* cls, WNDPROC proc, HINSTANCE inst, UINT icon, UINT icon_small, DWORD style = CS_HREDRAW | CS_VREDRAW, const wchar_t* cursor = /*IDC_ARROW*/MAKEINTRESOURCEW(32512)); // use the main window icon as tray icon if icon was NULL // in tray message 'tray_msg', the parameter 'lParam' is a mouse event code, e.g. WM_RBUTTONUP. more see NOTIFYICONDATAW PORT_API(bool) add_tray_icon(int tray_id, HWND main_wnd, UINT tray_msg, const wchar_t* tray_tips, HICON icon = NULL); PORT_API(bool) remove_tray_icon(int tray_id, HWND main_wnd); PORT_API(bool) set_tray_icon_tips(int tray_id, HWND main_wnd, const wchar_t* tips); PORT_API(bool) show_balloon(int tray_id, HWND main_wnd, const wchar_t* tips, const wchar_t* title, DWORD dwTimeout, HICON hIcon = NULL, DWORD dwInfoFlag = NIIF_USER); PORT_API(UINT_PTR) reg_full_screen_notify(HWND main_wnd, UINT notify_msg, bool reg = true); PORT_API(int) get_taskbar_pos(LPRECT r = NULL); // return ABE_LEFT, ABE_TOP, ABE_BOTTOM or ABE_RIGHT // data - (wchar_t*) // len - words of 'data' // total - always be 0 PORT_API(bool) error_message(int err_code, inter_module_data::set_data set_unic_str, void* param); };