Moving windows without visible caption 
Author Message
 Moving windows without visible caption


Quote:

>I'm trying to implement a frame window/dialog which is completely filled by
>a bitmap like a splash window BUT can be dragged over the screen like any
>other top level window.

>I have played around with a thin border window and tried to handle the mouse
>events in a suggested caption region but with no satisfactory result.

     Let's take the easy case first:  Suppose that you want the window to be
draggable by any point within it.  In other words, the user can put the
cursor anywhere within the window and drag to move the window.
     To do this, you just need to override OnNcHitTest; your handler should
look like this:

afx_msg UINT CMyWindowClass::OnNcHitTest(CPoint point)
{
    UINT nArea = CWnd::OnNcHitTest(point);
    // This assumes that your window class derives from CWnd; if it derives
    // from CDialog or some other class, you should call that class's
    // OnNcHitTest instead

    if (nArea == HTCLIENT) {
        nArea = HTCAPTION;
    }
    return nArea;

Quote:
}

     Basically, this handler will make Windows' mouse-handling logic believe
that your entire window is a gigantic caption bar; and when the user drags on
a caption bar, Windows' default handler moves the window.  So with this code,
you don't have to implement your own mouse-handling or window-moving logic at
all; Windows will take care of all of it for you, just as it normally does
when a window is dragged by its caption bar.
     If you want your window to only be draggable by some parts of its area,
your OnNcHitTest handler will need to be a bit more picky; it will need to
check that "point" value passed in (which is the coordinates of the cursor,
in screen coordinates), and see whether or not HTCAPTION should be returned.
For example, the following handler makes the window draggable, but only if
the cursor is within ten pixels of the top of the window:

afx_msg UINT CMyWindowClass::OnNcHitTest(CPoint point)
{
    UINT nArea = CWnd::OnNcHitTest(point);
    // This assumes that your window class derives from CWnd; if it derives
    // from CDialog or some other class, you should call that class's
    // OnNcHitTest instead

    if (nArea == HTCLIENT) {
        CPoint clientPoint = point;
        ScreenToClient(clientPoint);
        if (clientPoint.x < 10) {
            nArea = HTCAPTION;
        }
    }
    return nArea;

Quote:
}

--
\o\ If you're interested in books and stories with transformation themes, \o\
/o/ please have a look at <URL: http://www.*-*-*.com/ ;. Thanks!  /o/
\o\   FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT   \o\
/o/              a cmn++++$ d e++ f+++ h- i++wf p-- sm#                   /o/


Sat, 22 Dec 2001 03:00:00 GMT  
 Moving windows without visible caption
I'm trying to implement a frame window/dialog which is completely filled by
a bitmap like a splash window BUT can be dragged over the screen like any
other top level window.

I have played around with a thin border window and tried to handle the mouse
events in a suggested caption region but with no satisfactory result.

So, I need help: Can anybody send me some sample code, that...

... opens a window with WS_CAPTION style and paints a bitmap allover the
client and non-client area

OR

... opens a borderless/thin border window and handles the mouse events for
correct (non-jerky) window movement?

TIA
Wolfgang



Sun, 23 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Moving Windows Without Captions

2. Getting window handle without matching window caption text

3. Help: How to move windows with no caption?

4. Window without caption bar

5. Creating A Window Without A Caption Bar.....

6. Making a main(frame)window without a border and caption (just white)

7. How to move line without flickering(which is attached to child window)

8. how to move the line(which is attached to child window) without flickering

9. Make tooltip visible WITHOUT using mouse over

10. How to implement a Property Sheet without caption bar

11. MFC without Caption bar

12. SDI As Child without Caption but with Menu

 

 
Powered by phpBB® Forum Software