??xml version="1.0" encoding="utf-8" standalone="yes"?>国内精品久久久久国产盗摄,久久九九有精品国产23百花影院,亚洲成色www久久网站夜月http://www.shnenglu.com/wanghaiguang/category/19357.html逆水行舟Q不q则退zh-cnFri, 10 Oct 2014 06:29:01 GMTFri, 10 Oct 2014 06:29:01 GMT60MFC wcslen获取中文长度http://www.shnenglu.com/wanghaiguang/archive/2014/10/10/208529.html王v?/dc:creator>王v?/author>Fri, 10 Oct 2014 03:53:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2014/10/10/208529.htmlhttp://www.shnenglu.com/wanghaiguang/comments/208529.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2014/10/10/208529.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/208529.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/208529.html不知道大家有没有我这U体?大家先看看下面这D代?
int fp=_wopen(L"Hello.dat",O_BINARY | O_CREAT | O_TRUNC | O_RDWR);
if(fp==-1) return;
write(fp,L"123中国?,wcslen(L"123中国?));
close(fp);

上面q段代码不知道大家看Z么BUG来了.如果大家看不出毛病也不为?因ؓq是我们的习惯导致了我们的错误?


先让我来分析一下write?下面是write的原?
int write( int handle, const void *buffer, unsigned int count );
参数:
handle   已打开或已创徏的文件句?/span>
buffer     待写入的数据
count     待写入的数据大小
现在分析Z么上面的那代码有bug,其实主要问题在一个buffer,和count.
如果我们写入一个Ansi字符?上面的代码改成相应的形式实没有?
但如果是写入一个宽字符?那么上面的代码就不严?原因在于count.

我们首先看一下strlen?/span>wcslen,如果使用strlen,一般情况下,我们直接作ؓ字符串的长度,
而?/span>wcslen,你会发现,得出的不是字W串的长度而是字符的个?

q就是问题的所?一般情况下.char的长度是1,q是用sizeof(char)q算出来的结?
len=strlen(str)*sizeof(char);而我们一般情况下,都只用strlen(str)来等?q就是^时的习惯.
正是׃q个习惯所引来的问?q个习惯q不适用于宽字符?因ؓwcslen(str)*sizeof(wchar_t)q不{于wcslen(strl).q就是习惯所引v的错?

说到q里我想大家都明白了.我在q里把这U习惯称之ؓ不良习惯.所以大家以后在计算字符串长度的时?千万不能而简?一定要len=strlen(str)*sizeof(char),len=wcslen(str)*sizeof(wchar_t).
不要再犯q种习惯性的低错误.

本文转自Q?a >http://blog.csdn.net/aylixuan/article/details/6130820

]]>
MFC讄鼠标滑轮响应http://www.shnenglu.com/wanghaiguang/archive/2014/05/08/206864.html王v?/dc:creator>王v?/author>Thu, 08 May 2014 08:33:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2014/05/08/206864.htmlhttp://www.shnenglu.com/wanghaiguang/comments/206864.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2014/05/08/206864.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/206864.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/206864.html鼠标滚轮消息g只会发给当前获得焦点的窗口,所以当子窗体没有焦Ҏ是收不到滚轮消息的,收到消息的可能是父窗口?/p>

解决Q添加鼠标单ȝ应函敎ͼ在响应函CdSetFoucs();一句,q样强制讄焦点l子H口Q然后再滚动鼠标滚轮Q子H体p收到滚轮消息了?/p>

 

问题l箋Q当子窗口上有其他可以获得焦点的控gӞ比如下拉列表Q这时在H口函数中执行SetFoucs();焦点会自动跑到那个控件上去,子窗口同h不到滚轮消息?/p>

解决Q在执行SetFoucs();语句前先Disable子窗体上的所有控Ӟ然后执行SetFoucs();Q再Enanle所有控Ӟq时焦点才会在子H口上?br />
本文转自Q?a style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21.111112594604492px;">http://blog.csdn.net/vanship/article/details/4119246



]]>
MFC 多文档界面禁用关闭、最大化按钮http://www.shnenglu.com/wanghaiguang/archive/2014/03/25/206331.html王v?/dc:creator>王v?/author>Tue, 25 Mar 2014 10:37:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2014/03/25/206331.htmlhttp://www.shnenglu.com/wanghaiguang/comments/206331.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2014/03/25/206331.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/206331.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/206331.html

?WM_CREATE 消息处理E序中的 MDI 子框架窗?QCMDIChildWnd zc) 用在关闭按钮用下面的代码Q?/p>

CMenu *pSysMenu = GetSystemMenu(FALSE); 
ASSERT(pSysMenu 
!= NULL); 
VERIFY(pSysMenu
->RemoveMenu(SC_CLOSE, MF_BYCOMMAND));

此时的最大、最化?span style="font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; white-space: normal;">q原按钮也消׃见。通过?/span>PreCreateWindow函数中修Ҏ实现昄最大、最化?/span>q原按钮?/span>
cs.style += WS_MINIMIZEBOX|WS_SIZEBOX; 



]]>
MFC 子对话框与父视图传递自定义消息http://www.shnenglu.com/wanghaiguang/archive/2014/03/07/206090.html王v?/dc:creator>王v?/author>Fri, 07 Mar 2014 07:01:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2014/03/07/206090.htmlhttp://www.shnenglu.com/wanghaiguang/comments/206090.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2014/03/07/206090.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/206090.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/206090.html视图c调用非模态对话时Q如何销毁分配的内存

要步骤:

1?/span>视图cd调用非模态对话框Ӟ自w的指针传递给非模态对话框?/span>
2?/span>当非模态对话框l束Ӟ向视囄发送自定义消息Q由自定义消息处理函数来释放内存?/span>

具体代码步骤Q?/strong>

1?/span>定义自定义消?nbsp; #define WM_RELEASEPLAYSOUNDDC (WM_USER+1001)
2?/span>修改非模态对话框cȝ构造函敎ͼ便于视图指针传递进厅R?/span>

非模态对话框.h文g?/span>

class CTestDialog : public CDialog
{
    DECLARE_DYNAMIC(CPlaySound)

public:
    //CTestDialog (CWnd* pParent = NULL);   // standard constructor
    CTestDialog (CView* pParent);   // standard constructor
    virtual ~CTestDialog ();
    CView *pView;

// Dialog Data
    enum { IDD = IDD_TEST_DIALOG };

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg LRESULT OnNcHitTest(CPoint point);

};

非模态对话框.cpp文g?/span>
IMPLEMENT_DYNAMIC(CTestDialog, CDialog)
//CTestDialog::CTestDialog(CWnd* pParent /*=NULL*/)
CTestDialog::CTestDialog(CView* pParent)
    : CDialog(CTestDialog::IDD, pParent)
{
    pView = pParent;
}

3、在非模态对话框l束的时候发送自定义消息
void CTestDialog::OnBnClickedBtnClose()
{
    // TODO: Add your control notification handler code here
    pView->PostMessage(WM_RELEASEPLAYSOUNDDC, 0, 0);
    OnOK();
}

4、在视图c?/span>.h文g中,增加定义Q?/span>
afx_msg LRESULT OnReleaseDialog(WPARAM wparam,LPARAM lparam);

5、在视图c?/span>.cpp文g中,增加消息映射部分Q?/span>
ON_MESSAGE(WM_DIALOGOK,OnDialogOk)

6、在视图c?/span>.cpp文g?/span>定义消息处理函数的实玎ͼ

LRESULT CTestView::OnReleaseDialog(WPARAM wparam,LPARAM lparam)
{
    if (m_pPlaySound != NULL)
    {
        delete m_pPlaySound;
        m_pPlaySound = NULL;
    }

    return 0;
}


]]>
MFC BMP文g转JPEG文ghttp://www.shnenglu.com/wanghaiguang/archive/2014/01/09/205258.html王v?/dc:creator>王v?/author>Thu, 09 Jan 2014 06:30:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2014/01/09/205258.htmlhttp://www.shnenglu.com/wanghaiguang/comments/205258.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2014/01/09/205258.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/205258.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/205258.html2.在你要使用GDI+的工E中Q完成初始化工作Q?br />?/span>StdAfx.h中加?/span>

#define ULONG_PTR unsigned long
#include <Gdiplus.h>
using namespace Gdiplus;

3.?/span>CXApp头文件中加入

ULONG_PTR        m_gdiplusToken;

 4.?BOOL CXApp::InitInstance() 中添?/span>

GdiplusStartupInput     m_gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken&m_gdiplusStartupInput, NULL);

 5.?/span>int CXApp::ExitInstance()加入(q个Ҏ需要自己加?在ClassWizard 中,注意在ClassName中选择CXApp,Messages列表框中选择ExitInstance)

Gdiplus::GdiplusShutdown(m_gdiplusToken);

 6.在Project->stting->Link->Intput->Additional Dependencies中加?/span>gdiplus.lib

