
// AKAssmsView.cpp : implementation of the CAKAssmsView class
//

#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "AKAssms.h"
#endif

#include "AKAssmsDoc.h"
#include "AKAssmsView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAKAssmsView

IMPLEMENT_DYNCREATE(CAKAssmsView, CView)

// CAKAssmsView construction/destruction

CAKAssmsView::CAKAssmsView()
{
	// TODO: add construction code here

}

CAKAssmsView::~CAKAssmsView()
{
}

BOOL CAKAssmsView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

// CAKAssmsView drawing

void CAKAssmsView::OnDraw(CDC* /*pDC*/)
{
	CAKAssmsDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: add draw code for native data here
}


// CAKAssmsView printing


void CAKAssmsView::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
	AFXPrintPreview(this);
#endif
}

BOOL CAKAssmsView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CAKAssmsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CAKAssmsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CAKAssmsView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CAKAssmsView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CAKAssmsView diagnostics

#ifdef _DEBUG
void CAKAssmsView::AssertValid() const
{
	CView::AssertValid();
}

void CAKAssmsView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CAKAssmsDoc* CAKAssmsView::GetDocument() const // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAKAssmsDoc)));
	return (CAKAssmsDoc*)m_pDocument;
}
#endif //_DEBUG

///////////////////////////////////////////////////////////////////////////////
//  CAKAssmsView message handlers
BEGIN_MESSAGE_MAP(CAKAssmsView, CView)
    // External commands
    ON_MESSAGE(WM_APP_TABLE_TOP_1000_ROWS,OnExecuteSQLstmt)
    ON_MESSAGE(WM_APP_VIEW_TOP_1000_ROWS,OnExecuteSQLstmt)

    // Standard printing commands
    ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CAKAssmsView::OnFilePrintPreview)
    ON_WM_CONTEXTMENU()
    ON_WM_RBUTTONUP()
END_MESSAGE_MAP()

LRESULT
CAKAssmsView::OnExecuteSQLstmt ( WPARAM wParam, LPARAM lParam )
{
    //if ( m_wndSplitter.m_hWnd == NULL )
	  //  m_wndSplitter.Create ( this,
		//                         2, 2,       // TODO: adjust the number of rows, columns
		//                         CSize(10, 10),  // TODO: adjust the minimum pane size
		//                         0 );
    return TRUE;
}


void
CAKAssmsView::OnUpdate ( CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/)
{
    // TODO: Add your specialized code here and/or call the base class
    CAKAssmsDoc *pAssmsDoc = GetDocument ( );
    if ( pAssmsDoc == nullptr )
      return;
    if ( lHint == NULL )
      return;

    // Fetch SQL content directly from document
    //CString strSqlStmt = pAssmsDoc -> GetSQLstmt ();


}
