// UIThread.cpp : implementation file
//

#include "stdafx.h"
#include "WatkiSynchronizacja.h"
#include "WatkiSynchronizacjaDlg.h"
#include "ThreadDialog.h"
#include "UIThread.h"

extern CWatkiSynchronizacjaDlg::firma fm;    

// CUIThread

IMPLEMENT_DYNCREATE(CUIThread, CWinThread)

CUIThread::CUIThread()
{
}

CUIThread::~CUIThread()
{
}

BOOL CUIThread::InitInstance()
{
    if(fm.nazwa == "" || fm.obrot == NULL)
        AfxMessageBox(L"Nie dokonano zapisu danych");
    else
    {
        dialog = new CThreadDialog();
        dialog->Create(IDD_DIALOG1);
        dialog->ShowWindow(SW_SHOW);    
        HWND hWnd = dialog->m_hWnd;
        CString temp;

        SetDlgItemTextW(hWnd, IDC_EDIT1, fm.nazwa);
        temp.Format(L"%.2f", fm.obrot);
        SetDlgItemTextW(hWnd, IDC_EDIT2, temp);
    }

    return TRUE;
}

int CUIThread::ExitInstance()
{
    PostMessageW(dialog->m_hWnd, WM_CLOSE, NULL, NULL);
	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CUIThread, CWinThread)
END_MESSAGE_MAP()


// CUIThread message handlers
