1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#pragma once
#include <iContext.h>
#include "logger.h"
CString formatErrorMessage( HRESULT hr );
void reportFatalError( const char* what, HRESULT hr );
#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
HRESULT implParse( const CString& s, Whisper::eModelImplementation& rdi );
LPCTSTR implString( Whisper::eModelImplementation i );
void implPopulateCombobox( CComboBox& cb, Whisper::eModelImplementation impl );
Whisper::eModelImplementation implGetValue( CComboBox& cb );
__interface iThreadPoolCallback
{
void __stdcall poolCallback() noexcept;
};
class ThreadPoolWork
{
PTP_WORK work = nullptr;
static void __stdcall callback( PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work );
public:
~ThreadPoolWork();
HRESULT create( iThreadPoolCallback* cb );
HRESULT post();
};
void makeUtf16( CString& rdi, const char* utf8 );
void makeUtf8( CStringA& rdi, const CString& utf16 );
bool getOpenFileName( HWND owner, LPCTSTR title, LPCTSTR filter, CString& path );
bool getSaveFileName( HWND owner, LPCTSTR title, LPCTSTR filter, CString& path, DWORD* filterIndex = nullptr );
#define ON_BUTTON_CLICK( id, func ) \
if( uMsg == WM_COMMAND && \
id == LOWORD( wParam ) ) \
{ \
bHandled = TRUE; \
func(); \
lResult = 0; \
return TRUE; \
}
void reportError( HWND owner, LPCTSTR text, LPCTSTR title, HRESULT hr = S_FALSE );
inline const wchar_t* cstr( const CString& s ) { return s; }
inline const char* cstr( const CStringA& s ) { return s; }
inline HRESULT getLastHr()
{
return HRESULT_FROM_WIN32( GetLastError() );
}
HRESULT writeUtf8Bom( CAtlFile& file );
// Flip order of bytes from RGB to BGR, or vice versa
inline uint32_t flipRgb( uint32_t val )
{
val = _byteswap_ulong( val );
return val >> 8;
}
bool isInvalidTranslate( HWND owner, uint32_t lang, bool translate );
inline bool isChecked( CButton& btn )
{
return btn.GetCheck() == BST_CHECKED;
}
|