| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 512 人关注过本帖
标题:各位楼主麻烦你们帮我解释个程序谢谢
只看楼主 加入收藏
danzengduoji52
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-4-22
收藏
 问题点数:0 回复次数:0 
各位楼主麻烦你们帮我解释个程序谢谢
// batchdlg.cpp : implementation file
//

#include "stdafx.h"
#include "tlzw.h"
#include "batchdlg.h"

#include "lzwtable.h"
#include "lzwcode.h"
#include "lzwfile.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBatchDlg dialog
HWND hWndDlg=NULL;
CString szFileName;
void BatchEncodedBytes(void)
{
    ::SendMessage(hWndDlg,WM_LZW_ENCODE_BYTES,0,0);
}
void BatchDecodedBytes(void)
{
    ::SendMessage(hWndDlg,WM_LZW_DECODE_BYTES,0,0);
}
LONG CBatchDlg::OnDecodeBytes(UINT uP,LONG lP)
{
    char szPercent[200];
    CClientDC dc(this);
    dc.SelectStockObject(WHITE_BRUSH);
    dc.Rectangle(m_rcDraw);
    dc.SelectStockObject(LTGRAY_BRUSH);
    CRect rcPercent=m_rcDraw;
    if(++m_iPercent>=101)
        m_iPercent=0;
    rcPercent.right=rcPercent.left+m_iPercent*3;
    dc.Rectangle(rcPercent);
    sprintf(szPercent,"%s %d%%",(LPCSTR)szFileName,m_iPercent);
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(0,0,255));
    dc.DrawText(szPercent,strlen(szPercent),m_rcDraw,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
    return 0L;
}
LONG CBatchDlg::OnEncodeBytes(UINT uP,LONG lP)
{
    if(++m_iPercent>=101)
        m_iPercent=0;
    if(m_iPercent%5!=0)
        return 0L;
    char szPercent[200];
    CClientDC dc(this);
    dc.SelectStockObject(WHITE_BRUSH);
    dc.Rectangle(m_rcDraw);
    dc.SelectStockObject(LTGRAY_BRUSH);
    CRect rcPercent=m_rcDraw;
    rcPercent.right=rcPercent.left+m_iPercent*3;
    dc.Rectangle(rcPercent);
    sprintf(szPercent,"%s %d%%",(LPCSTR)szFileName,m_iPercent);
    dc.SetTextColor(RGB(0,0,255));
    dc.SetBkMode(TRANSPARENT);
    dc.DrawText(szPercent,strlen(szPercent),m_rcDraw,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
    return 0L;
}
CBatchDlg::CBatchDlg(LPCSTR pszFileName,CStringArray* pszNameArray,CWnd* pParent /*=NULL*/)
    : CDialog(CBatchDlg::IDD, pParent),m_rcDraw(CPoint(0,50),CSize(300,30))
{
    m_iPercent=0;
    m_pszNameArray=pszNameArray;
    m_szHGLZName=pszFileName;
    m_fEncode=TRUE;
    //{{AFX_DATA_INIT(CBatchDlg)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
}
CBatchDlg::CBatchDlg(LPCSTR pszFileName,LPCSTR pszDirName,int* piPos,int iCount,CWnd* pParent /*=NULL*/)
    : CDialog(CBatchDlg::IDD, pParent),m_rcDraw(CPoint(0,50),CSize(300,30))
{
    m_szHGLZName=pszFileName;
    m_fEncode=FALSE;
    m_iPercent=0;
    m_szDirName=pszDirName;
    m_piPos=piPos;
    m_iCount=iCount;
    //{{AFX_DATA_INIT(CBatchDlg)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
}

void CBatchDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CBatchDlg)
        // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBatchDlg, CDialog)
    ON_MESSAGE(WM_LZW_DECODE_BYTES,OnDecodeBytes)
    ON_MESSAGE(WM_LZW_ENCODE_BYTES,OnEncodeBytes)
    //{{AFX_MSG_MAP(CBatchDlg)
    ON_WM_TIMER()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

int FindFileName(LPCSTR pszName);
void MakeFileName(LPCSTR pszIn,char* pszOut)
{
    
}
/*{
    int iLen=strlen(pszName);
    for(int i=iLen-1;i>=0;i--)
    {
        if(pszName[i]=='\\')
            return i+1;
    }
    return 0;
}*/


/////////////////////////////////////////////////////////////////////////////
// CBatchDlg message handlers
void CBatchDlg::BeginDecode(void)
{
    CStringArray array;
    if(!LZWParseFileHead(m_szHGLZName,array))
    {
        array.RemoveAll();
        OnOK();
        return;
    }
    int iTotal=array.GetUpperBound()+1;
    if(iTotal==0 )
    {
        array.RemoveAll();
        AfxMessageBox("error batch parameter");
        OnOK();
        return;
    }
    for(int i=0;i<m_iCount;i++)
    {
        szFileName=array.GetAt(m_piPos[i]);
        //MakeFileName(szPutName,szGetName);
        m_iPercent=0;
        LZWDecodeFileOnPosition(m_szHGLZName,m_szDirName,
                                (DWORD)m_piPos[i],BatchDecodedBytes);
    }
    array.RemoveAll();
    OnOK();
}
void CBatchDlg::BeginBatch(void)
{
    int iTotal=m_pszNameArray->GetUpperBound()+1;
    if(iTotal==0 )
    {
        AfxMessageBox("error batch encode parameter");
        OnOK();
        return;
    }
    char szGetName[1000];
    CString szTemp;
    for(int i=0;i<iTotal;i++)
    {
        szTemp=m_pszNameArray->GetAt(i);
        strcpy(szGetName,szTemp);
        szFileName=(szGetName+FindFileName(szGetName));
        //MakeFileName(szPutName,szGetName);
        m_iPercent=0;
        if(i==0)
            LZWEncodeFile(szGetName,m_szHGLZName,BatchEncodedBytes);
        else
            LZWAddEncodeFile(szGetName,m_szHGLZName,BatchEncodedBytes);
    }
    OnOK();
}
void CBatchDlg::OnTimer(UINT nIDEvent)
{
    CClientDC dc(this);
    dc.SelectStockObject(WHITE_BRUSH);
    dc.Rectangle(m_rcDraw);
    KillTimer(1);
    if(m_fEncode)
        BeginBatch();
    else
        BeginDecode();
    //SendMessage(WM_LZW_DECODE_BYTES);
    //SendMessage(WM_LZW_ENCODE_BYTES);
    CDialog::OnTimer(nIDEvent);
}

BOOL CBatchDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    hWndDlg=GetSafeHwnd();
    SetTimer(1,10,NULL);
    CRect rcC;
    GetClientRect(rcC);
    m_rcDraw+=CPoint((rcC.Width()-300)/2,0);
    if(!m_fEncode)
        SetWindowText("Batch DeCompress");
    return TRUE;  // return TRUE  unless you set the focus to a control
}
搜索更多相关主题的帖子: 楼主 麻烦 解释 
2008-04-22 16:31
快速回复:各位楼主麻烦你们帮我解释个程序谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027195 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved