Progress: define message numbers, fix message sending

This commit is contained in:
zvon 2020-02-25 10:10:40 +01:00
parent de851fc356
commit 0076059360
2 changed files with 7 additions and 8 deletions

View File

@ -100,7 +100,7 @@ void ProgressBar::print( int perc ) {
#ifndef _WIN32
static_cast< ProgressWindow * >( ptr )->setPerc( perc );
#else
PostMessage( ptr, WM_APP, 0, perc );
SendMessage( (HWND)ptr, WM_APP, PROGRESS_PERC, perc );
#endif
}
@ -108,7 +108,7 @@ void ProgressBar::print( const string &t ) {
#ifndef _WIN32
static_cast< ProgressWindow * >( ptr )->setLabel( t );
#else
PostMessage( ptr, WM_APP, 1, ( LPARAM )t.c_str() );
SendMessage( (HWND)ptr, WM_APP, PROGRESS_STRING, ( LPARAM )t.c_str() );
#endif
}
@ -116,7 +116,7 @@ ProgressBar::~ProgressBar() {
#ifndef _WIN32
static_cast< ProgressWindow * >( ptr )->hide();
#else
PostMessageW( ptr, WM_APP, 2, 0 );
SendMessage( (HWND)ptr, WM_CLOSE, 0, 0 );
#endif
}

View File

@ -10,6 +10,9 @@ using string = std::wstring;
using string = std::string;
#endif
#define PROGRESS_PERC 0x4000
#define PROGRESS_STRING 0x4001
class ProgressBar {
public:
#ifndef GUI
@ -19,11 +22,7 @@ public:
#ifndef _WIN32
ProgressBar( void *pw ) : ptr( pw ){};
#else
ProgressBasr( void *hwnd_in ) {
while ( *hwnd_in == nullptr )
sleep( 50 );
ptr = *hwnd_in;
};
ProgressBar( void *hwnd ) : ptr( hwnd ){};
#endif // _WIN32
~ProgressBar();
#endif // GUI