Solved

A CDialog question.

Posted on 1998-11-24
12
268 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
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 114
Turn a spreadsheet into a vba executable. 2 96
how do i create updater to My Activex application? 3 97
Line meaning 9 88
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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