此时GDI+讄成功?br />
具体代码如下Q?br />

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)   
{   
UINT num = 0;                     // number of image encoders   
UINT size = 0;                   // size of the image encoder array in bytes   
ImageCodecInfo* pImageCodecInfo = NULL;   
GetImageEncodersSize(&num, &size);   
if(size == 0)   
return -1;     //   Failure   
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));   
if(pImageCodecInfo == NULL)   
return -1;     //   Failure   
GetImageEncoders(num, size, pImageCodecInfo);   
for(UINT j = 0; j < num; ++j)   
{   
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )   
{   
*pClsid = pImageCodecInfo[j].Clsid;   
free(pImageCodecInfo);   
return j;     //   Success   
}           
}   
free(pImageCodecInfo);   
return -1;     //   Failure   
}
void SaveFile(Bitmap* pImage, const wchar_t* pFileName)
{
EncoderParameters encoderParameters;
CLSID jpgClsid
GetEncoderClsid(L"image/jpeg", &jpgClsid);
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
// Save the image as a JPEG with quality level 100.
ULONG             quality;
quality = 100;
encoderParameters.Parameter[0].Value = &quality;
Status status = pImage->Save(pFileName, &jpgClsid, &encoderParameters);
if (status != Ok
{
wprintf(L"%d Attempt to save %s failed./n", status, pFileName);
}
}

//调用方式Q?/span>
Bitmap newbitmap(L"d://d.bmp");//加蝲BMP
const wchar_t *pFileName=L"d://new.jpg";//保存路径
SaveFile(&newbitmap,pFileName );

本文转自Q?/span>http://blog.csdn.net/highyyy/article/details/6125763

 



]]>
MFC 修改单文档标?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/12/13/204764.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Fri, 13 Dec 2013 02:28:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/12/13/204764.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/204764.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/12/13/204764.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/204764.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/204764.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;"><strong>一、修Ҏ?/strong></span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff;"><br /></span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">Ҏ1Q?/span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">在CMainFrame?/span><span style="color: #0000ff; font-family: Verdana; font-size: 12pt;">PreCreateWindow(CREATESTRUCT& cs)</span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">q行更改</span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">Q如下:</span><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="font-family: Verdana;">BOOL CKTLXSubjectShowFrame::PreCreateWindow(CREATESTRUCT& cs)</span><br /><span style="font-family: Verdana;">{</span><br />    <span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;"> TODO: Add your specialized code here and/or call the base class</span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">    cs.style &=~WS_MAXIMIZEBOX;</span><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">用最大化按钮</span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">    cs.style &=~WS_SIZEBOX;</span><br />    <span style="color: red; font-family: Verdana;">cs.style </span><span style="color: red; font-family: Verdana;">&=~</span><span style="color: red; font-family: Verdana;">FWS_ADDTOTITLE;</span><br /><br /><span style="font-family: Verdana;">    cs.lpszName = </span><span style="color: #ff0000; font-family: Verdana;">_T(</span><span style="color: #ff0000; font-family: Verdana;">"</span><span style="color: #ff0000; font-family: Verdana;">试标题</span><span style="color: #ff0000; font-family: Verdana;">"</span><span style="color: #ff0000; font-family: Verdana;">)</span><span style="color: red; font-family: Verdana;">;</span><br /><span style="font-family: Verdana;">    cs.cx = 970;</span><br /><span style="font-family: Verdana;">    cs.cy = 650;</span><br />    <span style="color: #0000ff; font-family: Verdana;">return</span><span style="font-family: Verdana;"> CXTPFrameWnd::PreCreateWindow(cs);</span><br /><span style="font-family: Verdana;">}</span></div><span style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">Ҏ2Q在doccM</span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; color: #0000ff; font-size: 12pt;">OnNewDocument</span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">函数修改Q添加修改的标题Q如下:</span><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="font-family: Verdana;">BOOL CKTLXSubjectShowDoc::OnNewDocument()</span><br /><span style="font-family: Verdana;">{</span><br />    <span style="color: #0000ff; font-family: Verdana;">if</span><span style="font-family: Verdana;"> (!CDocument::OnNewDocument())</span><br />        <span style="color: #0000ff; font-family: Verdana;">return</span><span style="font-family: Verdana;"> FALSE;</span><br /><br />    <span style="color: #ff0000; font-family: Verdana;">SetTitle(_T(</span><span style="color: #ff0000; font-family: Verdana;">"</span><span style="color: #ff0000; font-family: Verdana;">试标题</span><span style="color: #ff0000; font-family: Verdana;">"</span><span style="color: #ff0000; font-family: Verdana;">));</span><br /><br />    <span style="color: #0000ff; font-family: Verdana;">return</span><span style="font-family: Verdana;"> TRUE;</span><br /><span style="font-family: Verdana;">}</span></div><span style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></span><strong><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">二?/span><span style="font-family: Verdana; font-size: 16px; line-height: 20px; background-color: #ffffff;">修改标题后半部分</span></strong><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;"><br /></span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 12pt;">单文标题通常会有两部分组成,例如Q?/span><span style="font-family: Verdana; line-height: 26px; background-color: #ffffff; color: #ff0000; font-size: 12pt;">标题名称—工程名称Q?/span><span style="font-family: Verdana; font-size: 12pt; line-height: 26px; background-color: #ffffff;">修改StringTable的IDR_MAINFRAME的标题,第一个\n之前的字W串替换?/span><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0pt; padding: 0px; font-size: 12px; font-family: Simsun; line-height: 20px; background-color: #ffffff;"></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: red;">标题</span>\n\nTestSingleTitle\n\n\nTestSingleTitle.Document\nTestSingleTitle.Document</div><p> <span style="line-height: 20px; font-size: 12pt; font-family: Verdana;"><strong>三、去</strong></span><span style="line-height: 20px; font-size: 12pt; font-family: Verdana;"><strong>掉标题的后半部分</strong></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0pt; padding: 0px; font-size: 12px; font-family: Simsun; line-height: 20px; background-color: #ffffff;"><span style="font-family: Verdana; font-size: 12pt;">Ҏ1Q?/span><span style="font-size: 12pt; font-family: Verdana;">在C</span><span style="font-family: Verdana; font-size: 12pt; line-height: 21px; text-indent: 26.66666603088379px;">TestSingleTitle</span><span lang="EN-US" style="font-size: 12pt; font-family: Verdana;">App::InitInstance()</span><span style="font-size: 12pt; font-family: Verdana;">中调用如下语?/span><span lang="EN-US" style="font-size: 12pt; font-family: Verdana;">m_pMainWnd->SetWindowText(<span style="font-size: 12pt;">_T(</span><span lang="EN-US" style="font-size: 10pt;"><span style="font-size: 12pt;">"</span></span><span lang="EN-US" style="font-size: 12pt; color: #0000ff;"><strong style="color: #ff0000; text-indent: 26.66666603088379px;">标题</strong></span><span lang="EN-US" style="font-size: 10pt;"><span style="font-size: 12pt;">")</span></span><span lang="EN-US" style="font-size: 12pt;">);</span></span><span style="font-family: Verdana; font-size: 12pt;">或在其他地方?span lang="EN-US" style="font-size: 12pt;">(AfxGetMainWnd())->SetWindowText(</span></span><span lang="EN-US" style="font-family: Verdana; font-size: 10pt;"><span style="font-size: 12pt;">_T(</span><span style="font-size: 10pt;"><span style="font-size: 12pt;">"</span></span><span style="font-size: 12pt; color: #0000ff;"><strong style="color: #ff0000; text-indent: 26.66666603088379px;">标题</strong></span><span style="font-size: 12pt;"><span style="color: maroon;">")</span></span></span><span lang="EN-US" style="font-family: Verdana; font-size: 12pt;">);</span><span style="font-family: Verdana; font-size: 12pt;">也可以得到相同的l果?/span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0pt; padding: 0px; font-size: 12px; font-family: Simsun; line-height: 20px; background-color: #ffffff;"><span style="font-size: 10pt; font-family: 新宋?"> </span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px;"><span style="font-size: 12pt; font-family: Verdana; color: #000000;">Ҏ2Q?/span><span style="font-size: 12pt; font-family: Verdana;">可以通过</span><span style="font-size: 12pt; font-family: Verdana;">利用<span lang="EN-US" style="font-family: Verdana; font-size: 12pt;">CWnd::SetWindowText</span></span><span style="font-size: 12pt; font-family: Verdana;">卻I<span lang="EN-US" style="font-family: Verdana; font-size: 12pt;">void SetWindowText( LPCTSTR</span> <span lang="EN-US" style="font-family: Verdana; font-size: 12pt;">lpszString );</span></span><span style="font-size: 12pt; font-family: Verdana;">重蝲<span lang="EN-US" style="font-family: Verdana; font-size: 12pt;">CFramWnd</span></span><span style="font-size: 12pt; font-family: Verdana;">cȝ<span lang="EN-US" style="font-family: Verdana; font-size: 12pt; color: #0000ff;">OnUpdateFrameTitle</span></span><span style="font-size: 12pt; font-family: Verdana;">函数</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0pt; padding: 0px;"></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000ff; font-family: Verdana;">void</span><span style="font-family: Verdana;"> CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)</span><br /><span style="font-family: Verdana;">{</span><br />    <span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;"> TODO: 在此d专用代码?或调用基cR</span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">   </span><span style="font-family: Verdana; color: #ff0000;"> SetWindowText(_T(</span><span style="font-family: Verdana; color: #ff0000;">"</span><span style="font-family: Verdana; color: #ff0000;">标题</span><span style="font-family: Verdana; color: #ff0000;">"</span><span style="font-family: Verdana; color: #ff0000;">));</span><br /><span style="font-family: Verdana;">    CFrameWnd::OnUpdateFrameTitle(bAddToTitle);</span><br /><span style="font-family: Verdana;">}</span></div><p> <span style="font-size: 12pt; font-family: Verdana;">Ҏ</span><span style="font-size: 12pt; font-family: Verdana;">3</span><span style="font-size: 12pt; font-family: Verdana;">Q在</span><span style="font-size: 10pt; font-family: Verdana;"><span lang="EN-US" style="font-size: 12pt;">CMainFrame</span></span><span style="font-size: 12pt; font-family: Verdana;">?span lang="EN-US" style="color: #0000ff; font-size: 12pt;">PreCreateWindow</span></span><span style="font-size: 12pt; font-family: Verdana;">函数中修改窗口风|</span></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="font-family: Verdana;">BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)</span><br /><span style="font-family: Verdana;">{</span><br />          <span style="color: #ff0000; font-family: Verdana;">cs.style </span><span style="color: #ff0000; font-family: Verdana;">&=</span> <span style="color: #ff0000; font-family: Verdana;">~</span><span style="color: #ff0000; font-family: Verdana;">(LONG) FWS_ADDTOTITLE;</span><br />          <span style="color: #0000ff; font-family: Verdana;">return</span><span style="font-family: Verdana;"> CFrameWnd::PreCreateWindow(cs);</span><br /><span style="font-family: Verdana;">}</span></div><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/204764.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-12-13 10:28 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/12/13/204764.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC PreTranslateMessage(MSG* pMsg)中调用DoModal()模态窗口问?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/12/05/204603.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Thu, 05 Dec 2013 02:58:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/12/05/204603.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/204603.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/12/05/204603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/204603.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/204603.html</trackback:ping><description><![CDATA[<span style="font-size: 12pt;"> ?/span><span style="font-size: 12pt;">PreTranslateMessage(MSG* pMsg)中调用DoModal()模态窗口如下:<br /></span><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1 BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)<br /> 2 {<br /> 3     <span style="color: #008000; ">//</span><span style="color: #008000; "> TODO: Add your specialized code here and/or call the base class</span><span style="color: #008000; "><br /></span> 4     <span style="color: #0000FF; ">if</span> ( pMsg->message == WM_LBUTTONDOWN)<br /> 5     {<br /> 6         GetWindowRect(m_oldRect);<br /> 7         ::SetCapture(<span style="color: #0000FF; ">this</span>->m_hWnd);<br /> 8         m_bCanDrag = TRUE;<br /> 9         m_lastPt = pMsg->pt ;<br />10     }<br />11     <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> ( pMsg->message == WM_LBUTTONUP)<br />12     {<br />13         <span style="color: #0000FF; ">if</span>( m_bCanDrag )<br />14         {<br />15             ::ReleaseCapture();<br />16             m_bCanDrag = FALSE;<br />17             GetWindowRect(m_newRect);<br />18             <span style="color: #0000FF; ">if</span> (m_oldRect.EqualRect(m_newRect))<br />19             {<br />20                 <span style="color: #ff00ff;">GetMainItemID(pMsg);</span><span style="color: #008000; ">//</span><span style="color: #008000; ">调用对话框函?/span><span style="color: #008000; "><br /></span>21<span style="color: #ff0000;">                 </span><span style="color: #339966;">//</span><span style="color: #339966;">return</span><span style="color: #339966;"> TRUE;</span><br />22             }<br />23         }<br />24     } <br />25     <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span>( pMsg->message == WM_MOUSEMOVE)<br />26     {<br />27         <span style="color: #0000FF; ">if</span>( m_bCanDrag )<br />28         {<br />29             CRect rc;<br />30             GetWindowRect(&rc);<br />31             rc.OffsetRect( pMsg->pt.x - m_lastPt.x , pMsg->pt.y - m_lastPt.y  ) ;<br />32             m_lastPt = pMsg->pt;<br />33             <span style="color: #0000FF; ">this</span>->MoveWindow( rc );<br />34         }<br />35     }<br />36 <br />37     <span style="color: #0000FF; ">return</span> CDialog::PreTranslateMessage(pMsg);<br />38 }<br /><br />39  <span style="color: #0000FF; ">void</span> CMainDlg::GetMainItemID(MSG* pMsg)<br />40 {<br />41     <span style="color: #0000FF; ">if</span> (pMsg->hwnd == GetDlgItem( IDC_BTN_MYCOMPUTER )->m_hWnd)<br />42     {<br />43       <span style="color: #ff00ff;"> CTestDlg dlg;</span><br />44        <span style="color: #ff00ff;">dlg.DoModal();</span><br />45     }<br />46 }</div><br /><span style="font-size: 12pt;">再单d话框上的按钮时发送断a中断Q具体位|如下:</span><br /><img src="http://www.shnenglu.com/images/cppblog_com/wanghaiguang/domal.jpg" width="788" height="548" alt="" /><br /><br /><div><strong style="font-size: 14pt;">::IsWindow(m_hWnd)<br /><br /></strong></div><div style="clear: both; font-size: 0px; line-height: 0; height: 0px; visibility: visible; font-family: arial, 宋体, sans-serif; background-color: #ffffff;"></div><div style="font-family: arial, 宋体, sans-serif; line-height: 24px; color: #333333; margin-bottom: 5px; text-indent: 2em;">函数功能Q该函数定l定?a target="_blank" style="text-decoration: none; color: #136ec2;">H口句柄</a>是否标识一个已存在的窗口?/div><div style="font-family: arial, 宋体, sans-serif; line-height: 24px; color: #333333; margin-bottom: 5px; text-indent: 2em;">函数原型QBOOL IsWindowQHWND hWndQ;</div><div style="font-family: arial, 宋体, sans-serif; line-height: 24px; color: #333333; margin-bottom: 5px; text-indent: 2em;">参数Q?/div><div style="font-family: arial, 宋体, sans-serif; line-height: 24px; color: #333333; margin-bottom: 5px; text-indent: 2em;">hWnd:被测试窗口的句柄?/div><div style="font-family: arial, 宋体, sans-serif; line-height: 24px; color: #333333; margin-bottom: 5px; text-indent: 2em;">q回|如果<a target="_blank" style="text-decoration: none; color: #136ec2;">H口句柄</a>标识了一个已存在的窗口,q回gؓ非零Q如果窗口句柄未标识一个已存在H口Q返回gؓ零?/div><br /><span style="color: #ff0000; font-size: 12pt;">可能原因Q?/span><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">在PreTranslateMessage里的获取对应m_hWndQ?/span><span style="font-size: 12pt;">DoModal()模态对话框退出后Q?/span><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">m_hWnd</span><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">不是有效的窗口句柄?/span><br /><span style="color: #ff0000; font-size: 12pt;">解决办法Q?/span><span style="font-size: 12pt;">处理?/span><span style="font-size: 12pt;">WM_LBUTTONUP</span><span style="font-size: 12pt;">后,</span><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">需要返回TRUE?/span><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/204603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-12-05 10:58 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/12/05/204603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FTP上传、下载及其相兛_能示?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/11/19/204327.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Tue, 19 Nov 2013 00:54:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/11/19/204327.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/204327.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/11/19/204327.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/204327.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/204327.html</trackback:ping><description><![CDATA[<h1><span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900;"><br />FTP</span> Wanderer - <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900;">FTP</span> Client using WININET<br /><div class="frthzhz" id="contentdiv" itemprop="articleBody" style="margin: 0px; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: normal; background-color: #ffffff;"><ul style="margin: 25px 0px 10px; padding: 0px 0px 0px 40px; border: 0px;"><li style="margin: 0px 0px 6px -40px; padding: 0px 0px 1px 30px; border: 0px; background-image: url(http://s.codeproject.com/images/download24.png); background-attachment: scroll; background-color: transparent; font-weight: bold; list-style-type: none; vertical-align: middle; background-position: 0% 50%; background-repeat: no-repeat no-repeat;"><a style="margin: 0px; padding: 0px; border: 0px; text-decoration: none; color: purple;">Download executable - 105 Kb</a></li><li style="margin: 0px 0px 6px -40px; padding: 0px 0px 1px 30px; border: 0px; background-image: url(http://s.codeproject.com/images/download24.png); background-attachment: scroll; background-color: transparent; font-weight: bold; list-style-type: none; vertical-align: middle; background-position: 0% 50%; background-repeat: no-repeat no-repeat;"><a style="margin: 0px; padding: 0px; border: 0px; text-decoration: none; color: purple;">Download source - 152 Kb</a></li></ul><p><img src="http://www.codeproject.com/KB/IP/ftpwanderer/ftpwanderer.jpg" alt="Sample Image" width="550" height="467" style="margin: 0px; padding: 0px; border: 0px; overflow: auto; max-width: 100%; height: auto;" /></p><h2>Description</h2><p>This article presents a fully functional implementation of a <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> client. <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> Wanderer is a multithreaded <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> client with the look-and-feel of Windows Explorer, and makes moving files between the Internet and your computer as simple as local file manipulation. This application uses WININET API's to handle the <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> protocol, and while it's not the most elegant way to connect to a <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> server it does the job pretty well.</p><h2><strong>Features list</strong></h2><ul style="margin: 10px 0px; padding: 0px 0px 0px 40px; border: 0px;"><li style="margin: 0px; padding: 0px; border: 0px;">All file transfer requests are handled in the background, so you don't have to wait while files copy to continue browsing the current server. You can even connect to a different server, while file transfers on another server are still in progress.</li><li style="margin: 0px; padding: 0px; border: 0px;">The Transfer Manager shows all file transfers currently in progress plus the ones that are in the queue. You can configure how many transfers are processed simultaneously, so you don't run out of resources.</li><li style="margin: 0px; padding: 0px; border: 0px;"><span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> Wanderer uses the Windows 9x/NT/XP style list boxes for displaying the contents of remote servers. With all familiar system icons and context menus.</li><li style="margin: 0px; padding: 0px; border: 0px;">You can specify the number of times it should try to connect, and the time delay between connection attempts.</li><li style="margin: 0px; padding: 0px; border: 0px;">Full Drag and Drop support. Simply drag one or more files or even complete folders onto <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> Wanderer's file view area to transfer them to the location of the server that is currently connected.</li><li style="margin: 0px; padding: 0px; border: 0px;">Easily configure <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> site settings, like username, password, port, initial remote folder, number of retries and default download folder.</li></ul><p>Here's a brief description of some of the important classes of the application:</p><h3>CMainFrame</h3><p>CMainFrame contains most of the code for managing the <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> connection. It takes care of connecting to the server; initiate up/downloads and handling other <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> related actions.</p><h3>C<span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900;">FTP</span>ListView</h3><p>This is just a <code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">CListView</code> derived class that takes care of displaying the files and enabling you to sort them. When the application is busy downloading or sorting a directory listing it can display an animation, just like explorer does.</p><h3>CConnectDlg</h3><p>This class (= Site Manager) enables the user to manage <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> sites. You can add/change and delete sites and configure properties such as hostname, port, username and password. The settings of each site are save to disk using serializing.</p><h3>CTransferManagerDlg</h3><p><code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">CTransferManagerDlg</code> (= Transfer manager) takes care of queuing the file transfers. It shows all file transfers currently in progress plus the ones that are in the queue. You can configure how many transfers are processed simultaneously, so you don't run out of resources. Each up/download in handled in a separate thread by initiating a<code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">CDownloadThread</code> or <code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">C<span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">Upload</span>Thread</code> thread.</p><h3>CDownloadThread</h3><p>Each download is handled in the background using a separate thread. <code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">CDownloadThread</code> creates a new connection with the <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> server and displays a progress dialog that tells you the status of the file transfer. When the download is completed (or aborted) it notifies the transfer manager so the UI can be updated.</p><h3>C<span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900;">Upload</span>Thread</h3><p>Each <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">upload</span> is handled in the background using a separate thread. <code style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-size: 11pt; font-family: Consolas, 'Courier New', Courier, mono;">C<span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">Upload</span>Thread</code> creates a new connection with the <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> server and displays a progress dialog that tells you the status of the file transfer. When the <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">upload</span> is completed (or aborted) it notifies the transfer manager so the UI can be updated.</p><h2><strong>To do list:</strong></h2><p>While this application has most of the features you might expect in a <span style="margin: 0px; padding: 0px; border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: #ff9900; font-weight: bold;">FTP</span> client, there are a few things left to do:</p><ul style="margin: 10px 0px; padding: 0px 0px 0px 40px; border: 0px;"><li style="margin: 0px; padding: 0px; border: 0px;">Drag and drop support out of the file view area to Explorer. I think this one is not that easy, because this would probably 'block' explorer until the file transfer is completed (any suggestions?).</li><li style="margin: 0px; padding: 0px; border: 0px;">Progress indication in the transfer manager. This is not really that hard to do, so this will probably be in the next release.</li><li style="margin: 0px; padding: 0px; border: 0px;">Better asynchrony handling of getting directory listing. The UI now does not respond when downloading a huge directory listing.</li></ul><h2>Contacting the Author</h2>Please send any comments or bug reports to me via <a href="mailto:info@pablovandermeer.nl" style="margin: 0px; padding: 0px; border: 0px; text-decoration: none; color: purple;">email</a>. For any updates to this article, check my site <a style="margin: 0px; padding: 0px; border: 0px; text-decoration: none; color: purple;">here</a>.<h2>Revision history</h2><ul style="margin: 10px 0px; padding: 0px 0px 0px 40px; border: 0px;"><li style="margin: 0px; padding: 0px; border: 0px;">31st July 2002 - Initial revision.</li></ul></div></h1><h2>License</h2><div class="pdljxhj" id="LicenseTerms" style="margin: 0px; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: normal; background-color: #ffffff;"><p>This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.</p><p>A list of licenses authors might use can be found <a style="margin: 0px; padding: 0px; border: 0px; text-decoration: none; color: purple;">here<br /><br />原文</a>地址Q?a >http://www.codeproject.com/Articles/2665/FTP-Wanderer-FTP-Client-using-WININET</a></p></div><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/204327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-11-19 08:54 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/11/19/204327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC COMBOX控g只接受数字和讄数字范围http://www.shnenglu.com/wanghaiguang/archive/2013/09/25/203432.html王v?/dc:creator>王v?/author>Wed, 25 Sep 2013 09:39:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/09/25/203432.htmlhttp://www.shnenglu.com/wanghaiguang/comments/203432.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/09/25/203432.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/203432.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/203432.html在MFC开发过E中使用ComboBoxQ有时会Ҏ需求要求只能输入数字,q且要求数字在一定的范围内,例如一个用于选择时的ComboBoxQ时间范围ؓ00?3Q那么该如何实现Q?/span>

代码如下Q?/span>

在Dialog.h中: 
…… 
CComboBox m_cbHour;// 声明CComboBoxcd作ؓCDialogcȝ成员变量 
…… 
afx_msg void OnCbnEditchangeCbHour(); 
afx_msg void OnCbnEditupdateCbHour();

在Dialog.cpp中: 
…… 
DDX_Control(pDX, IDC_CB_HOUR, m_cbHour);// 数据交换 
…… 
ON_CBN_EDITCHANGE(IDC_CB_HOUR, &CDialog::OnCbnEditchangeCbHour)//d消息映射Q用于CComboBox内容改变?nbsp;
ON_CBN_EDITUPDATE(IDC_CB_HOUR, &CCDialog::OnCbnEditupdateCbHour)//d消息映射Q用于CComboBox内容更新 
…… 
下面来具体实现函敎ͼ 
image 
循环遍历CComboBox中已l输入的字符如果发现含有非数字则Q置?#8220;00”Q用@环的目的是ؓ了防止用戯着输(大概只有试人员才会跳着输)?br />
for循环改ؓfor (int i = 0; i < (strTmp.GetLength()); i++)遇到非数字字W就讄?0Q?/span>

image 
当CComboBox更新数据时判断数字范_如果过边界Q则讄gؓ最q边界|x一个只接受可控范围数字的CComboBox完成了Q但是在WinCE开发中却有一个问题,是所有的汉字都输不进去,但是“?#8221;q个汉字却能输入Q不知道q是不是一个BUGQ如果在代码中对“?#8221;做特别判断,那这D늨序也太奇怪了Q?br />
本文转自Q?/span>http://blog.csdn.net/wyunteng/article/details/6370882



]]>
MFC解决讄控g内容 文字重叠问题http://www.shnenglu.com/wanghaiguang/archive/2013/09/24/203402.html王v?/dc:creator>王v?/author>Tue, 24 Sep 2013 02:31:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/09/24/203402.htmlhttp://www.shnenglu.com/wanghaiguang/comments/203402.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/09/24/203402.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/203402.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/203402.html在用SetWindowText讄控g内容Ӟ有时候会出字体重叠问题,调用ơ数多Q重叠越严重。以下ؓ解决Ҏ?br />
Ҏ一Q?/span>RedrawWindow()
1 GetDlgItem(IDC_STATIC)->SetWindowText("your string");   
2 GetDlgItem(IDC_STATIC)->GetParent()->RedrawWindow(); 

~点Q?/span>H口h太频J,一闪一闪,效果不太好?br />
Ҏ二:局部刷?/span>
1 void YourDlg::RefreshControl(UINT uCtlID)   
2 {      
3     CRect   rc;      
4     GetDlgItem(uCtlID)->GetWindowRect(&rc);    
5     ScreenToClient(&rc);      
6     InvalidateRect(rc);      
7 }     

Ҏ三:隐藏和显C?/span>
1 GetDlgItem(IDC_STATIC)->ShowWindow(SW_HIDE);
2 GetDlgItem(IDC_STATIC)->ShowWindow(SW_SHOW);



]]>
判断文gCFile已经打开http://www.shnenglu.com/wanghaiguang/archive/2013/09/23/203381.html王v?/dc:creator>王v?/author>Mon, 23 Sep 2013 08:46:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/09/23/203381.htmlhttp://www.shnenglu.com/wanghaiguang/comments/203381.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/09/23/203381.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/203381.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/203381.html

CFilecȝ成员变量Q?/span>

m_hFileQ表CZ个打开文g的操作系l文件句柄。通过?/span>m_hFile ?/span> CFile::hFileNull的比较来判断该文件是否已l打开?br />
CZ代码Q?br />

 1     CString strFilename = _T("D:\\大学语文.docx");
 2     CFile file;
 3     file.Open(strFilename,CFile::modeReadWrite);//
 4     
 6     if (file.m_hFile != CFile::hFileNull)
 7     {
 8         file.Close();
 9     }
10     else
11     {
12         printf("File Already Close \n");
13     }

Ҏ二:

利用file.GetFileName().IsEmpty()来判?br />

CZ代码Q?/span>

 1     CString strFilename = _T("D:\\大学语文.docx");
 2     CFile file;
 3     file.Open(strFilename,CFile::modeReadWrite);//
 4     
 5     if (!file.GetFileName().IsEmpty())
 6     {
 7         file.Close();
 8     }
 9     else
10     {
11         printf("File Already Close \n");
12     }

Ҏ三:

通过讄成员变量来记录文件是否被打开。如BOOL bIsFileOpen;默认?/span>FALSE,

打开成功Q把它置?/span>TRUE;否则|ؓFALSE;

然后在程序里面判断就可以了。关闭后|?/span>bIsFileOpen?/span>FALSE,

 



]]>
MFC 解决默认回R或ESC会关闭对话框的办?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/09/13/203208.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Fri, 13 Sep 2013 00:31:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/09/13/203208.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/203208.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/09/13/203208.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/203208.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/203208.html</trackback:ping><description><![CDATA[<span style="font-family: 宋体; line-height: 25px; background-color: #ffffff; font-size: 12pt;">一U方法:解决Ҏ是在CDialog::PreTranslateMessage() 的重载函CESC和回车按键的消息处理?<br /></span><span style="font-family: 宋体; line-height: 25px; background-color: #ffffff;"><br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)   <br />{  <br />    <span style="color: #0000FF; ">if</span>(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_RETURN)     <br />        <span style="color: #0000FF; ">return</span> TRUE;  <br />    <span style="color: #0000FF; ">if</span>(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_ESCAPE)     <br />        <span style="color: #0000FF; ">return</span> TRUE;  <br />    <span style="color: #0000FF; ">return</span> CDialog::PreTranslateMessage(pMsg);  <br />}  </div><br /><span style="font-size: 12pt;">另一U方法:</span><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">一开始的cancel按扭不要LQ双dq入命oOnCancel(), 把OnCancel()L</span><br style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5;" /><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">直接q回Q这没问题?/span><br style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5;" /><br style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5;" /><span style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5; font-size: 12pt;">如果你已l把按钮删掉Q那得手工加这个命令,但效果一?/span><br style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #f5f5f5;" /><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/203208.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-09-13 08:31 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/09/13/203208.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC获取pȝ当前旉http://www.shnenglu.com/wanghaiguang/archive/2013/08/22/202704.html王v?/dc:creator>王v?/author>Thu, 22 Aug 2013 09:36:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/08/22/202704.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202704.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/22/202704.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202704.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202704.html1.使用CTimec?  

CString str; //获取pȝ旉   

CTime tm; tm=CTime::GetCurrentTime();   

str=tm.Format("现在旉?Yq?m?d?%X");

MessageBox(str,NULL,MB_OK); 2: 得到pȝ旉日期(使用GetLocalTime)   

SYSTEMTIME st;   

CString strDate,strTime;   

GetLocalTime(&st);   

strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);   

strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);

 

3.使用GetTickCount//获取E序q行旉   

long t1=GetTickCount();//E序D开始前取得pȝq行旉(ms)   

Sleep(500); long t2=GetTickCount();//E序D늻束后取得pȝq行旉(ms)   

str.Format("time:%dms",t2-t1);//前后之差?E序q行旉   

AfxMessageBox(str);//获取pȝq行旉   

long t=GetTickCount();   

CString str,str1;   

str1.Format("pȝ已运?%d?,t/3600000);   

str=str1; t%=3600000;   

str1.Format("%d?,t/60000);   

str+=str1; t%=60000;   

str1.Format("%dU?,t/1000);   

str+=str1; AfxMessageBox(str);

本文转自Q?a style="font-family: verdana, 'courier new'; line-height: 21px;">http://www.cnblogs.com/bigbigtree/archive/2011/12/02/2272066.html



]]>
Word、RichEdit文本转RTF文gQRTF文g转HTMLhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202684.html王v?/dc:creator>王v?/author>Wed, 21 Aug 2013 00:53:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202684.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202684.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202684.html#Feedback1http://www.shnenglu.com/wanghaiguang/comments/commentRss/202684.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202684.html1、RichEdit文本转RTF文g


static DWORD CALLBACK MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
    CFile* pFile = (CFile*) dwCookie;
    pFile->Write(pbBuff, cb);
    *pcb = cb;
    return 0;
}

void CKTLXFunction::OnBnClickedIssuePaper()
{
    // TODO: Add your control notification handler code here
    CString sText;
    m_richEdit.GetWindowText(sText);
    if (sText.IsEmpty() && m_sImportPaperPath.IsEmpty())
    {
        AfxMessageBox("内容为空");
        return;
    }

    CString sImportRtfPath = CCommonFun::GetExecutablePath() + "temp.rtf";
    if (CFileFind().FindFile(sImportRtfPath))
    {
        ::DeleteFile(sImportRtfPath);
    }

    CFile cFile(TEXT(sImportRtfPath), CFile::modeCreate|CFile::modeWrite);
    EDITSTREAM es;
    es.dwCookie = (DWORD) &cFile; //讄用例参数,以便回调函数调用
    es.pfnCallback = MyStreamOutCallback;
    m_richEdit.StreamOut(SF_RTF, es);
}

2、word文本转RTF文g

    CString  m_sImportRtfPath = CCommonFun::GetExecutablePath() + "temp.rtf";
    if (CFileFind().FindFile(m_sImportRtfPath))
    {
        ::DeleteFile(m_sImportRtfPath);
    }

    _Application WordApp;
    CoInitialize(NULL);
    if(!WordApp.CreateDispatch("Word.Application",NULL))
    {
        LOG("创徏Word服务p|!");
        exit(1);
        return FALSE;
    }
    WordApp.SetVisible(FALSE);

    COleVariant vTrue((short)TRUE),vFalse((short)FALSE),vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

    Documents docs=WordApp.GetDocuments();
    docs.Open(COleVariant("word文g路径"), vFalse, vFalse, vFalse, COleVariant(""), 
              COleVariant(""), vFalse, COleVariant(""), COleVariant(""),
              COleVariant((short)0),COleVariant("UTF-8") ,vTrue, vFalse, 
              COleVariant((short)0), vFalse, COleVariant(""));

    _Document active_doc; 
    active_doc = WordApp.GetActiveDocument();

    active_doc.SaveAs(COleVariant(m_sImportRtfPath), COleVariant((short)wdFormatRTF), vFalse, 
              COleVariant(""),vFalse, COleVariant(""), vFalse, vTrue, vFalse, vFalse,
              vFalse,COleVariant("936"), vFalse, vFalse, COleVariant((short)0), vFalse);

    WordApp.Quit(vOpt, vOpt, vOpt);
    active_doc.ReleaseDispatch();
    docs.ReleaseDispatch();
  WordApp.ReleaseDispatch(); //释放对象指针。切讎ͼ必须调用

3、RTF文g转html文g

    // 保存html文g [8/12/2013 dell]
    _Application WordApp;
    CoInitialize(NULL);
    if(!WordApp.CreateDispatch("Word.Application",NULL))
    {
        //AfxMessageBox("创徏Word服务p|!");
        exit(1);
        return FALSE;
    }
    WordApp.SetVisible(FALSE);

    COleVariant vTrue((short)TRUE),vFalse((short)FALSE),vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
    CString  m_sImportRtfPath = CCommonFun::GetExecutablePath() + "temp.rtf";
    if (!CFileFind().FindFile(m_sImportRtfPath))
    {
        LOG("转换html文gp|Q没有找到rtf文g Q?nbsp;%s", m_sImportRtfPath);
        return FALSE;
    }
    Documents docs=WordApp.GetDocuments();
    docs.Open(COleVariant(m_sImportRtfPath),
        vFalse,vFalse,vFalse,COleVariant(""),COleVariant(""),
        vFalse,COleVariant(""),COleVariant(""),
        COleVariant((short)0),COleVariant("UTF-8")
        ,vTrue,vFalse,COleVariant((short)0),vFalse,
        COleVariant(""));

    _Document active_doc; 
    active_doc = WordApp.GetActiveDocument();

    active_doc.SaveAs(COleVariant("保存html文g路径"), 
        COleVariant((short)wdFormatHTML),
        vFalse, COleVariant(""),vFalse, COleVariant(""),
        vFalse,vTrue,vFalse,vFalse,vFalse,COleVariant("936"),//COleVariant(L"UTF-8")
        vFalse,vFalse,COleVariant((short)0),vFalse);

    WordApp.Quit(vOpt, vOpt, vOpt);
    active_doc.ReleaseDispatch();
    docs.ReleaseDispatch();
    WordApp.ReleaseDispatch(); //释放对象指针。切讎ͼ必须调用


王v?/a> 2013-08-21 08:53 发表评论
]]>Richedit使用大全http://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202683.html王v?/dc:creator>王v?/author>Wed, 21 Aug 2013 00:42:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202683.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202683.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/21/202683.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202683.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202683.html阅读全文

]]>
MFC讄控g背景透明http://www.shnenglu.com/wanghaiguang/archive/2013/08/18/202616.html王v?/dc:creator>王v?/author>Sun, 18 Aug 2013 08:54:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/08/18/202616.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202616.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/18/202616.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202616.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202616.htmld消息响应WM_CTLCOLORQ?br />Static代码如下Q?/p>

HBRUSH CTest1Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr 
= CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
CFont m_font;   //声明变量
m_font.CreatePointFont(600,"华文行楷"); //讄字体大小和类?/span>
if(pWnd->GetDlgCtrlID()==IDC_STATIC01)//可以?/span>CTLCOLOR_STATIC表示静态控?/span>
{
   pDC
->SelectObject(&m_font);       //讄字体 
   pDC->SetTextColor(RGB(0,0,255)); //讄字体颜色
   pDC->SetBkMode(TRANSPARENT);      //属性设|ؓ透明
   return (HBRUSH)::GetStockObject(NULL_BRUSH); //不返回画?/span>
}
// TODO: Return a different brush if the default is not desired
return hbr;
}

Radio和Check代码如下
HBRUSH CLoginDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    //HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    HBRUSH hbr = ::CreateSolidBrush(#f9f9f9);

    // TODO:  Change any attributes of the DC here

    if (pWnd->GetDlgCtrlID() == IDC_RADIO_REALNAME  ||
        pWnd->GetDlgCtrlID() == IDC_RADIO_ANONYMOUS ||
        pWnd->GetDlgCtrlID() == IDC_CHECK_SELFSELECT)
    {
        pDC->SetBkMode(TRANSPARENT);

        CRect rc;
        pWnd->GetWindowRect(&rc);
        ScreenToClient(&rc);

        CDC* dc = GetDC();
        pDC->BitBlt(0,0,rc.Width(),rc.Height(),dc,rc.left,rc.top,SRCCOPY);    //把父H口背景先画到按钮上
        ReleaseDC(dc);

        hbr = (HBRUSH) ::GetStockObject(NULL_BRUSH);
    }
}

 



]]>
VS2008中docsingl.cpp文g中的ENSURE(strDocName.LoadString(AFX_IDS_UNTITLED))错误 http://www.shnenglu.com/wanghaiguang/archive/2013/08/12/202499.html王v?/dc:creator>王v?/author>Mon, 12 Aug 2013 09:41:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/08/12/202499.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202499.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/08/12/202499.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202499.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202499.htmlMFCE序vs2008~译通过Q运行时出错Q无法打开Q提Cf:\dd\xxxx的docsingl.cpp中的210行,扑ֈ以下代码Q?/span>
void CSingleDocTemplate::SetDefaultTitle(CDocument* pDocument)
{
        CString strDocName;
        if (!GetDocString(strDocName, CDocTemplate::docName) ||
             strDocName.IsEmpty())
        {
                // use generic 'untitled'
                ENSURE(strDocName.LoadString(AFX_IDS_UNTITLED));
        }
     pDocument->SetTitle(strDocName);
}

U色行就是出错地方,原因是资源文件引P一般是从英文或其它语言Ҏ体中文而造成Q把语言相关改ؓ以下几行
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE 4, 2
#pragma code_page(936)
#endif //_WIN32


]]>
MFC判断U程是否存在http://www.shnenglu.com/wanghaiguang/archive/2013/07/31/202258.html王v?/dc:creator>王v?/author>Wed, 31 Jul 2013 03:37:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/07/31/202258.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202258.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/07/31/202258.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202258.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202258.htmlGetExitCodeThread函数是获得线E的退出码Q?/span> 

函数Q?/span> GetExitCodeThread()

功能Q获取一个结束线E的q回?/span>

函数原ŞQ?/span> BOOL GetExitCodeThread( HANDLE hThread, LPDWORD lpExitCode);

参数Q?/span> hThread 指向Ʋ获取返回值的U程对象的句?/span>

               lpExitCode 用于存储U程的返回?/span>

q回|函数执行成功则返回非0|否则q回 0Q?/span>FALSEQ?/span>

W一个参数是U程句柄Q用 CreateThread 创徏U程时获得到?/span>

W二个参数是一?/span> DWORD的指针,用户应该使用一?/span> DWORD cd的变量去接收数据Q返回的数据是线E的退出码Q?/span>
通过U程退出码可以判断U程是否正在q行Q还是已l退出。或者可以判断线E是否是正常退是异帔R出?/span>

执行成功Ӟ存放U程的状态码Q如果是U程的返回|表示U程执行完,  如果U程没执行完Q返?/span>STILL_ACTIVE,如果U程的返回值就?/span>STILL_ACTIVEQ就无法判断  .


MSDN解释:

GetExitCodeThread Function

Retrieves the termination status of the specified thread.

 

BOOL WINAPI GetExitCodeThread(   __in           HANDLE hThread,    __out         LPDWORD lpExitCode ); 

Parameters

hThread

A handle to the thread.

The handle must have the THREAD_QUERY_INFORMATION access right. For more information, see Thread Security and Access Rights.

lpExitCode

A pointer to a variable to receive the thread termination status. If the specified thread has not terminated and the function succeeds, the termination status returned is STILL_ACTIVE.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If the thread has terminated and the function succeeds, the termination status returned may be one of the following:

 

  • The exit value specified in the ExitThread or TerminateThread function.
  • The return value from the thread function.
  • The exit value of the thread's process.

Warning  If a thread happens to return STILL_ACTIVE (259) as an error code, applications that test for this value could end up in an infinite loop.


参考例子:
 1 int main()     
 2 {         
 3     DWORD exitCode1 = 0;     
 4     DWORD exitCode2 = 0;     
 5     DWORD threadId;          
 6   
 7     HANDLE hThrd1 = CreateThread(NULL, 0,   ThreadFunc1, 0, 0, &threadId );  
 9     if (hThrd1)     
10         printf("Thread 1 launched\n");    
11 
13     HANDLE hThrd2 = CreateThread(NULL, 0,  ThreadFunc2, 0, 0, &threadId );     
14     if (hThrd2)     
15         printf("Thread 2 launched\n");    
16 
18     for (;;)      
19     {   
20           printf("Press any key to exit..\n");   
21           getch();   
22           GetExitCodeThread(hThrd1, &exitCode1);   
23           GetExitCodeThread(hThrd2, &exitCode2);   
24           if ( exitCode1 == STILL_ACTIVE )   
25               puts("Thread 1 is still running!");   
26   
27           if ( exitCode2 == STILL_ACTIVE )   
28               puts("Thread 2 is still running!");   
29           if ( exitCode1 != STILL_ACTIVE   && exitCode2 != STILL_ACTIVE )   
30               break;   
31     }   
32   
33     CloseHandle(hThrd1);   
34     CloseHandle(hThrd2);   
35    
36     printf("Thread 1 returned %d\n", exitCode1);   
37     printf("Thread 2 returned %d\n", exitCode2);   
38     return EXIT_SUCCESS;     
39 }    
40   
41 DWORD WINAPI ThreadFunc1(LPVOID n)   
42 {   
43      Sleep((DWORD)n*1000*2);   
44      return (DWORD)n * 10;   
45 } 
46 
48 DWORD WINAPI ThreadFunc2(LPVOID n)   
49 {   
50      Sleep((DWORD)n*1000*2);   
51      return (DWORD)n * 10;   
52 } 


]]>
MFC实现?picture control c,对话框上昄囄http://www.shnenglu.com/wanghaiguang/archive/2013/07/22/202033.html王v?/dc:creator>王v?/author>Mon, 22 Jul 2013 10:09:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/07/22/202033.htmlhttp://www.shnenglu.com/wanghaiguang/comments/202033.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/07/22/202033.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/202033.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/202033.html

以上是源码及演示E序下蝲地址

Q文章原地址 http://www.codeproject.com/Articles/24969/An-MFC-picture-control-to-dynamically-show-pictureQ?/h2>

Introduction 介绍

q篇文章描述的是一个可以用于在对话框上昄各种Lcd囄 (?BMP, GIF, JPEG...) ?/span>MFC控g

Background 背景

我花了一些时间去搜烦可以用于昄囄的MFC控g, 但却没有发现合适的?所以我军_自己做一个轻量Q灵zd高的囄控gQPicture controlQ去昄各种cd的图片?/p>

Using the code 如何使用

q个控g内部使用的是GDI+库,所以请在用时把GdiPlus.lib加入C的工E中Qinclude librariesQ?/span>

使用q个控gӞ先用VC++对话框设计器创徏一个静态文字控Ӟstatic text controlQ?/span> 。之后用MFC向导个控件分配一个控件变量,cd定义为CPictureCtrl?/p>

现在你可以用你的控g装蝲昄囄了,你只需要在q几?code style="color: #990000; font-family: 'Courier New', Courier, mono; font-size: 11pt;">CPictureCtrl::LoadFrom... 函数Q?选择合适你需要的的进行调用。装载后控g会自动更新ƈ昄囄?/p>

要清除掉控g中显C的囄Q调?code style="color: #990000; font-family: 'Courier New', Courier, mono; font-size: 11pt;">CPictureCtrl::FreeImage卛_?/p>

你的囄会被自动调整到控件的大小Q这可能会改变图片原先的长宽比例?/p>

 Collapse | Copy Code
class CPictureCtrl :     
public CStatic
{
public:
   //Constructor
   CPictureCtrl(void);
   //Destructor
   ~CPictureCtrl(void);

public:
   //Loads an image from a file
   BOOL LoadFromFile(CString &szFilePath);
   //Loads an image from an IStream interface
   BOOL LoadFromStream(IStream* piStream);
   //Loads an image from a byte stream;
   BOOL LoadFromStream(BYTE* pData, size_t nSize);
   //Loads an image from a Resource
   // BOOL LoadFromResource(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
   //Overload - Single load function
   BOOL Load(CString &szFilePath);
   BOOL Load(IStream* piStream);
   BOOL Load(BYTE* pData, size_t nSize);
   // BOOL Load(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
   //Frees the image data
   void FreeData();

protected:
   virtual void PreSubclassWindow();
   //Draws the Control
   virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
   virtual BOOL OnEraseBkgnd(CDC* pDC);

private:
   //Internal image stream buffer
   IStream* m_pStream;
   //Control flag if a pic is loaded
   BOOL m_bIsPicLoaded;
   //GDI Plus Token
   ULONG_PTR m_gdiplusToken; };

Points of interest

q个控g是基?nbsp;CStatic control 设计的(基类使用的是CStaticQ?/span>。所以你可以使用CStatic control的各U功?/span>Q但它ƈ不会昄M文字。对GDI+库的使用使其可以支持各种Lcd的图片?/span>

History 历史

  • 1.0 - Initial release.
  • 1.1 - A bug when drawing the control without a loaded image was corrected.
  • 1.2 - A bug when drawing the control was corrected.

    Loading an image from a resource is disabled due to problems recognizing it correctly as an image.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

TEiseler

Tester / Quality Assurance

Germany Germany

Member
 

本文转自Q?a style="font-family: verdana, 'courier new'; line-height: 21px;">http://blog.csdn.net/cashey1991/article/details/7516996

]]>
动态创图时?AfxCheckDialogTemplate执行出错http://www.shnenglu.com/wanghaiguang/archive/2013/05/31/200722.html王v?/dc:creator>王v?/author>Fri, 31 May 2013 09:02:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/05/31/200722.htmlhttp://www.shnenglu.com/wanghaiguang/comments/200722.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/05/31/200722.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/200722.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/200722.html

动态创图时?/span> AfxCheckDialogTemplate执行出错

?/span>mfc?/span>sdi架构中,准备多做几个视图Q试囄l承?/span>formviewQ但在动态创囄时候出了错误,AfxCheckDialogTemplate执行出错。后来通过搜烦发现cformviewcd联对话框时候,资源必须具备child属性?/span>

1.CFormViewcd联的对话框资源必d?/span>Child属性?/span>

?/span>CFormViewz的类Q可以关联一个对话框资源。但该对话框资源必须在属性设定中Style选定[Child]属性,否则的话Q?/span>
代码可以~译Q但Debugq行会报告一个断a错误Q跟t代码,断言在:

#ifdef _DEBUG

    // dialog template must exist and be invisible with WS_CHILD set
    if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
    {
        ASSERT(FALSE);          // invalid dialog template name
        PostNcDestroy();        // cleanup if Create fails too soon
        return FALSE;
    }

#endif //_DEBUG

2.CFormView比较ҎQ是一个父H体嵌套了一个子H体Q所以,
CFormViewcȝzcȝ实例不响?/span>WM_CLOSE消息Q仅仅响?/span>WM_DESTROY消息?/span>
另外Q若要用代码关闭当前View,也不能直接:PostMessage(WM_CLOSE,0,0);
而必d获取父窗体的指针Q然后对父窗体发?/span>WM_CLOSE消息才行Q像q样Q?/span>
GetParent()-&gt;PostMessage(WM_CLOSE,0,0);
才能够达到目的?/span>
《深入浅?/span>MFC》第八章4618-1清楚地说明了q种情况Q?/span>ViewH口?/span>CChildFrameH口的子H口?/span>



]]>
MFC拖动无标题窗?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/05/30/200689.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Thu, 30 May 2013 00:35:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/05/30/200689.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/200689.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/05/30/200689.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/200689.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/200689.html</trackback:ping><description><![CDATA[拖动无标题的H口可以重蝲<span style="color: #333333; font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px; white-space: pre-wrap;"></span><span style="color: #333333; font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px; white-space: pre-wrap;">WM_LBUTTONDOWNQ添加如下代码:</span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->SendMessage(WM_SYSCOMMAND,0xF012,0);</div> ?br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->PostMessage (WM_NCLBUTTONDOWN , HTCAPTION , MAKELPARAM(point.x , point. y ));</div><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/200689.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-05-30 08:35 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/05/30/200689.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC讄透明?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200672.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Wed, 29 May 2013 03:18:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200672.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/200672.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200672.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/200672.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/200672.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; font-size: 12pt;">代码CZQ?/span><br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000ff; font-family: Verdana;">#define</span><span style="font-family: Verdana;"> LWA_COLORKEY 0x00000001         </span><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">方式</span><br /><span style="color: #0000ff; font-family: Verdana;">#define</span><span style="font-family: Verdana;"> WS_EX_LAYERED 0x00080000 </span><br /><br /><span style="font-family: Verdana;">typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); </span><br /><span style="font-family: Verdana;">lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes; </span><br /><br /><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">讄成边~透明 </span><br /><span style="font-family: Verdana;">COLORREF maskColor=#000000;</span><br /><br /><span style="font-family: Verdana;">HMODULE hUser32 = GetModuleHandle("user32.dll"); </span><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">加蝲动态链接库</span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">SetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,"SetLayeredWindowAttributes"); </span><br /><br /><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">取得SetLayeredWindowAttributes函数指针 </span><br /><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">为窗口加入WS_EX_LAYERED扩展属?/span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">SetWindowLong(</span><span style="color: #0000ff; font-family: Verdana;">this</span><span style="font-family: Verdana;">->GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE)^WS_EX_LAYERED); </span><br /><br /><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">调用SetLayeredWinowAttributes函数</span><span style="color: #008000; "><br /></span><span style="font-family: Verdana;">SetLayeredWindowAttributes(</span><span style="color: #0000ff; font-family: Verdana;">this</span><span style="font-family: Verdana;">->GetSafeHwnd(), maskColor, 192, LWA_COLORKEY); </span><br /><br /><span style="font-family: Verdana;">FreeLibrary(hUser32);   </span><span style="color: #008000; font-family: Verdana;">//</span><span style="color: #008000; font-family: Verdana;">释放动态链接库</span></div><br /><span times="" new="" roman";="" mso-hansi-font-family:"="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">以上代码加入</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;">OnInitDialog()</span><span times="" new="" roman";mso-hansi-font-family:"="" roman";="" color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">中,其中</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;"> SetLayeredWindowAttributes(this->GetSafeHwnd(), maskColor, 192, LWA_COLORKEY); </span><span times="" new="" roman";="" mso-hansi-font-family:"="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">里,</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;">maskColor</span><span times="" new="" roman";mso-hansi-font-family:"="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">为将q行透明处理的颜Ԍ</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;"> 192</span><span times="" new="" roman";mso-hansi-font-family:"="" roman";="" color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">为透明度,</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;"> LWA_COLORKEY</span><span times="" new="" roman";""="" "="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">为透明方式?/span><span style="line-height: 25px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ffffff;"><br /><br /></span><span times="" new="" roman";="" mso-hansi-font-family:"="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">若要透明整个对话框,?/span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;">LWA_COLORKEY=2;<br /></span><span times="" new="" roman";="" mso-hansi-font-family:"="" roman";color:black;"="" style="line-height: 25px; color: #333333; background-color: #ffffff; font-family: Verdana; font-size: 12pt;">若要寚w定颜色透明Q则</span><span style="line-height: 25px; font-family: Verdana; background-color: #ffffff; font-size: 12pt;">LWA_COLORKEY=1;</span><br />   <br /><span style="font-family: Verdana; font-size: 12pt;">本文转自Q?/span><a ><span style="font-family: Verdana; font-size: 12pt;">http://chenjiuliang.blog.163.com/blog/static/36572155201151735735374/</span></a><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/200672.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-05-29 11:18 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200672.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC讄对话框背景图?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200671.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Wed, 29 May 2013 03:02:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200671.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/200671.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200671.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/200671.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/200671.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; font-size: 12pt;">1、导入Bitmap资源囄Q?/span><br /><span style="font-family: Verdana; font-size: 12pt;">2、重载WM_PAINT ——></span><span style="color: #454545; font-family: Verdana; background-color: #ffffff; font-size: 12pt;">void CXXXDlg::OnPaint()<br /></span><span style="font-family: Verdana; font-size: 12pt;">3、添加如下代码:<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->    CRect   rect;   <br />    GetClientRect(&rect);   <br />    CDC   dcMem;   <br />    dcMem.CreateCompatibleDC(&dc);   <br />    CBitmap   bmpBackground;   <br />    bmpBackground.LoadBitmap(IDB_BITMAP_TOOL);   <span style="color: #008000; ">//</span><span style="color: #008000; ">IDB_BITMAP_TOOL是你自己的图对应的ID </span><span style="color: #008000; "><br /></span><br />    BITMAP   bitmap;   <br />    bmpBackground.GetBitmap(&bitmap);   <br />    CBitmap   *pbmpOld=dcMem.SelectObject(&bmpBackground);   <br />    dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,   <br />        bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);   </div><span style="font-family: Verdana; font-size: 12pt;"><br />其他ҎQ?br />重写WM_ERASEBKGND消息<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->BOOL CxxDialog::OnEraseBkgnd(CDC* pDC) <br />{<br />   <span style="color: #008000; ">//</span><span style="color: #008000; "> CDialog::OnEraseBkgnd(pDC);</span><span style="color: #008000; ">//</span><span style="color: #008000; ">忘记要不要执行父cȝq个?</span><span style="color: #008000; "><br /></span>    CDC  memdc;<br />    memdc.CreateCompatibleDC(pDC);<br />    CBitmap bmp;<br />    CBitmap *pOldBmp;<br />    BITMAP bm;<span style="color: #008000; ">//</span><span style="color: #008000; ">用来保存囄的长宽等信息</span><span style="color: #008000; "><br /></span><br />    bmp.LoadBitmap(IDB_BITMAP1);<br />    bmp.GetBitmap(&bm);<br /><br />    <span style="color: #008000; ">//</span><span style="color: #008000; ">图片选进~冲?/span><span style="color: #008000; "><br /></span>    pOldBmp = (CBitmap *)memdc.SelectObject(&bmp);<br /><br />    <span style="color: #008000; ">//</span><span style="color: #008000; ">如果囄跟对话框的客户区一样大Q直接用BitBlt可?br />    </span><span style="color: #008000; ">//</span><span style="color: #008000; ">pDC->BitBlt(0, 0, rcWnd.Width(), rcWnd.Height(), &memdc, 0, 0, SRCCOPY);<br /><br />    </span><span style="color: #008000; ">//</span><span style="color: #008000; ">如果囄比对话框的背景小Q就要用StrechBlt来拉伸图?/span><span style="color: #008000; "><br /></span>    pDC->StrechBlt(0, 0, rcWnd.Width, rcWnd.Height(), &memdc, 0, 0, bm.bmWidth,bm.bmHeight, SRCCOPY);<br /><br />   <span style="color: #008000; ">//</span><span style="color: #008000; ">释放DC</span><span style="color: #008000; "><br /></span>    memdc.SelectObject(pOldBmp);<br />    memdc.DeleteDC();<br /><br />    <span style="color: #0000FF; ">return</span> TRUE; <br />}</div><span style="font-family: Verdana; font-size: 12pt;"><br />其他ҎQ?/span><a >http://blog.csdn.net/ply421600/article/details/6692967</a><span style="font-family: Verdana; font-size: 12pt;"><br /></span><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/200671.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-05-29 11:02 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/05/29/200671.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Base64~解?C++?http://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198626.html王v?/dc:creator>王v?/author>Wed, 20 Mar 2013 06:00:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198626.htmlhttp://www.shnenglu.com/wanghaiguang/comments/198626.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198626.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/198626.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/198626.html
#include <string>
using namespace std;

class ZBase64
{
public:
    /*~码
    DataByte
        [in]输入的数据长?以字节ؓ单位
    
*/
    string Encode(const unsigned char* Data,int DataByte);
    /*解码
    DataByte
        [in]输入的数据长?以字节ؓ单位
    OutByte
        [out]输出的数据长?以字节ؓ单位,请不要通过q回D?br />        输出数据的长?br />    
*/
    string Decode(const char* Data,int DataByte,int& OutByte);
};

.cpp文gQ?br />
#include "stdAfx.h"
#include "ZBase64.h"

string ZBase64::Encode(const unsigned char* Data,int DataByte)
{
    //~码?/span>
    const char EncodeTable[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    //q回?/span>
    string strEncode;
    unsigned char Tmp[4]={0};
    int LineLength=0;
    for(int i=0;i<(int)(DataByte / 3);i++)
    {
        Tmp[1] = *Data++;
        Tmp[2] = *Data++;
        Tmp[3] = *Data++;
        strEncode+= EncodeTable[Tmp[1] >> 2];
        strEncode+= EncodeTable[((Tmp[1] << 4) | (Tmp[2] >> 4)) & 0x3F];
        strEncode+= EncodeTable[((Tmp[2] << 2) | (Tmp[3] >> 6)) & 0x3F];
        strEncode+= EncodeTable[Tmp[3] & 0x3F];
        if(LineLength+=4,LineLength==76) {strEncode+="\r\n";LineLength=0;}
    }
    //对剩余数据进行编?/span>
    int Mod=DataByte % 3;
    if(Mod==1)
    {
        Tmp[1] = *Data++;
        strEncode+= EncodeTable[(Tmp[1] & 0xFC) >> 2];
        strEncode+= EncodeTable[((Tmp[1] & 0x03) << 4)];
        strEncode+= "==";
    }
    else if(Mod==2)
    {
        Tmp[1] = *Data++;
        Tmp[2] = *Data++;
        strEncode+= EncodeTable[(Tmp[1] & 0xFC) >> 2];
        strEncode+= EncodeTable[((Tmp[1] & 0x03) << 4) | ((Tmp[2] & 0xF0) >> 4)];
        strEncode+= EncodeTable[((Tmp[2] & 0x0F) << 2)];
        strEncode+= "=";
    }
    
    return strEncode;
}

string ZBase64::Decode(const char* Data,int DataByte,int& OutByte)
{
    //解码?/span>
    const char DecodeTable[] =
    {
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// '+'
, 0, 0,
// '/'
, 53, 54, 55, 56, 57, 58, 59, 60, 61, // '0'-'9'
, 0, 0, 0, 0, 0, 0,
, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 'A'-'Z'
, 0, 0, 0, 0, 0,
, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // 'a'-'z'
    };
    //q回?/span>
    string strDecode;
    int nValue;
    int i= 0;
    while (i < DataByte)
    {
        if (*Data != '\r' && *Data!='\n')
        {
            nValue = DecodeTable[*Data++] << 18;
            nValue += DecodeTable[*Data++] << 12;
            strDecode+=(nValue & 0x00FF0000) >> 16;
            OutByte++;
            if (*Data != '=')
            {
                nValue += DecodeTable[*Data++] << 6;
                strDecode+=(nValue & 0x0000FF00) >> 8;
                OutByte++;
                if (*Data != '=')
                {
                    nValue += DecodeTable[*Data++];
                    strDecode+=nValue & 0x000000FF;
                    OutByte++;
                }
            }
            i += 4;
        }
        else// 回R换行,跌
        {
            Data++;
            i++;
        }
     }
    return strDecode;
}

使用CZQ结合CxImage库)Q?/span>
CString CScanDlg::EncodeImage()
{//对图片进行Base64~码
    ZBase64 zBase;
    //囄~码
    CxImage  image;   // 定义一个CxImage对象    
    image.Load(this->m_strImgPath, CXIMAGE_FORMAT_JPG);   //先装载jpg文g,需要指定文件类?/span>
    long size=0;//得到囑փ大小
    BYTE* buffer=0;//存储囑փ数据的缓?/span>
    image.Encode(buffer,size,CXIMAGE_FORMAT_JPG);//把image对象中的囑փ以typecd数据copy到buffer
    string strTmpResult=zBase.Encode(buffer,size);
    CString result;
    result = strTmpResult.c_str();
    return result;
}

void CScanDlg::DecodeImageData(CString strData)
{//对Base64~码q的数据解码q显C原囄

    ZBase64 zBase;
    int OutByte=0;
    string strTmpResult=zBase.Decode(strData,strData.GetLength(),OutByte);
    int i,len = strTmpResult.length();
    BYTE *buffer = new BYTE[len];
    for (i=0;i<len;++i)
    {
        buffer[i] = strTmpResult[i];
    }
    CxImage image(buffer,len,CXIMAGE_FORMAT_JPG);//把内存缓冲buffer中的数据构造成Image对象
    delete [] buffer;
    CDC* hdc = m_picture.GetDC();
    m_bitmap = image.MakeBitmap(hdc->m_hDC);
    HBITMAP h0ldBmp = m_picture.SetBitmap(m_bitmap);
    if(h0ldBmp) DeleteObject(h0ldBmp);
    if(hdc->m_hDC) m_picture.ReleaseDC(hdc);
    if(m_bitmap) DeleteObject(m_bitmap);
}

本文转自Qhttp://www.cnblogs.com/phinecos/archive/2008/10/10/1308272.html

]]>
VS2008打开资源文g时显C没有安装q个ActiveX控g "{648A5600-2C6E-101B-82B6-000000000014http://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198617.html王v?/dc:creator>王v?/author>Wed, 20 Mar 2013 02:23:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198617.htmlhttp://www.shnenglu.com/wanghaiguang/comments/198617.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/03/20/198617.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/198617.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/198617.html手动注册Q?/strong>

      大家知道Q当我们安装VC++6.0/VB6.0Ӟ如果选择了ACtiveX控g(自定义安装)QMSComm控g׃自动安装在计机上了Qƈ在系l文件夹下多?个文ӞMscomm.srg, Mscomm32.ocx,Mscomm32.dep

  注意Q操作系l不同,则系l文件夹不同Q?/span>
       Win98:    windows/system
       Win2000:  winnt/system32

     那么用了MSComm控g的程序在发布时或者在VS2008开发环境下如何来注册MSComm控g呢?发布E序时可以用安装E序Q我们这里不介绍Q只谈谈如何手工来注册安装MSComm控g?/span>

 

  W一步:Mscomm.srg, Mscomm32.ocx,Mscomm32.dep三个文g复制到系l文件夹中。要注意的是QMSComm控g是要授权的,所以必d其?#8220;执照”Licence 在注册表中登记注册,下一步就是注册方法。至于ؓ什么要q样做,可以看看下面的网:http://support.microsoft.com/support/kb/articles/q151/7/71.asp

  

  W二步:用Windows下的注册工具regsvr32注册该OCX控gQ点?#8220;开?#8221;->"q行"Q再在中填入Q假设操作安装在C盘,WIN2000Q:

      Regsvr32  C:\winnt\system32\Mscomm32.ocx

 

    W三步:在注册表中手工新Z个主键项Q先在点?#8220;开?#8221;->"q行"Q再在中填入regedit命o打开注册表,扑ֈHKEY_CLASSES_ROOT\LicensesQ在其中d主键
