Commit 416d3cdb authored by chili's avatar chili
Browse files

set window title, fix FAILED

parent 9bde6218
......@@ -76,10 +76,10 @@ Window::Window( int width,int height,const char* name )
wr.right = width + wr.left;
wr.top = 100;
wr.bottom = height + wr.top;
if( FAILED( AdjustWindowRect( &wr,WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,FALSE ) ) )
if( AdjustWindowRect( &wr,WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,FALSE ) == 0 )
{
throw CHWND_LAST_EXCEPT();
};
}
// create window & get hWnd
hWnd = CreateWindow(
WindowClass::GetName(),name,
......@@ -101,6 +101,14 @@ Window::~Window()
DestroyWindow( hWnd );
}
void Window::SetTitle( const std::string& title )
{
if( SetWindowText( hWnd,title.c_str() ) == 0 )
{
throw CHWND_LAST_EXCEPT();
}
}
LRESULT CALLBACK Window::HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noexcept
{
// use create parameter passed in from CreateWindow() to store window class pointer at WinAPI side
......
......@@ -60,6 +60,7 @@ public:
~Window();
Window( const Window& ) = delete;
Window& operator=( const Window& ) = delete;
void SetTitle( const std::string& title );
private:
static LRESULT CALLBACK HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noexcept;
static LRESULT CALLBACK HandleMsgThunk( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noexcept;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment