// BmpWnd.cpp : implementation file // #include "stdafx.h" #include "leadrasterview.h" #include "leadraster.h" ///#include "leadrasterdlg.h" //#include "leadrastersavetype.h" #include "resource.h" #include "NETCMD.h" #include "BmpWnd.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CBitmapWnd dialog CBitmapWnd::CBitmapWnd(CWnd* pParent /*=NULL*/) : CDialog(CBitmapWnd::IDD, pParent) { //{{AFX_DATA_INIT(CBitmapWnd) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pOwner = NULL; m_iComputer = 0; m_pltRasIO = NULL; } void CBitmapWnd::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CBitmapWnd) DDX_Control(pDX, IDC_LEADRASTERVIEW1, m_LEAD1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CBitmapWnd, CDialog) //{{AFX_MSG_MAP(CBitmapWnd) ON_WM_SIZE() ON_WM_ACTIVATE() ON_WM_DESTROY() ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CBitmapWnd message handlers void CBitmapWnd::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); if(::IsWindow(m_LEAD1.m_hWnd)) { m_LEAD1.MoveWindow(0, 0, cx, cy); } } short CBitmapWnd::SaveToFile(CString csFile, short nFormat, short nBitsPerPixel, short nQFactor, BOOL bMultiPage) { short nRet = 0; short nModify; if(m_LEAD1.GetRaster().GetBitmap() != 0) { if(bMultiPage) nModify = SAVE_APPEND; else nModify = 0; //LAH :: Correct to ILEADRasterIO ... Finished //nRet = m_LEAD1.Save(csFile, nFormat, nBitsPerPixel, nQFactor, nModify); { short iRet; if (m_pltRasIO) { iRet = m_pltRasIO->Save (m_LEAD1.GetRaster().m_lpDispatch, csFile.AllocSysString(), (RasterFileConstants)nFormat, nBitsPerPixel, (QFactorConstants)nQFactor, nModify); if (iRet) { AfxMessageBox (TEXT("Failed to Save File.")); } } } } else nRet = ERROR_NO_BITMAP; return nRet; } void CBitmapWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { m_pOwner->m_pActiveKid = this; m_pOwner->UpdateMenuStatus (); CDialog::OnActivate(nState, pWndOther, bMinimized); } BOOL CBitmapWnd::OnInitDialog() { DWORD dwStyle; CDialog::OnInitDialog(); dwStyle = GetWindowLong (this->m_hWnd, GWL_STYLE); dwStyle |= WS_CLIPCHILDREN; SetWindowLong (this->m_hWnd, GWL_STYLE, dwStyle); CoCreateInstance (CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void **)&m_pltRasIO); if (!m_pltRasIO) return FALSE; m_pltRasIO->PutEnableMethodErrors (FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CBitmapWnd::OnDestroy() { CDialog::OnDestroy(); if (m_pltRasIO) m_pltRasIO->Release (); m_pOwner->RemoveKid(this); m_pOwner->m_lKids--; m_pOwner->RedimKids(); if (m_pOwner->m_pActiveKid == this) m_pOwner->m_pActiveKid = NULL; m_pOwner->DeleteKid(this); } void CBitmapWnd::OnClose() { SendCloseWndCmd (); if (m_pltRasIO) m_pltRasIO->Release (); m_pOwner->RemoveKid(this); m_pOwner->m_lKids--; m_pOwner->RedimKids(); if (m_pOwner->m_pActiveKid == this) m_pOwner->m_pActiveKid = NULL; CDialog::OnClose(); m_pOwner->DeleteKid(this); } int CBitmapWnd::SendCloseWndCmd() { int nRet = 0; CString csOut; ILEADRasterInetPacket * Packet = NULL; TCHAR szText[]=TEXT("Window Closed Before Attach"); IDispatch *pDisp=NULL; ILEADRasterVariant * pltRasVar = NULL; HRESULT hr = ::CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant, (void **)&pltRasVar); if (FAILED(hr) || !pltRasVar) return 1; if (!m_iComputer) return 1; m_pOwner->RemoveSendList(m_iComputer); m_pOwner->m_nCommandID++; hr = CoCreateInstance(CLSID_LEADRasterInetPacket, NULL, CLSCTX_ALL, IID_ILEADRasterInetPacket, (void**)&Packet); //Packet.AttachDispatch(pDisp); Packet->PutParamCount(1); pltRasVar->Type = VALUE_ULONG; pltRasVar->DoubleValue = (unsigned long)this->m_hWnd; Packet->PutParamValue(0, pltRasVar); Packet->PutParamType(0, PARAM_TYPE_UINT32); pltRasVar->Type = VALUE_ARRAY_BYTE; for (int i = 0; i < lstrlen(szText)+1; i++) pltRasVar->PutShortItemValue(i, szText[i]); nRet = (int)m_pOwner->m_pLEADNet->InetSendCmd((InetCmdType)(INETCMD_USER_CUSTOM + 2)/*INETCMD_CREATEDWNDCLOSED*/, m_pOwner->m_nCommandID, Packet, lstrlen(szText) + 1, pltRasVar); if((nRet != 0) && (nRet != ERROR_DATA_QUEUED)) { csOut.Format(TEXT("ERROR %d calling InetSendCmd."), nRet); m_pOwner->StatusUpdate(csOut); } else m_pOwner->StatusUpdate("InetSendCmd Executed."); m_pOwner->AddSendList (); pltRasVar->Release(); return nRet; }