Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

A CDialog question.

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
Thirstyplusplus
Asked:
Thirstyplusplus
  • 5
  • 3
  • 2
  • +2
1 Solution
 
cramer091498Commented:
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
 
jstolanCommented:
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
 
cyrilbdtCommented:
CMyDialog::OnNcHitTest(CPoint pt)
{
  return HTNOWHERE;
}
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ThirstyplusplusAuthor Commented:
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
 
cyrilbdtCommented:
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
 
migelCommented:
Hi! Try this:
UINT CYourtDlg::OnNcHitTest(CPoint point)
{
      //UINT uRes = CDialog::OnNcHitTest(point);
      SetWindowLong(m_hWnd, DWL_MSGRESULT, HTCLIENT);
      return HTCLIENT;
}

0
 
cyrilbdtCommented:
UINT CEx1Dlg::OnNcHitTest(CPoint point)
{
      UINT u = CDialog::OnNcHitTest(point);
      if(u == HTCAPTION)
            u = HTNOWHERE;
      return u;
}
from WORKING example
0
 
ThirstyplusplusAuthor Commented:
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
 
migelCommented:
Are you add ON_WM_NCHITTEST() to the dialog message Map?

0
 
cyrilbdtCommented:
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
 
ThirstyplusplusAuthor Commented:
/**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
 
cyrilbdtCommented:
Thankx
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now