4250E830-6AC2-11cf-8ADB-00AA00C00905 q将内容讄为:

       kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun

   Q注Q这内容也可以用记事本E序打开Mscomm.srg文g看到Q?/span>

 

  在VCQ包括VC.NETQ中应用Q我已经介绍多次了,q里再说说在Delphi中的应用Q进入Delphi环境中,选择菜单命oQComponent->Import ActiveX Control,在列表中可以看到Microsoft Comm ControlQversion 6.0, 选中后点击Install按钮,完成安装。在ActiveX控g上可以看到MSComm控g的电话图标?br />
以上转自Q?/span>http://www.gjwtech.com/scomm/manaualregistermscomm.htm


自动注册Q?/strong>
     
      q行附g中的“注册.cmd”完成自动注册 MSComm控g?/span>  MSComm
       



]]>
VS2008 下error PRJ0003 : Error spawning 'cmd.exe'的解x?/title><link>http://www.shnenglu.com/wanghaiguang/archive/2013/03/07/198255.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Thu, 07 Mar 2013 02:49:00 GMT</pubDate><guid>http://www.shnenglu.com/wanghaiguang/archive/2013/03/07/198255.html</guid><wfw:comment>http://www.shnenglu.com/wanghaiguang/comments/198255.html</wfw:comment><comments>http://www.shnenglu.com/wanghaiguang/archive/2013/03/07/198255.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/wanghaiguang/comments/commentRss/198255.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/wanghaiguang/services/trackbacks/198255.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-indent: 20px; background-color: #ffffff;"></span><span style="font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px; background-color: #ffffff; color: #0000ff;">Ҏ1Q?br /></span><span style="font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px; background-color: #ffffff;"><br /></span><span style="font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px; background-color: #ffffff;">In the Options go into Projects and Solutions -> VC++ Directories page and place this rows:<br /><br /></span><span style="font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px; background-color: #ffffff;">$(SystemRoot)\System32<br /></span><span style="background-color: #ffffff; font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px;">$(SystemRoot)<br /></span><span style="background-color: #ffffff; font-family: Verdana; font-size: 12pt; line-height: 19px; text-indent: 20px;">$(SystemRoot)\System32\wbem<br /></span><span style="background-color: #ffffff; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-indent: 20px;"><br /></span><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">适用VC8的各U工E项目(包括Ud讑֤的项目)Q如果在加了以后q出现这L错误提示Q将上面的三句删除掉Q重新加一ơ就可以?br /><br /></span><span style="font-size: 12pt; font-family: Verdana; color: #0000ff;">Ҏ2Q?/span><br /><br /><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">在Visual Studio中,选择工具->选项->工程和解x?>VC++目录 </span><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">点击上方的像文g夹的按钮-新徏行,然后在空白处dcmd.exe所在的目录C:\Windows\System32\ Q如果你是默认装在C盘的话)点击定Q就OK了?nbsp;</span><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">In VS, go to </span><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">tools>options>projects and solutions>VC++ Directories </span><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; background-color: #ffffff;" /><span style="font-family: Verdana; font-size: 12pt; line-height: 16px; background-color: #ffffff;">click the little folder button (new line) then in the new line that appears put: <br /><br /></span><span style="font-size: 12pt; font-family: Verdana;">本文转自Q?/span><span style="font-size: 12pt; font-family: Verdana;">http://www.shnenglu.com/zhangyq/archive/2009/02/16/73940.html</span><img src ="http://www.shnenglu.com/wanghaiguang/aggbug/198255.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2013-03-07 10:49 <a href="http://www.shnenglu.com/wanghaiguang/archive/2013/03/07/198255.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC网l连接和ping IP地址http://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198157.html王v?/dc:creator>王v?/author>Fri, 01 Mar 2013 07:51:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198157.htmlhttp://www.shnenglu.com/wanghaiguang/comments/198157.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198157.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/198157.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/198157.html代码CZQ?br />
#include <Sensapi.h>
#pragma comment(lib, "Sensapi.lib")
BOOL CheckNetIsOK(const CString sUpdateIP)
{
    //Judge Network is Connected
    int nCount = 1;
    do 
    {
        DWORD dw;
        if( IsNetworkAlive(&dw))
        {
            break;
        }
        else
        {
            Sleep(10000);
            CString sNetWorkConnect;
            sNetWorkConnect.Format("W?dơ网l未成功q接, 10U后重试", nCount);
            m_recvCtrl.SetWindowText(sNetWorkConnect);
            nCount++ ;
        }
    } while (nCount <4);

    if (nCount == 4)
    {
        m_recvCtrl.SetWindowText("|络q接p|, 共检?0U?);
        return FALSE;
    }

    DWORD n = CCommonFun::WinExecAndWait32(_T("ping.exe"), sUpdateIP + " -n 2"/*sCmdPara*/, NULL, 10000);
    if (n == 0)
    {
        return TRUE;
    }
    else
    {
        CString sNetWorkConnect;
        sNetWorkConnect.Format("|络q接正常, Ping:%s p|, h此IP对应的服务器是否正常工作", sUpdateIP);
        m_recvCtrl.SetWindowText(sNetWorkConnect);
        return FALSE;
    }
}



]]>
MFC CEdit昄q加信息http://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198156.html王v?/dc:creator>王v?/author>Fri, 01 Mar 2013 07:50:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198156.htmlhttp://www.shnenglu.com/wanghaiguang/comments/198156.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/03/01/198156.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/198156.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/198156.html
    int LineNum=m_recvCtrl.GetLineCount();
    if(LineNum > 100)                                // 过最大信息显C?/span>
    {
        m_recvCtrl.SetSel(0, -1);
        m_recvCtrl.Clear();                            // 清空~辑?/span>
    }    

    CTime RevTime = CTime::GetCurrentTime();
    CString Temp = RevTime.Format("[%Y/%m/%d %H:%M:%S]: ");

    CString strEdit;    
    m_recvCtrl.GetWindowText(strEdit);   
    m_recvCtrl.SetSel(strEdit.GetLength(), strEdit.GetLength());  
    m_recvCtrl.ReplaceSel(Temp + sText + "\n");


]]>
查找CString里面出现某个字符的次?http://www.shnenglu.com/wanghaiguang/archive/2013/02/19/197935.html王v?/dc:creator>王v?/author>Tue, 19 Feb 2013 06:34:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/02/19/197935.htmlhttp://www.shnenglu.com/wanghaiguang/comments/197935.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/02/19/197935.html#Feedback1http://www.shnenglu.com/wanghaiguang/comments/commentRss/197935.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/197935.html1?/span>Replace函数替换查找

Replace函数q回|q回被替换的字符数。如果这个字W串没有改变则返回零?/span>

CString sTest="aabbccaadd";
int nCount=s.Replace("a","a");

nCount
是你的惌的?br />
CString::Replace
int Replace( TCHAR chOld, TCHAR chNew );
int Replace( LPCTSTR lpszOld, LPCTSTR lpszNew );

Return Value
The number of replaced instances of the character. Zero if the string isn't changed.


2?/span>标准函数 count_if

#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

int main( void )
{
    const string a = " 12113";
    cout << count_if( a.begin(), a.end(), bind2nd(equal_to<char>(),'1') ) << endl;

    return 0;
}

CString也一P但它没有标准的P代器Q因此需要写?/span>
count_if( (LPCTSTR)a, (LPCTSTR)a+a.GetLength(), bind2nd(equal_to<TCHAR>(),_T('某字W?)) )

]]>
MFC获取盘I间信息http://www.shnenglu.com/wanghaiguang/archive/2013/01/16/197324.html王v?/dc:creator>王v?/author>Wed, 16 Jan 2013 09:00:00 GMThttp://www.shnenglu.com/wanghaiguang/archive/2013/01/16/197324.htmlhttp://www.shnenglu.com/wanghaiguang/comments/197324.htmlhttp://www.shnenglu.com/wanghaiguang/archive/2013/01/16/197324.html#Feedback0http://www.shnenglu.com/wanghaiguang/comments/commentRss/197324.htmlhttp://www.shnenglu.com/wanghaiguang/services/trackbacks/197324.htmlCZ代码Q?/span>
DWORD CCommonFun::GetDesignatedDiskFreeSpace(const CString &szPath)
{
    DWORD dwTotalDiskSpace,dwFreeDiskSpace,dwUsedDiskSpace;    

    ULARGE_INTEGER uiFreeBytesAvailableToCaller;
    ULARGE_INTEGER uiTotalNumberOfBytes;
    ULARGE_INTEGER uiTotalNumberOfFreeBytes;

    if(GetDiskFreeSpaceEx(szPath, &uiFreeBytesAvailableToCaller,
        &uiTotalNumberOfBytes,
        &uiTotalNumberOfFreeBytes))
    {
        dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
        dwFreeDiskSpace  = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
        dwUsedDiskSpace     = dwTotalDiskSpace - dwFreeDiskSpace;
        TRACE("盘%s::ȝ?dMB, 已用%dMB, 可用%dMB\n", szPath,
            dwTotalDiskSpace, dwUsedDiskSpace, dwFreeDiskSpace);

        return dwFreeDiskSpace;
    }

    return -1;
}


]]>
aëƬþѲ| ۺþþ| þùƷƷ| þֹƷۺ| þۺƵվ| һɫþۺ޾Ʒ| ޡvþþ뾫Ʒ| ɫ͵͵888ŷƷþþ| þ99Ʒþþþþ9| ĻӰӾþþ| 18պҹþó| þ99Ʒ| þþþùɫAVѿͼƬ| AVþþƷ | ޹þþþƷ| 91þùۺϾƷ| 99þùۺϾƷˮ | þseֻоƷ| þþƷһ| Ʒþþþ9999| þþþֻоƷ | þþƷ99þ㽶| þþþþAŷAV| þþþþAVר| þþƷ޾Ʒŷ| ŷ޳ҹƷþ | þþҹƷ| þ91ۺϹ91þþƷ| ĻӰӾþþѹۿ| þþƷƷ޾Ʒ| ˾ƷۺϾþþ| þþƷƷ | 2020¾þþӾƷ | ѾƷþþþþĻ| þùѾƷ| Ʒþþþa| Ʒŷ޺ձþ| þþŷղ| ŷ޾Ʒ˾þԻӰƬ| Ʒ99þþþþö | þҹӰ|