2 * Copyright 2003 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Martin Fuchs, 23.07.2003
29 // standard windows headers
30 #define WIN32_LEAN_AND_MEAN
31 #define WIN32_EXTRA_LEAN
40 #include <windowsx.h> // for SelectBrush(), ListBox_SetSel(), SubclassWindow(), ...
43 #include <malloc.h> // for alloca()
49 #define BTNS_BUTTON TBSTYLE_BUTTON //TODO: should be in mingw headers
50 #define BTNS_SEP TBSTYLE_SEP
57 #pragma warning(disable: 4786) // disable warnings about too long debug information symbols
60 // STL headers for strings and streams
65 #if defined(_MSC_VER) && !defined(_NO_COMUTIL)
67 // COM utility headers
69 using namespace _com_util
;
71 #endif // _MSC_VER && !_NO_COMUTIL
74 #define for if (0) {} else for
77 #define BUFFER_LEN 1024
80 struct CommonControlInit
82 CommonControlInit(DWORD flags
=ICC_LISTVIEW_CLASSES
)
84 INITCOMMONCONTROLSEX icc
= {sizeof(INITCOMMONCONTROLSEX
), flags
};
86 InitCommonControlsEx(&icc
);
95 _old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
100 SetCursor(_old_cursor
);
108 struct ClientRect
: public RECT
110 ClientRect(HWND hwnd
)
112 GetClientRect(hwnd
, this);
116 struct WindowRect
: public RECT
118 WindowRect(HWND hwnd
)
120 GetWindowRect(hwnd
, this);
127 TextColor(HDC hdc
, COLORREF color
)
128 : _hdc(hdc
), _old_color(SetTextColor(hdc
, color
)) {}
130 ~TextColor() {SetTextColor(_hdc
, _old_color
);}
139 BkMode(HDC hdc
, int bkmode
)
140 : _hdc(hdc
), _old_bkmode(SetBkMode(hdc
, bkmode
)) {}
142 ~BkMode() {SetBkMode(_hdc
, _old_bkmode
);}
146 COLORREF _old_bkmode
;
151 SelectedFont(HDC hdc
, HFONT hFont
)
152 : _hdc(hdc
), _old_hFont(SelectFont(hdc
, hFont
)) {}
154 ~SelectedFont() {SelectFont(_hdc
, _old_hFont
);}
162 struct FullScreenParameters
{
163 FullScreenParameters()
182 typedef wstring super
;
184 typedef string super
;
188 String(LPCTSTR s
) : super(s
) {}
189 String(const String
& other
) : super(other
) {}
191 String
& operator=(LPCTSTR s
) {assign(s
); return *this;}
192 operator LPCTSTR() const {return c_str();}
196 #endif // __cplusplus
205 #define LONGLONGARG TEXT("I64")
207 #define LONGLONGARG TEXT("L")
213 #define _tcsrchr wcsrchr
215 #define _tcsrchr strrchr
221 #define _stprintf wcsrintf
223 #define _stprintf sprintf
228 #define SetDlgCtrlID(hwnd, id) SetWindowLong(hwnd, GWL_ID, id)
232 extern void display_error(HWND hwnd
, DWORD error
);
234 // convert time_t to WIN32 FILETIME
235 extern BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
);
237 // search for windows of a specific classname
238 extern int find_window_class(LPCTSTR classname
);
240 // launch a program or document file
241 extern BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
);
243 extern BOOL
launch_fileA(HWND hwnd
, LPSTR cmd
, UINT nCmdShow
);
245 #define launch_fileA launch_file