Solved

How to move a window w/o caption bar?

Posted on 1997-08-21
6
231 Views
Last Modified: 2013-11-20
Hi:

I have a window without decorations (border and caption bar), only the client area. As a reaction on some user action (say, double click) I want to switch into move window mode. I tried PostMessage( WM_SYSCOMMAND, SC_MOVE, 0 ) and it works: cursor changes and the frame appears, but the window is not moved when I drag it.

I have found that it is by design: even if the window has a caption bar, it can be dragged only by the caption bar (you may try it on any window).

Does anybody how to change this and allow dragging from the client area?

Regards,
Asker.
0
Comment
Question by:asker
  • 3
  • 2
6 Comments
 

Expert Comment

by:Amaresh080997
ID: 1304400
Hi Asker,
   I am sorry that I could not give you a tried working solution.But immediately all that I can think of is: Just try to override "OnMouseMove()" (WM_MOUSEMOVE message) function to get the units by which you have dragged the mouse on the window.Then add this much to the present windows coordinates and then do MoveWindow() or SetWindowPos().I am not sure if this will be satisfactory.There my be a flickering.But you can give it a try.

Bye!
Amaresh
0
 

Author Comment

by:asker
ID: 1304401
I would not want that my window be always dragged as a whole (full drag).
Frankly speaking, I understand that there may be different approaches to implement move mode manually. What I am trying to do is to use the internal Windows possibilities (move mode).
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1304402
Try maintaining a flag that says whether or not the window is in move mode. Then in that window catch the WM_NCHITTEST message. If you're in the move mode, return HT_CAPTION. If not, return the base class behavior:

  CMyWindow::OnNcHitTest(CPoint point)
  {
    if (m_InMoveMode)
      return HT_CAPTION;
    else
      return CWnd::OnNcHitTest(point);
   }

Of course, you will need to turn on m_InMoveMode when the user double clicks (WM_LBUTTONDBLCLK). Also, you will need to catch WM_NCLBUTTONDOWN to turn off m_InMoveMode.
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:asker
ID: 1304403
Hi, Thui:

I initiate the move mode by posting WM_SYSCOMMAND with SC_MOVE. The WM_NCHITTEST message is not sent to the window being moved after I've posted WM_SYSCOMMAND (I checked it with Spy++, you may also check this if you try Spy++ on any window, just select Move item from the system menu).
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 80 total points
ID: 1304404
No, don't initiate the move mode by posting WM_SYSCOMMAND. As I mentioned, you need to handle the move mode yourself.

The WM_SYSCOMMAND message is posted to enable the window to go into a modal loop where the tracking of the mouse can occur. However, a keystroke must be hit before the tracking of the mouse can be enabled. So after posting the WM_SYSCOMMAND, try posting a WM_KEYUP and WM_KEYDOWN message immediately after and see what happens.
0
 

Author Comment

by:asker
ID: 1304405
Yes, this sequence lead to the success:

      PostMessage( WM_SYSCOMMAND, SC_MOVE, 0 );
      PostMessage( WM_KEYDOWN, VK_LEFT, 0 );
      PostMessage( WM_KEYUP, VK_LEFT, 0 );
      PostMessage( WM_KEYDOWN, VK_RIGHT, 0 );
      PostMessage( WM_KEYUP, VK_RIGHT, 0 );

Thank you!

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question