正在阅读:实用!超强VC/MFC 常见问答收集实用!超强VC/MFC 常见问答收集

2004-07-15 10:04 出处:CSDN 作者:jiangsheng收集 责任编辑:linjixiong


COleStreamFile osfRead;
    osfRead.Attach(pStream);
    long lLength=osfRead.GetLength();
    CByteArray baBuf;
    baBuf.SetSize(lLength);
    osfRead.Read(baBuf.GetData(),lLength);



  问:我Create了一个ListControl用来显示文件列表?怎么实现有图标的文件显示阿?
  答:SHGetFileInfo可以返回系统图像列表,里面包含每一种文件类型的图标。参见http://www.csdn.net/develop/read_article.asp?id=22243
  问题:如何编写无界面的HTML解析器?
  答:walkall示例就是一个无界面的HTML解析器。
http://msdn.microsoft.com/downloads/samples/internet/browser/walkall/default.asp
  问:用AfxBeginThread创建的线程除了调用AfxEndThread还可以用什么函数关闭?
  答:
  可以从外部用事件通知来优雅地结束线程
  启动线程
m_pThreadWrite=AfxBeginThread(ThreadProc,(LPVOID)this);
线程体。为了避免在静态函数中引用对象指针的麻烦,调用对象参数的线程体成员函数。


UINT CMyClass::ThreadProc(LPVOID lp)
{
CMicrophoneInput* pInput=(CMicrophoneInput*)lp;
return pInput->Run();
}
  简单的循环检测退出标志
UINT CMyClass::Run()
{
HRESULT hr;
if(!InitInstance()){
TRACE("InitInstance failed\r\n";
return ExitInstance();
}
while(!IsKilling()){
//do something
}
return ExitInstance();
}
  重设退出标志
BOOL CMyClass::InitInstance()
{
m_eventKill.ResetEvent();
m_eventDead.ResetEvent();
//do something
return TRUE
}
  设已退出标志
UINT CMyClass::ExitInstance()
{
//do something
m_eventDead.SetEvent();
return 0;
}


 


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品