diff options
-rw-r--r-- | src/test/w32dtst.cpp | 2 | ||||
-rw-r--r-- | src/w32dlib/window.h | 25 | ||||
-rw-r--r-- | src/window.cpp | 34 |
3 files changed, 60 insertions, 1 deletions
diff --git a/src/test/w32dtst.cpp b/src/test/w32dtst.cpp index 838c9f5..c06c5ce 100644 --- a/src/test/w32dtst.cpp +++ b/src/test/w32dtst.cpp @@ -167,6 +167,8 @@ private: std::cout << "Called OnCheck() - state " << checked << std::endl; + std::cout << "move="<< m_quit.MoveBase(this,10+(checked ? 50:0),50,150,18) << std::endl; + m_quit.Enable(checked); m_load.ReadOnly(checked); m_save.Enable(!checked); diff --git a/src/w32dlib/window.h b/src/w32dlib/window.h index 1a60c58..ebf496b 100644 --- a/src/w32dlib/window.h +++ b/src/w32dlib/window.h @@ -80,6 +80,31 @@ namespace W32DLib /// bool SetHMENU(HMENU menu); + /// \brief Sets a Window's position and size. + /// + /// \param x The X Co-ord in pixels. + /// \param y The Y Co-ord in pixels. + /// \param width The width in pixels. + /// \param height The height in pixels. + /// \param repaint Cause a repaint of the window and exposed areas. + /// \return True if the call succeeds. + /// + bool Move(int x, int y, int width, int height, + bool repaint=true); + + /// \brief Sets a Window's position and size using Dialog base units. + /// + /// \param w The dialog. + /// \param x The X Co-ord in dialog base units. + /// \param y The Y Co-ord in dialog base units. + /// \param width The width in dialog base units. + /// \param height The height in dialog base units. + /// \param repaint Cause a repaint of the window and exposed areas. + /// \return True if the call succeeds. + /// + bool MoveBase(Window *w, int x, int y, int width, int height, + bool repaint=true); + /// \brief Send a message to the window. /// /// This call will only work while the window is on display. diff --git a/src/window.cpp b/src/window.cpp index 1646d70..e64bd30 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -82,7 +82,39 @@ HMENU Window::GetHMENU() // bool Window::SetHMENU(HMENU menu) { - return SetMenu(m_wnd,menu) ? true:false; + return SetMenu(m_wnd,menu)!=0; +} + + +// ------------------------------------------------------------ +// +bool Window::Move(int x, int y, int width, int height, bool repaint) +{ + return MoveWindow(m_wnd,x,y,width,height,repaint ? TRUE:FALSE)!=0; +} + + +// ------------------------------------------------------------ +// +bool Window::MoveBase(Window *w, int x, int y, int width, int height, + bool repaint) +{ + RECT r; + + r.left=x; + r.top=y; + r.right=width; + r.bottom=height; + + if (MapDialogRect(w->m_wnd,&r)) + { + return MoveWindow(m_wnd,r.left,r.top, + r.right,r.bottom,repaint ? TRUE:FALSE)!=0; + } + else + { + return false; + } } |