Solved

A CDialog question.

Posted on 1998-11-24
12
264 Views
Last Modified: 2013-11-20
Hi,
Is there any way to prevent the user from moving  a Dialog Box by holding mouse down on the title bar and dragging?

I assume the question is less than easy.

0
Comment
Question by:Thirstyplusplus
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 2

Expert Comment

by:cramer091498
Comment Utility
Create a dialog box in the resource editor, with no static or client edge, and no title bar.
When you call this resource, the dialog box will be unmovable.

Cramer

0
 
LVL 2

Expert Comment

by:jstolan
Comment Utility
If you want to have the dialog box look normal and do the same thing, you might try intercepting the WM_MOVING message and changing the passed in rectangle address to the windows baseline.  In other words, when you get the WM_MOVING message, put the rectangle back in the same place.  Warning, I've never done this, but the documentation says this should work.
0
 
LVL 2

Expert Comment

by:cyrilbdt
Comment Utility
CMyDialog::OnNcHitTest(CPoint pt)
{
  return HTNOWHERE;
}
0
 

Author Comment

by:Thirstyplusplus
Comment Utility
Cyrilbdt, that does not work. Thanks.

jstolan, I do not know how to capture WM_MOVING message directly, in a dialog. Tried overriding the "OnMoving" message map using class wizard. It seems the message is processed at
the base class function itself.

Can u please show a sample code, how to capture the WM_MOVING
message?

I am increasing the points. Help!
Regards.

   
0
 
LVL 2

Expert Comment

by:cyrilbdt
Comment Utility
I don't know what you mean with "not work". I create simple dialog based project and the prgram works! the main window wich is dialog can't be moved. send me your e-mail if you want to see example.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi! Try this:
UINT CYourtDlg::OnNcHitTest(CPoint point)
{
      //UINT uRes = CDialog::OnNcHitTest(point);
      SetWindowLong(m_hWnd, DWL_MSGRESULT, HTCLIENT);
      return HTCLIENT;
}

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:cyrilbdt
Comment Utility
UINT CEx1Dlg::OnNcHitTest(CPoint point)
{
      UINT u = CDialog::OnNcHitTest(point);
      if(u == HTCAPTION)
            u = HTNOWHERE;
      return u;
}
from WORKING example
0
 

Author Comment

by:Thirstyplusplus
Comment Utility
cyrilbdt,
I have tried the following code exactly as u said.
The Frame work never called the function 'CBaseDialog::OnNcHitTest(CPoint point)'.
 
Incidently I am using an SDI application based on CFormView, not Dialog based. The additional dialogs have this problem.

Does that make any difference?

Please see the code from my application...

UINT CBaseDialog::OnNcHitTest(CPoint point)
{
AfxMessageBox("OnNcHitTest fired"); //I never got this
UINT u = CDialog::OnNcHitTest(point);
if(u == HTCAPTION)
u = HTNOWHERE;
return u;
}
/***********************/
migel,

For the same reason as sited above, I have to reject your answer too.




0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Are you add ON_WM_NCHITTEST() to the dialog message Map?

0
 
LVL 2

Expert Comment

by:cyrilbdt
Comment Utility
by default when you invoke ClassWizard on CDialog derived class in message map there is no WM_NCHITTEST. You should goto ClassInfo tab an there to change Message Filter to Window. then back to Message Map and use Add function button to add WM_NCHITTEST member.

Hope this helps
0
 

Author Comment

by:Thirstyplusplus
Comment Utility
/**This question being reloaded only to transfer points to
   Cyrilbdt's account.**/

Cyrilbdt,

That was pure ignorance on my part. I did not go by the Class wizard. It works fine.

I have reloaded the question so that I can give the points
to u. Thanks.
 
My sincere thanks to  migel also but the points goes to cyrilbdt,
because originally he had answered the question.

I sincerely  apologize to all for I rejected a correct answer.

bye
 



0
 
LVL 2

Accepted Solution

by:
cyrilbdt earned 50 total points
Comment Utility
Thankx
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now