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

View File

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