Click here to Skip to main content
15,892,809 members
Articles / Desktop Programming / MFC

FiveLoaves v1.0

Rate me:
Please Sign up or sign in to vote.
3.84/5 (10 votes)
2 Jul 20028 min read 84.8K   4.4K   49  
FiveLoaves is an Internet utility designed to meet the most common needs of internet users - primarily secure connectivity
// SubProcessView.cpp : implementation file
//

#include "stdafx.h"
#include "filexfer.h"
#include "SubProcessView.h"
#include "ProcessDragDrop.h"	// UBT Async DnD utility


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

/////////////////////////////////////////////////////////////////////////////
// CSubProcessView

IMPLEMENT_DYNCREATE(CSubProcessView, CFormView)

CSubProcessView::CSubProcessView()
	: CFormView(CSubProcessView::IDD)
{
	//{{AFX_DATA_INIT(CSubProcessView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CSubProcessView::~CSubProcessView()
{
}

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


BEGIN_MESSAGE_MAP(CSubProcessView, CFormView)
	//{{AFX_MSG_MAP(CSubProcessView)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSubProcessView diagnostics

#ifdef _DEBUG
void CSubProcessView::AssertValid() const
{
	CFormView::AssertValid();
}

void CSubProcessView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSubProcessView message handlers

void CSubProcessView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();

	::MoveWindow(AfxGetMainWnd()->m_hWnd,200,200,350,175,1);

	// if i could get this instance to continue the drag operation
	// started in the first instance, it would be a simple solution
	// to the blocking OLE call ::DoDragDrop(), without using 
	// the NT 5 only IASyncOperation, or adding complex custom 
	// shell extension.  It would have the behavior of the 
	// "flying files" dialog that keeps Explorer runnin Async.

	// but even though OnLButtonDown() gets called, it don't work. 
//	PostMessage(WM_LBUTTONDOWN,0,0);


	// and none of this helped.

//	::SetActiveWindow(m_hWnd);
//	::SetForegroundWindow(m_hWnd);
//	SetFocus();
//	SetCapture();

}

void CSubProcessView::OnLButtonDown(UINT nFlags, CPoint point) 
{

	// this works, but not unless it's a real WM_LBUTTONDOWN
	// which means the DnD operation needs to be re-started from this
	// instance.

    POINT pt;
    HWND hwndAttach;
    HRESULT hr = E_FAIL;


    // Find the window under the mouse pointer.
    // This window might not be owned by the current thread, which
    // means you need to use AttachThreadInput in order for mouse
    // capture (and drag and drop) to work correctly.
    GetCursorPos(&pt);
    hwndAttach = ::WindowFromPoint(pt);
    if (!hwndAttach)
	{
        AfxMessageBox("WindowFromPoint failed");
		return;
	}

	// Article: Q139408 explains AttachThreadInput() but it didn't help.


	DropData DD;
	DD.DeSerialize(((CFileXferApp *)AfxGetApp())->m_strSerializedDropData);

	// do it on this thread
	DragThread((void *)&DD);

	// or a new one there's no difference in behavior
//	DWORD dwNotUsed;
//	CreateThread(NULL, 0, DragThread, (void *)pDDIn, 0, &dwNotUsed);

	CFormView::OnLButtonDown(nFlags, point);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Founder United Business Technologies
United States United States
http://about.me/brian.aberle
https://www.linkedin.com/in/brianaberle
http://SyrianRue.org/Brian

Comments and Discussions