mfc >> how to make a view (without a title bar) draggable?

by May Young » Thu, 04 Dec 2003 04:13:24 GMT

Hi,

I want to create a listbox (using CWnd::CreateEx()) as a child view of
the main view. But the lustbox must not have a menu bar and a title
bar. How can I make this listbox child view draggable (but not
resizable)? Please help. Thanks.

Tony



mfc >> how to make a view (without a title bar) draggable?

by CheckAbdoul » Thu, 04 Dec 2003 05:01:44 GMT


Handle OnMouseMove() at the Listbox level and send a WM_NCLBUTTONDOWN
message with wParam = HTCAPTION to the listbox itself. Something like

void CYourListBox::OnMouseMove(UINT nFlags, CPoint point)
{
SendMessage( WM_NCLBUTTONDOWN, HTCAPTION, 0 );
// CListBox::OnMouseMove(nFlags, point);
}

--
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------








mfc >> how to make a view (without a title bar) draggable?

by May Young » Thu, 04 Dec 2003 07:42:18 GMT

Hi CheckAbdoul,

Thanks for the guide. It works but has two problems:

1) If I click on an item in the listbox and drag, the listbox
won't move. It moves only if I click on an empty space and
then drag.

2) If I click on a location outside the listbox and then drag, the
listbox moves after the cursor enters the listbox. The listbox
shouldn't move unless the left mouse down location is inside
its area.

Could you kindly give me future instuction? Thanks.

Tony







how to make a view (without a title bar) draggable?

by May Young » Thu, 04 Dec 2003 08:34:41 GMT

Never mind. Thanks. I got the solution:

UINT CYourListBox::OnNcHitTest(CPoint point)
{
UINT nHitTest = CListBox::OnNcHitTest(point);
if ((nHitTest == HTCLIENT) &&
(::GetAsyncKeyState(MK_LBUTTON) < 0))
nHitTest = HTCAPTION;
return nHitTest;
}








Similar Threads

1. Title bar in Doc/View application

2. title bar isn't properly drawn with large views

Hello,
when I display a very large image with a CScrollView based class, the title 
bar sometimes is not properly redrawn when I move the view in and outside the 
screen. I get al kinds of colours (from the scrollbars and toolbar). 

Does anyone recognize this problem and maybe has some solution or trick to 
solve this? 

Thanks in advance,
Arno

3. Moving a Form without Title bar. - CSharp/C#

4. Change Windows Form Location without Title Bar

I want to create a windows application with a small topmost form. Because the 
form is so small, It does not include title bar. Is there any control, so I 
can use it to move FORM location by mouse? Thanks.

5. Move a dialog based application without the title bar

6. Windows CE 5.0 SIP Without Title Bar

Hi...

I've designed a SIP Keyboard for Windows CE that is working fine, but one of 
the requirements is that the "Title Bar" on the SIP Keyboard must be 
removed...

Can anyone please tell me whether this is at all possible... I tried 
creating the SIP window using WS_POPUP, that just makes the whole thing act 
beserk...

Thanks

-- 
Shup

7. forcing parent window's title bar to remain active - CSharp/C#

8. Title Bar Double Clicking

Double clicking the title bar to toggle a form between full screen
size and the previous size is a great feature.

Can someone please explain how to programmatically double click the
title bar?

The form I am working with does not show any of the sizing, minimize,
or close buttons in the title bar. This clean appearance is preferred
for this specific application ... so hopefully the solution is
specific to the title bar only and not the sizing button. If you can
programmatically call the functionality of the sizing button without
it being shown ... that may be a good approach?

Hopefully the above can be done within C# without usage of MFC. If MFC
is required ... any favorite texts for teaching that topic would be
appreciated greatly.

More specifically, I want to only programmatically double click the
title bar if the form is currently sized to full screen; however, I am
hopeful that I can implement the screen size testing once I learn how
to programmatically double click the title bar.

Thank you in advance.

I have Googled for some clues on how to perform the above. If you can
easily find this information through a search procedure ... please
also explain your search methodology. That will be hugely helpful too!

Have a great day. :)

-- Tom