Link to home
Start Free TrialLog in
Avatar of davinder101
davinder101

asked on

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



Avatar of Raj_Kau
Raj_Kau

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
Avatar of davinder101

ASKER

Hi Raj,

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

Raj

 .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;
}



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()

ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial