Solved

A CDialog question.

Posted on 1998-11-24
12
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 2

Expert Comment

by:cramer091498
ID: 1325197
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
ID: 1325198
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
ID: 1325199
CMyDialog::OnNcHitTest(CPoint pt)
{
  return HTNOWHERE;
}
0
Industry Leaders: 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!

 

Author Comment

by:Thirstyplusplus
ID: 1325200
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
ID: 1325201
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
ID: 1325202
Hi! Try this:
UINT CYourtDlg::OnNcHitTest(CPoint point)
{
      //UINT uRes = CDialog::OnNcHitTest(point);
      SetWindowLong(m_hWnd, DWL_MSGRESULT, HTCLIENT);
      return HTCLIENT;
}

0
 
LVL 2

Expert Comment

by:cyrilbdt
ID: 1325203
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
ID: 1325204
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
ID: 1325205
Are you add ON_WM_NCHITTEST() to the dialog message Map?

0
 
LVL 2

Expert Comment

by:cyrilbdt
ID: 1325206
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
ID: 1325207
/**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
ID: 1325208
Thankx
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 791
countEvens challenge 2 117
fizzArray  challenge 1 115
Notepad++ Question 11 28
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 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