⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dragdialog.cpp

📁 對網只操作的函數,很不錯
💻 CPP
字号:
// DragDialog.cpp : implementation file
//

#include "stdafx.h"
#include "MainFrm.h"
#include "DragDialog.h"
#include "resource.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDragDialog dialog


CDragDialog::CDragDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CDragDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDragDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDragDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDragDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDragDialog, CDialog)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(CDragDialog)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_NCHITTEST()
	ON_WM_CLOSE()
	ON_WM_CREATE()
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDragDialog message handlers

void CDragDialog::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_pFrame!=NULL)
	{
		if(m_pFrame->IsWindowVisible()) //如果主窗口可视,将其调之最前
		{
			m_pFrame->SetForegroundWindow();
			SetFocus();
		}
	}
	SendMessage(WM_LBUTTONUP);
	SendMessage(WM_SYSCOMMAND, 0xF012);
}

BOOL CDragDialog::Create()
{
	return CDialog::Create(CDragDialog::IDD);
}

BOOL CDragDialog::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	if((LOWORD(wParam)==IDCANCEL)||(LOWORD(wParam)==IDOK))
		return TRUE;
	else
		return CDialog::OnCommand(wParam, lParam);
}

void CDragDialog::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_pFrame!=NULL)
	{
		m_pFrame->SendMessage(WM_COMMAND,ID_VIEW_MAIN_WINDOW);
	}
	CDialog::OnLButtonDblClk(nFlags, point);
}

UINT CDragDialog::OnNcHitTest(CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	return HTCLIENT; //指定拖放位置
}

void CDragDialog::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	m_pFrame->PostMessage(WM_CLOSE);
	CWnd::OnClose();
}
int CDragDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here

	BOOL success = m_OleTarget.Register(this) ;
	if(!success)
	{
		MessageBox("创建拖放接口失败!","错误",MB_OK|MB_ICONSTOP);
		return -1;
	}
	m_OleTarget.SetParent(this);	
	

	if (!m_wndAnimate.Create(WS_CHILD | WS_VISIBLE | ACS_AUTOPLAY,
		CRect(0,0,120,120), this, AFX_IDW_TOOLBAR+10) ||
		!m_wndAnimate.Open(IDR_LINK_AVI))
	{
		TRACE0("Failed to create animation control.\n");
		return -1;      // fail to create
	}
	return 0;
}

void CDragDialog::SetFrameWnd(CMainFrame *pFrame)
{
	m_pFrame = pFrame;
}

void CDragDialog::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_pFrame!=NULL)
	{
		if(m_pFrame->IsWindowVisible())
		{
			m_pFrame->SetForegroundWindow();
			SetFocus();
		}
	}
	CDialog::OnRButtonDown(nFlags, point);
}

void CDragDialog::OnContextMenu(CWnd*, CPoint point)
{
     //本函数自动响应右击事件	// CG: This block was added by the Pop-up Menu component	{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(IDR_POPUPMENU));		CMenu* pPopup = menu.GetSubMenu(0);		ASSERT(pPopup != NULL);		//CWnd* pWndPopupOwner = this;		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			m_pFrame);	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -