00001
00002
00003
00004 #include "stdafx.h"
00005 #include "TransClient.h"
00006
00007 #include "TransClientDoc.h"
00008 #include "TransClientView.h"
00009 #include "ConnectDialog.h"
00010 #include "ProfileDialog.h"
00011 #include <vfw.h>
00012
00013 #ifdef _DEBUG
00014 #define new DEBUG_NEW
00015 #undef THIS_FILE
00016 static char THIS_FILE[] = __FILE__;
00017 #endif
00018
00019 extern HWND pPlayer;
00020 extern CClient m_client;
00021 static CDC *pDC;
00022 T_DISPLAYWINDOW vdWindow;
00023 int DrawDIB (int x, int y);
00024
00026
00027
00028 IMPLEMENT_DYNCREATE(CTransClientView, CFormView)
00029
00030 BEGIN_MESSAGE_MAP(CTransClientView, CFormView)
00031
00032 ON_WM_CREATE()
00033
00034
00035 ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
00036 ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
00037 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
00038 ON_MESSAGE(USER_MSG_DISPLAY,Display)
00039
00040 END_MESSAGE_MAP()
00041
00043
00044
00045 CTransClientView::CTransClientView()
00046 : CFormView(CTransClientView::IDD)
00047 {
00048
00049 m_Info = _T("");
00050
00051
00052 }
00053
00054 CTransClientView::~CTransClientView()
00055 {
00056
00057 }
00058
00059 void CTransClientView::DoDataExchange(CDataExchange* pDX)
00060 {
00061 CFormView::DoDataExchange(pDX);
00062
00063 DDX_Text(pDX, IDC_INFO, m_Info);
00064
00065 }
00066
00067 BOOL CTransClientView::PreCreateWindow(CREATESTRUCT& cs)
00068 {
00069
00070
00071
00072 return CFormView::PreCreateWindow(cs);
00073 }
00074
00075 void CTransClientView::OnInitialUpdate()
00076 {
00077 CFormView::OnInitialUpdate();
00078 GetParentFrame()->RecalcLayout();
00079 ResizeParentToFit();
00080
00081 }
00082
00084
00085
00086 BOOL CTransClientView::OnPreparePrinting(CPrintInfo* pInfo)
00087 {
00088
00089 return DoPreparePrinting(pInfo);
00090 }
00091
00092 void CTransClientView::OnBeginPrinting(CDC* , CPrintInfo* )
00093 {
00094
00095 }
00096
00097 void CTransClientView::OnEndPrinting(CDC* , CPrintInfo* )
00098 {
00099
00100 }
00101
00102 void CTransClientView::OnPrint(CDC* pDC, CPrintInfo* )
00103 {
00104
00105 }
00106
00108
00109
00110 #ifdef _DEBUG
00111 void CTransClientView::AssertValid() const
00112 {
00113 CFormView::AssertValid();
00114 }
00115
00116 void CTransClientView::Dump(CDumpContext& dc) const
00117 {
00118 CFormView::Dump(dc);
00119 }
00120
00121 CTransClientDoc* CTransClientView::GetDocument()
00122 {
00123 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTransClientDoc)));
00124 return (CTransClientDoc*)m_pDocument;
00125 }
00126 #endif //_DEBUG
00127
00129
00130
00131
00132
00133 void CTransClientView::Display(UINT wPara, LONG lPara)
00134 {
00135 int framenum = wPara;
00136 char str[30];
00137 CRect rect;
00138 int recW, recH, showH, showW;
00139
00140 if((framenum == 0)&&(lPara!=NULL))
00141 {
00142 init_display();
00143 }
00144
00145 if(lPara!=NULL)
00146 {
00147 GetClientRect(&rect);
00148 recW = rect.Width();
00149 recH = rect.Height();
00150 showW = rect.left + (recW - vdWindow.width)/2;
00151 showH=rect.top + (recH - vdWindow.height)/2;
00152
00153 vdWindow.bufRGB = (unsigned char*)lPara;
00154 vdWindow.hDC = ::GetDC (vdWindow.hWnd);
00155
00156 DrawDIB (showW, showH);
00157
00158 sprintf(str, "Playing Frame : %d\n",framenum);
00159
00160 ::ReleaseDC (vdWindow.hWnd, vdWindow.hDC);
00161
00162 CString temp(str);
00163 m_Info = temp;
00164
00165 UpdateData(false);
00166 }
00167 else
00168 {
00169 exit_display();
00170 OnInitialUpdate();
00171 sprintf(str, "Stop at Frame : %d\n",framenum);
00172 CString temp(str);
00173 m_Info = temp;
00174 UpdateData(false);
00175
00176 }
00177
00178 }
00179
00180 int CTransClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
00181 {
00182 if (CFormView::OnCreate(lpCreateStruct) == -1)
00183 return -1;
00184
00185
00186 pPlayer = GetSafeHwnd();
00187
00188 CSize totalSize = CSize(400*2,400*2);
00189 CSize pageSize = CSize(totalSize.cx/2, totalSize.cy/2);
00190 CSize lineSize = CSize(totalSize.cx/100, totalSize.cy/100);
00191 SetScrollSizes(MM_TEXT, totalSize, pageSize,lineSize);
00192 return 0;
00193 }
00194
00195
00196 void CTransClientView::init_display()
00197 {
00198
00199 vdWindow.hWnd = pPlayer;
00200 switch(m_client.m_profile.FrameSize)
00201 {
00202 case SF_QCIF:
00203 vdWindow.width = 176;
00204 vdWindow.height = 144;
00205 break;
00206 case SF_CIF:
00207 vdWindow.width = 352;
00208 vdWindow.height = 288;
00209 break;
00210 }
00211
00212 vdWindow.biHeader.biWidth = vdWindow.width;
00213 vdWindow.biHeader.biHeight = vdWindow.height;
00214 vdWindow.biHeader.biSize = sizeof (BITMAPINFOHEADER);
00215 vdWindow.biHeader.biCompression = BI_RGB;
00216 vdWindow.biHeader.biPlanes = 1;
00217 vdWindow.biHeader.biBitCount = 24;
00218 vdWindow.biHeader.biSizeImage = 3 * vdWindow.width * vdWindow.height;
00219
00220 vdWindow.hDC=::GetDC (vdWindow.hWnd);
00221 vdWindow.hDrawDib = DrawDibOpen();
00222
00223 DrawDibBegin(vdWindow.hDrawDib, vdWindow.hDC, vdWindow.width, vdWindow.height,
00224 &vdWindow.biHeader, vdWindow.width, vdWindow.height,0);
00225 ::ReleaseDC(vdWindow.hWnd, vdWindow.hDC);
00226 }
00227
00228 int DrawDIB (int x, int y)
00229 {
00230 int errFlag = 0;
00231
00232 errFlag |= DrawDibDraw (
00233 vdWindow.hDrawDib,
00234 vdWindow.hDC,
00235 x,
00236 y,
00237 -1,
00238 -1,
00239 &vdWindow.biHeader,
00240 vdWindow.bufRGB,
00241 0,
00242 0,
00243 vdWindow.width,
00244 vdWindow.height,
00245 DDF_SAME_DRAW
00246 );
00247 return errFlag;
00248 }
00249
00250
00251 void CTransClientView::exit_display()
00252 {
00253 vdWindow.hDC = ::GetDC (vdWindow.hWnd);
00254 DrawDibEnd (vdWindow.hDrawDib);
00255 DrawDibClose (vdWindow.hDrawDib);
00256 ::ReleaseDC (vdWindow.hWnd, vdWindow.hDC);
00257
00258 OnPaint();
00259 }