• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

How to drag a dialog box derived from DHtmlDialog ?

Hi

I have created a dialogbox which is derived from CDHtmlDialog. My dialogbox don't have titlebar.

Because it is a DHtmlDialog box it contains a web page. Web page hase an Image looks like titlebar (Which is not a titlebar).

Now what I want is I want to drag my dialog by pressing this image (titlebar).

I tried to Override OnLButtonDown but control not going there. Why I don't know?

Aftre tring this I am able to drag my dialog by pressing on border only. Which is not my requirement.

UINT CDhtmldemoDlg::OnNcHitTest(CPoint point)
{
      return  HTCAPTION ;
}

Any suggestion ????


Thanks



0
davinder101
Asked:
davinder101
  • 3
  • 2
1 Solution
 
Raj_KauCommented:
take a flage and make true when you press left button and again make false on lbutton up
also get the x y position of mouse and Set the window position by using "SetWindowPos" API

Raj
0
 
davinder101Author Commented:
Hi Raj,

Control is not going OnLButtonDown handler. Then how I'll set flag value?
0
 
Raj_KauCommented:
can you post some code

Raj
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
davinder101Author Commented:

 .CPP file my dialogbox is follows....



// DhtmldemoDlg.cpp : implementation file
//

#include "stdafx.h"
#include ".\dhtmldemodlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About
// CDhtmldemoDlg dialog

BEGIN_DHTML_EVENT_MAP(CDhtmldemoDlg)

END_DHTML_EVENT_MAP()


CDhtmldemoDlg::CDhtmldemoDlg(CWnd* pParent /*=NULL*/)
      : CDHtmlDialog(CDhtmldemoDlg::IDD, CDhtmldemoDlg::IDH, pParent)
{
      EnableModeless(true);
      m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDhtmldemoDlg::DoDataExchange(CDataExchange* pDX)
{
      CDHtmlDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CDhtmldemoDlg, CDHtmlDialog)
      ON_WM_SYSCOMMAND()
      //}}AFX_MSG_MAP
      ON_WM_CREATE()
      ON_WM_LBUTTONDOWN()
      ON_WM_NCHITTEST()
END_MESSAGE_MAP()


// CDhtmldemoDlg message handlers

int CDhtmldemoDlg::Create()
{
      return CDHtmlDialog::Create(CDhtmldemoDlg::IDD) ;
}


BOOL CDhtmldemoDlg::OnInitDialog()
{
      CDHtmlDialog::OnInitDialog();

      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE);                  // Set big icon
      SetIcon(m_hIcon, FALSE);            // Set small icon

      m_pBrowserApp->put_RegisterAsDropTarget(VARIANT_FALSE);
      return true;
}

void CDhtmldemoDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
      CRect rect;
      GetClientRect(&rect);
      PostMessage( WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM( point.x, point.y));
}


UINT CDhtmldemoDlg::OnNcHitTest(CPoint point)
{
      return  HTCAPTION ;
      
      //UINT uCode = CDialog::OnNcHitTest(point);
      //return uCode == HTCLIENT ? HTCAPTION : uCode;
}



0
 
davinder101Author Commented:
Hi,

I got solution.

BEGIN_DHTML_EVENT_MAP(CDhtmldemoDlg)    
      // handle  Button click event
      DHTML_EVENT_TAG_ALL(DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN, OnPageMouseDown )
END_DHTML_EVENT_MAP()

0
 
GranModCommented:
PAQed with points refunded (200)

GranMod
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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