// UserUIView.cpp : implementation of the CUserUIView 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 "UserUI.h"
#endif
#include "UserUIDoc.h"
#include "UserUIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
UserUIThread* uiThread = NULL;
// CUserUIView
IMPLEMENT_DYNCREATE(CUserUIView, CView)
BEGIN_MESSAGE_MAP(CUserUIView, CView)
// Standard printing commands
ON_COMMAND(ID_THREAD_START, &CUserUIView::StartThread)
ON_COMMAND(ID_THREAD_DIE, &CUserUIView::DieBitchThread)
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CUserUIView construction/destruction
void CUserUIView::StartThread()
{
uiThread = (UserUIThread*)AfxBeginThread(RUNTIME_CLASS(UserUIThread));
}
void CUserUIView::DieBitchThread()
{
if (uiThread)
uiThread->PostThreadMessage(42, (WPARAM)0, (LPARAM)0);
}
CUserUIView::CUserUIView()
{
// TODO: add construction code here
}
CUserUIView::~CUserUIView()
{
}
BOOL CUserUIView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CUserUIView drawing
void CUserUIView::OnDraw(CDC* /*pDC*/)
{
CUserUIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
}
// CUserUIView printing
BOOL CUserUIView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CUserUIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CUserUIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CUserUIView diagnostics
#ifdef _DEBUG
void CUserUIView::AssertValid() const
{
CView::AssertValid();
}
void CUserUIView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CUserUIDoc* CUserUIView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUserUIDoc)));
return (CUserUIDoc*)m_pDocument;
}
#endif //_DEBUG
// CUserUIView message handlers
#pragma once
// UserUIThread
class UserUIThread : public CWinThread
{
DECLARE_DYNCREATE(UserUIThread)
protected:
UserUIThread(); // protected constructor used by dynamic creation
virtual ~UserUIThread();
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
protected:
afx_msg void DieBitch(WPARAM,LPARAM);
DECLARE_MESSAGE_MAP()
};
// UserUIThread.cpp : implementation file
//
#include "stdafx.h"
#include "UserUI.h"
#include "UserUIThread.h"
// UserUIThread
IMPLEMENT_DYNCREATE(UserUIThread, CWinThread)
UserUIThread::UserUIThread()
{
}
UserUIThread::~UserUIThread()
{
}
BOOL UserUIThread::InitInstance()
{
// TODO: perform and per-thread initialization here
CWnd uiWnd;
uiWnd.CreateEx(0,
AfxRegisterWndClass(
CS_HREDRAW | CS_VREDRAW,
LoadCursor(NULL, IDC_ARROW),
(HBRUSH)(COLOR_WINDOW + 1),
LoadIcon(NULL, MAKEINTRESOURCE(IDR_MAINFRAME))
),
_T("tipa okno"),
WS_VISIBLE | WS_OVERLAPPED,
CRect(100, 100, 500, 500),
NULL,
NULL);
CWinThread::Run();
return TRUE;
}
int UserUIThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(UserUIThread, CWinThread)
ON_THREAD_MESSAGE(42, &UserUIThread::DieBitch)
END_MESSAGE_MAP()
// UserUIThread message handlers
void UserUIThread::DieBitch(WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(1);
}