??xml version="1.0" encoding="utf-8" standalone="yes"?>国产一区二区三区黄视频,国产精品久久国产愉拍,在线观看亚洲专区http://www.shnenglu.com/aaxron/category/15296.html记录修行的印? zh-cnThu, 18 May 2017 07:06:27 GMTThu, 18 May 2017 07:06:27 GMT60MoveWindow() SetWindowPos()的区别与联系http://www.shnenglu.com/aaxron/archive/2017/05/17/214944.html天下天下Wed, 17 May 2017 10:56:00 GMThttp://www.shnenglu.com/aaxron/archive/2017/05/17/214944.htmlhttp://www.shnenglu.com/aaxron/comments/214944.htmlhttp://www.shnenglu.com/aaxron/archive/2017/05/17/214944.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/214944.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/214944.htmlMoveWindow() SetWindowPos()的区别与联系
转自http://www.cnblogs.com/songliquan/p/3359002.html

先看MoveWindow()函数Q用于改变窗口的位置和尺寸,对于层H口Q按照屏q对齐与左上角,对于子窗口,则对齐与父窗口的左上角?br />
BOOL MoveWindow( HWND hWnd,
int x, int y, int nWidth, int nHeight,BOOL bRepaint = TRUE);
参数hWnd表示H口句柄Q?br />参数x,y表示H口的左上角LQ?br />参数nwidthQnHeight 表示H口高度和宽度;
最后一个bRepaint表示是否立即重绘。ؓtrue时系l会立即发送WM_PAINT到窗口程序(会调用UpdateWindow()函数Q,为false时不会发生Q何类型的重绘操作?br />
MoveWindow会给H口发送WM_WINDOWPOSCHANGINGQWM_WINDOWPOSCHANGEDQWM_MOVEQWM_SIZE和WM_NCCALCSIZE消息?br />
接下来看SetWindowPos(),q个函数同样用来实现H口Ud操作Q只不过功能更多一炏V?br />
BOOL SetWindowPos(HWND hWnd,
const CWnd* pWndInsertAfter, int x, int y,int cx, int cy, UINT nFlags);
W一个参数是H口句柄Q?br />W二个参数是H口的Z orderQ就是有多个H口Ӟ本窗口显C的序Q最上面或者最下面Q可选参数有:HWND_BOTTOM,HWND_NOTOPMOST,HWND_TOP,HWND_TOPMOST.
HWND_BOTTOMQ将H口|于Z序的底部。如果参数hWnd标识了一个顶层窗口,则窗口失去顶U位|,q且被置在其他窗口的底部?nbsp;    
HWND_NOTOPMOSTQ将H口|于所有非层H口之上Q即在所有顶层窗口之后)。如果窗口已l是非顶层窗口则该标志不起作用?nbsp;    
HWND_TOP:窗口置于Z序的剙?nbsp;    
HWND_TOPMOST:窗口置于所有非层H口之上。即使窗口未被激zȝ口也保持顶U位|?nbsp;
接下来四个参数是H口的位|和寸?br />最后一个参数nFlags是窗口显C方式的标志Q这个参数很多,可以l合使用Q详l如下:
SWP_ASNCWINDOWPOSQ如果调用进E不拥有H口Q系l会向拥有窗口的U程发出需求。这防止调用线E在其他U程处理需求的时候发生死锁?nbsp;   
SWP_DEFERERASEQ防止生WM_SYNCPAINT消息?nbsp;   
SWP_DRAWFRAMEQ在H口周围M个边框(定义在窗口类描述中)?nbsp;   
SWP_FRAMECHANGEDQ给H口发送WM_NCCALCSIZE消息Q即使窗口尺寸没有改变也会发送该消息。如果未指定q个标志Q只有在改变了窗口尺寸时才发送WM_NCCALCSIZE?nbsp;
SWP_HIDEWINDOW;隐藏H口?nbsp;
SWP_NOACTIVATEQ不Ȁzȝ口。如果未讄标志Q则H口被激z,q被讄到其他最高H口或非最高l的剙Q根据参数hWndlnsertAfter讄Q?nbsp;
SWP_NOCOPYBITSQ清除客户区的所有内宏V如果未讄该标志,客户区的有效内容被保存ƈ且在H口寸更新和重定位后拷贝回客户区?nbsp;
SWP_NOMOVEQ维持当前位|(忽略X和Y参数Q?nbsp;   
SWP_NOOWNERZORDERQ不改变z序中的所有者窗口的位置?nbsp;
SWP_NOREDRAW:不重L变的内容。如果设|了q个标志Q则不发生Q何重d作。适用于客户区和非客户区(包括标题栏和滚动条)和Q何由于窗回移动而露出的父窗口的所有部分。如果设|了q个标志Q应用程序必L地使窗口无效ƈ重画H口的Q何部分和父窗口需要重ȝ部分?nbsp;
SWP_NOREPOSITIONQ与SWP_NOOWNERZORDER标志相同?nbsp;     SWP_NOSENDCHANGINGQ防止窗口接收WM_WINDOWPOSCHANGING消息?nbsp;
SWP_NOSIZEQ维持当前尺寸(忽略cx和Cy参数Q?nbsp;
SWP_NOZORDERQ维持当前Z序(忽略hWndlnsertAfter参数Q?nbsp;
SWP_SHOWWINDOWQ显C窗口?br />注意事项Q?br />使用SetWindowPos()如果讄了SWP_SHOWWINDOWS或者SWP_HIDEWINDOWQ那么窗口将不能被移动和改变大小Q我使用时就是设|了SWP_SHOWWINDOW,从而导致不能重l背景?br />
两者的比较Q?br />两者都能实现移动和改变H口大小?br />
MoveWindow()功能比较单一Q只能移动和改变H口大小Q而SetWindowPos()可以讄更多的参敎ͼ实现Zorder及显C方式标志?br />
MoveWindow()发送WM_WINDOWPOSCHANGINGQWM_WINDOWPOSCHANGEDQWM_MOVEQWM_SIZE和WM_NCCALCSIZE{消息到H口QSetWindowPos()只发送WM_WINDOWPOSCHANGED消息到窗口。所以说如果需要发送更多消息时q是使用MoveWindow()的好?/span>

天下 2017-05-17 18:56 发表评论
]]>
Xtreme ToolKit 日志控ghttp://www.shnenglu.com/aaxron/archive/2017/05/16/214936.html天下天下Tue, 16 May 2017 03:06:00 GMThttp://www.shnenglu.com/aaxron/archive/2017/05/16/214936.htmlhttp://www.shnenglu.com/aaxron/comments/214936.htmlhttp://www.shnenglu.com/aaxron/archive/2017/05/16/214936.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/214936.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/214936.html

/Files/aaxron/OppoTestX.rar

天下 2017-05-16 11:06 发表评论
]]>
[转]VC中常用的文档c,视图c,框架c,应用E序c,自定义类中获取其它四个类的方?http://www.shnenglu.com/aaxron/archive/2016/05/30/213608.html天下天下Mon, 30 May 2016 06:02:00 GMThttp://www.shnenglu.com/aaxron/archive/2016/05/30/213608.htmlhttp://www.shnenglu.com/aaxron/comments/213608.htmlhttp://www.shnenglu.com/aaxron/archive/2016/05/30/213608.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/213608.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/213608.html[转]VC中常用的文c,视图c,框架c,应用E序c,自定义类中获取其它四个类的方?nbsp;
A: 
GET App 
   AfxGetInstanceHandle() 
   AfxGetApp() 
GET Frame
->View->Document 
    SDI   AfxGetMainWnd()
->GetActiveView()->GetDocument() 
    MDI   AfxGetMainWnd()
->MDIGetActive()->GetActiveView()->GetDocument() 
GET Menu 
     CMenu 
*pMenu=AfxGetApp()->m_pMainWnd->GetMenu(); 
GET ToolBarQStatusBar 
      (CMainFrame 
*)GetParent()->m_wndToolBar; 
      (CMainFrame 
*)GetParent()->m_wndStatusBar; 
      CStatusBar 
* pStatusBa=(CStatusBar*)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR); 
      CToolBar 
* pToolBar=(CtoolBar*)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR); 
Get View from Document 
      GetFirstViewPosition ?nbsp;GetNextView 函数得到指针?nbsp;
最后提? 
    在提取到各个句柄之后Q因为初ơ提取的都是标准cd柄,所以,在用时要注意将标准句柄转换成自qcȝ句柄?br />    ((CMyApp
*)AfxGetApp())->XXXXQ)Q?/span>//q的xxxx()是你定义的cM间的成员?/span>

**********************************************************************************************************
1) 在View中获得Doc指针 
2) 在App中获得MainFrame指针 
3) 在View中获得MainFrame指针 
4) 获得ViewQ已建立Q指?nbsp;
5) 获得当前文指针 
6) 获得状态栏与工h指针 
7) 获得状态栏与工h变量 
8) 在Mainframe获得菜单指针 
9) 在Q何类中获得应用程序类 
10) 从文类取得视图cȝ指针(1
11) 在App中获得文模板指?nbsp;
12) 从文模板获得文类指针 
13) 在文类中获得文档模板指?nbsp;
14) 从文类取得视图cȝ指针(2
15) 从一个视囄取得另一视图cȝ指针 

VC中编E对于刚刚开始学习的同学Q最大的障碍和问题就是消息机制和指针获取与操作。其实这些内容基本上是每本VC学习工具书上必讲的内容,而且通过MSDN很多问题都能解决。下面文字主要是个h在编E中指针使用的一些体会,说的不当的地方请指正。一般我们用的框架是VC提供的Wizard生成的MFC App Wizard(exe)框架Q?nbsp;
无论是多文q是单文,都存在指针获取和操作问题。下面这节内容主要是一般的框架Q然后再讲多U程中的指针使用。用到的类需要包含响应的头文件。首先一般获得本c?视,文档Q对话框都支?实例指针thisQ用this的目的,主要可以通过cM的函数向其他cL者函C发指针,以便于在非本cM操作和用本cM?nbsp;
功能?nbsp;

1Q?nbsp;在View中获得Doc指针 CYouSDIDoc *pDoc=GetDocument();一个视只能有一个文?nbsp;
2) 在App中获得MainFrame指针 
CWinApp 中的 m_pMainWnd变量是MainFrame的指?nbsp;
也可以: CMainFrame 
*pMain =(CMainFrame *)AfxGetMainWnd(); 
3) 在View中获得MainFrame指针 CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd; 
4) 获得ViewQ已建立Q指针CyouView *pView=(CyouView *)pMain->GetActiveView(); 
5) 获得当前文档指针 CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument(); 
6) 获得状态栏与工h指针 CStatusBar * pStatusBarQ?CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR); 
CToolBar 
* pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR); 

7) 如果框架中加入工h和状态栏变量q可以这?nbsp;
(CMainFrame 
*)GetParent()->m_wndToolBar; 
(CMainFrame 
*)GetParent()->m_wndStatusBar; 

8) 在Mainframe获得菜单指针 
CMenu 
*pMenu=m_pMainWnd->GetMenu(); 

9) 在Q何类中获得应用程序类 
用MFC全局函数AfxGetApp()获得?nbsp;

10) 从文类取得视图cȝ指针 
CDocumentcL供了两个函数用于视图cȝ定位Q?nbsp;
GetFirstViewPosition()和GetNextView() 
virtual POSITION GetFirstViewPosition() const
virtual CView* GetNextView(POSITION& rPosition) const

注意QGetNextView()括号中的参数用的是引用方式,因此执行后值可能改变?nbsp;
GetFirstViewPosition()用于q回W一个视图位|(q回的ƈ非视囄指针Q而是一个POSITIONcd|QGetNextView()有两个功能:q回下一个视囄的指针以及用引用调用的方式来改变传入的POSITIONcd参数的倹{很明显Q在TestE序中,只有一个视囄Q因此只需这两个函数调用一ơ即可得到CTestView的指针如下(需定义一个POSITIONl构变量来辅助操作)Q?nbsp;
CTestView
* pTestView; 
POSITION pos
=GetFirstViewPosition(); 
pTestView
=GetNextView(pos); 

q样Q便可到了CTestViewcȝ指针pTestView.执行完几句后Q变量pos
=NULL,因ؓ没有下一个视囄Q自然也没有下一个视囄的POSITION.但是q几条语句太单,不具有太强的通用性和安全特征Q当象前面说的那P当要在多个视图ؓ中返回某个指定类的指针时Q我们需要遍历所有视囄Q直到找到指定类为止。判断一个类指针指向的是否某个类的实例时Q可用IsKindOf()成员函数时行查,如: 
pView
->IsKindOf(RUNTIME_CLASS(CTestView)); 
卛_查pView所指是否是CTestViewcR?nbsp;

有了以上基础Q我们已l可以从文cd得Q何类的指针。ؓ了方便,我们其作ؓ一个文类的成员函敎ͼ它有一个参敎ͼ表示要获得哪个类的指针。实现如下: 
CView
* CTestDoc::GetView(CRuntimeClass* pClass) 

    CView
* pView; 
    POSITION pos
=GetFirstViewPosition(); 
    
while(pos!=NULL) {
      pView
=GetNextView(pos); 
      
if(!pView->IsKindOf(pClass)) 
        
break
    } 

    
if(!pView->IsKindOf(pClass)) { 
        AfxMessageBox(
"Connt Locate the View.\r\n"); 
        
return NULL; 
    } 
    
return pView; 


其中用了两次视图cȝ成员函数IsKindOf()来判断,是因为退出while循环有三U?nbsp;
可能Q?nbsp;
1.pos为NULLQ即已经不存在下一个视囄供操作; 
2.pView已符合要求?nbsp;

1?同是满。这是因为GetNextView()的功能是当前视图指针改变成一个视囄位置同时q回当前视图指针Q因此pos是pView的下一个视囄的POSITION,完全有可能既是pos
==NULL又是pViewW合需要。当所需的视图是最后一个视图是最后一个视囄时就如引。因此需采用两次判断?nbsp;使用该函数应遵@如下格式Q以取得CTestView指针ZQ: 
CTestView
* pTestView=(CTestView*)GetView(RUNTIME_CLASS(CTestView)); 
RUNTIME_CLASS是一个宏Q可以简单地理解它的作用Q将cȝ名字转化?nbsp;
CRuntimeClass为指针。至于强制类型{换也是ؓ了安全特性考虑的,因ؓ从同一个基cM间的指针cd是互相兼容的。这U强制类型{换也许ƈ不必要,但能避免一些可能出现的ȝ?nbsp;

3.从一个视囄取得另一视图cȝ指针 l合1?Q很Ҏ得出视图cM间互相获得指针的ҎQ就是用文档cM中{Q先?的方法得到文类的指针,再用2的方法,以文类的视囑֮位函数取得另一个视囄。同P可以实现成一个函敎ͼ 
Q假设要从CTestAView中取得指向其它视囄的指针) 
CView
* CTestAView::GetView(CRuntimeClass* pClass) 

CTestDoc
* pDoc=(CTestDoc*)GetDocument(); 
CView
* pView; 
POSITION pos
=pDoc->GetFirstViewPosition(); 
while(pos!=NULL){ 
pView
=pDoc->GetNextView(pos); 
if(!pView->IsKindOf(pClass)) 
break

if(!pView->IsKindOf(pClass)){ 
AfxMessageBox(
"Connt Locate the View."); 
return NULL; 

return pView; 

q个函数?中的GetView()相比Q一是多了第一句以取得文cL针,二是在GetFirstViewPosition()和GetNextView()前加上了文cL针,以表C它们是文档 
cL员函数。有了此函数Q当要从CTestAView中取得CTestBView的指针时Q只需如下QCTestBView
* pTestbView=(CTestView*)GetView(RUNTIME_CLASS(CTestBView)); 


11Q对于单文中也可以加入多个文档模板Q但是一般的开发就使用MDI方式开发多文模板Q其Ҏ与上q视囄获取Ҏ很接q,q里E做解释Q如果不清楚Q请查阅MSDN

可以用CWinApp::GetFirstDocTemplatePostion获得应用E序注册的第一个文模?nbsp;
的位|;利用该值来调用CWinApp::GetNextDocTemplate函数Q获得第一个CDocTemplate对象指针?nbsp;
POSITION GetFirstDocTemplate( ) 
const
CDocTemplate 
*GetNextDocTemplate( POSITION & pos ) const

W二个函数返回由pos 标识的文模ѝPOSITION是MFC定义的一个用于P代或对象指针索的倹{通过q两个函敎ͼ应用E序可以遍历整个文档模板列表。如果被索的文模板是模板列表中的最后一个,则pos参数被置为NULL?nbsp;

12Q一个文模板可以有多个文Q每个文档模杉K保留q维护了一个所有对应文的指针列表?nbsp;
用CDocTemplate::GetFirstDocPosition函数获得与文档模板相关的文集合中第一个文档的位置Qƈ用POSITIONg为CDocTemplate::GetNextDoc的参数来重复遍历与模板相关的文列表。函数原形ؓQ?nbsp;
viaual POSITION GetFirstDocPosition( ) 
const = 0
visual CDocument 
*GetNextDoc(POSITION & rPos) const = 0
如果列表为空Q则rPos被置为NULL. 

13Q在文档中可以调用CDocument::GetDocTemplate获得指向该文模板的指针?nbsp;
函数原Ş如下Q?nbsp;CDocTemplate 
* GetDocTemplate ( ) const
如果该文档不属于文模板理Q则q回gؓNULL?nbsp;

14)一个文档可以有多个视。每一个文都保留q维护一个所有相兌的列表?nbsp;
CDocument::AddView一个视q接到文上Q将该视加入到文相联系的视的列表中Qƈ视的文指针指向该文。当有File
/New、File/Open、Windows/New或Window/Split的命令而将一个新创徏的视的对象连接到文上时Q?nbsp;MFC会自动调用该函数Q框枉过文档/视的l构文档和视联pv来。当ӞE序员也可以Ҏ自己的需要调用该函数?nbsp;
Virtual POSITION GetFirstViewPosition( ) 
const
Virtual CView 
* GetNextView( POSITION &rPosition) cosnt; 

应用E序可以调用CDocument::GetFirstViewPositionq回与调用文相联系的视的列表中的第一个视的位|,q调用CDocument::GetNextViewq回指定位置的视QƈrPositon的值置为列表中下一个视的POSITION倹{如果找到的视ؓ列表中的最后一个视Q则rPosition|ؓNULL. 

15)从一个视囄取得另一视图cȝ指针 
q个应用在多视的应用E序中很多见Q一般如果自己在ȝ序或者主框架中做好变量记P也可以获得,q有比较通用的就是用文cM中{Q以文cȝ视图遍历 
定位Q取得另一个视囄。这个功能从本文W?0中可以得到?nbsp;


天下 2016-05-30 14:02 发表评论
]]>
CreateProcess+Pipe 交互q行命ohttp://www.shnenglu.com/aaxron/archive/2016/05/27/213597.html天下天下Fri, 27 May 2016 09:13:00 GMThttp://www.shnenglu.com/aaxron/archive/2016/05/27/213597.htmlhttp://www.shnenglu.com/aaxron/comments/213597.htmlhttp://www.shnenglu.com/aaxron/archive/2016/05/27/213597.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/213597.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/213597.htmlBOOL CNeowayAndroidCheckToolView::PipeSendCmd(const HANDLE& handle,LPCTSTR cmd)
{
    CString _cmd(cmd);
    BOOL bRet;
    DWORD dwWrited;

    _cmd.Append(
"\r\n");    
    
return WriteFile(handle,_cmd,_cmd.GetLength(),&dwWrited,NULL);
}
BOOL CNeowayAndroidCheckToolView::PipeRead(
const HANDLE& handle,CString& result,DWORD dwMilliseconds)
{
    BOOL bRet 
= FALSE;
    CHAR buffer[
4100];
    DWORD dwReaded;

    result.Empty();
    
while(1)
    {
        Sleep(dwMilliseconds);
        bRet 
= PeekNamedPipe(handle,buffer,1,&dwReaded,NULL,NULL);
        
if (!bRet) goto _flag_exit;
        
if (dwReaded>0)
        {
            bRet 
= ReadFile(handle, buffer,4096&dwReaded, NULL);
            
if (!bRet) goto _flag_exit;
            buffer[dwReaded] 
= '\0';
            result 
+= buffer;
        }
else {
            
break;
        }
    }
_flag_exit:
    
return bRet;
}
BOOL CNeowayAndroidCheckToolView::TestGpio()
{
    CString init_cmd 
= Path::Combine( Path::GetAppDirectory(),"adb.exe shell");
    
//CString init_cmd = "cmd.exe";
    CString cmd;
    CString result;
    DWORD exit_code 
= -1;
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    HANDLE hStdOutRead
=NULL, hStdOutPipe=NULL;
    HANDLE hStdInWrite
=NULL, hStdInPipe=NULL;
    SECURITY_ATTRIBUTES saRead,saWrite;
    BOOL bRet;
    BOOL bSucceed;    
    DWORD dwReaded;
    std::vector
<CString> lines;

    saRead.nLength 
= sizeof(SECURITY_ATTRIBUTES);
    saRead.bInheritHandle 
= TRUE;
    saRead.lpSecurityDescriptor 
= NULL;
    saWrite 
= saRead;

    bRet 
= CreatePipe(&hStdOutRead, &hStdOutPipe, &saRead, 4096);
    
if (!bRet)
        
goto _flag_exit;
    bRet 
= CreatePipe(&hStdInPipe, &hStdInWrite, &saWrite, 4096);
    
if (!bRet)
        
goto _flag_exit;

    memset(
&si, 0sizeof(si));
    si.cb 
= sizeof(si);
    si.dwFlags 
= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
    si.wShowWindow 
= SW_HIDE;
    si.hStdOutput 
= hStdOutPipe;
    si.hStdInput  
= hStdInPipe;

    bRet 
= CreateProcess(NULL, (LPSTR)(LPCTSTR)init_cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
    
if (!bRet) goto _flag_exit;
        

    CloseHandle(hStdOutPipe);hStdOutPipe 
= NULL;
    CloseHandle(hStdInPipe);hStdInPipe 
= NULL;

    bRet 
= PipeRead(hStdOutRead,result,50);
    
if (!bRet) goto _flag_exit;

    PipeSendCmd(hStdInWrite,
"cd sys/gpio_test");
    
if (!bRet) goto _exit_adb;

    bRet 
= PipeRead(hStdOutRead,result,50);
    
if (!bRet) goto _exit_adb;

    PipeSendCmd(hStdInWrite,
"echo \"1\" > start");
    
if (!bRet) goto _exit_adb;

    bRet 
= PipeRead(hStdOutRead,result,50);
    
if (!bRet) goto _exit_adb;

    PipeSendCmd(hStdInWrite,
"cat result");
    
if (!bRet) goto _exit_adb;

    bRet 
= PipeRead(hStdOutRead,result,50);
    
if (!bRet) goto _exit_adb;

    bRet 
= (result.Find("OK")>=0);
_exit_adb:
    
if (!PipeSendCmd(hStdInWrite,"exit")) {
        bRet 
= FALSE; goto _flag_exit;
    }

    WaitForSingleObject( pi.hProcess, 
5000);

    
if (!GetExitCodeProcess(pi.hProcess, &exit_code)) {
        bRet 
= FALSE; goto _flag_exit;
    }
    bRet 
= bRet && (exit_code==0);
_flag_exit:
    
if  (hStdOutRead!=NULL)
        CloseHandle(hStdOutRead);
    
if  (hStdOutPipe!=NULL)
        CloseHandle(hStdOutPipe);
    
if  (hStdInWrite!=NULL)
        CloseHandle(hStdInWrite);
    
if  (hStdInPipe!=NULL)
        CloseHandle(hStdInPipe);
    
return bRet;
}


天下 2016-05-27 17:13 发表评论
]]>
MFC单文界面的微调http://www.shnenglu.com/aaxron/archive/2016/05/24/213576.html天下天下Tue, 24 May 2016 09:23:00 GMThttp://www.shnenglu.com/aaxron/archive/2016/05/24/213576.htmlhttp://www.shnenglu.com/aaxron/comments/213576.htmlhttp://www.shnenglu.com/aaxron/archive/2016/05/24/213576.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/213576.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/213576.html
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
 if( !CFrameWnd::PreCreateWindow(cs) )
  return FALSE;

 cs.style &= ~FWS_ADDTOTITLE;//屏蔽“无标?#8221;字样
 cs.style &= ~WS_MAXIMIZEBOX;//屏蔽屏幕最大化
 
//cs.style &= ~WS_THICKFRAME;  //不可改变大小
 return TRUE;
}


//调整状态栏大小
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{    if (!m_wndStatusBar.Create(this))
    {
        TRACE0("未能创徏状态栏\n");
        return -1;      // 未能创徏
    }
    m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

    m_wndStatusBar.SetPaneInfo(0,m_wndStatusBar.GetDlgCtrlID(),SBPS_NORMAL,230); //调整大小
    
//.
}

//固定MainFrame大小
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
    POINT p = {365,400};
    lpMMI->ptMaxTrackSize = p;
    lpMMI->ptMinTrackSize = p;
    CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
// MainFrm.h  增加
public:
 POINT m_TrackSize;
 void SetAutoSize();

// MainFrm.cpp
void CMainFrame::SetAutoSize()
{
     CRect rc;
     GetWindowRect(&rc);
     m_TrackSize = CPoint(rc.Width(),rc.Height());
}

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
 if (m_TrackSize.x && m_TrackSize.x)
 {
  lpMMI->ptMinTrackSize = m_TrackSize;
  lpMMI->ptMaxTrackSize = m_TrackSize;
 }
 CXTPFrameWnd::OnGetMinMaxInfo(lpMMI);
}

// OppoTest6View.cpp
void COppoTest6View::OnInitialUpdate()
{
 CFormView::OnInitialUpdate();
 GetParentFrame()->RecalcLayout();
 ResizeParentToFit();
 
 CMainFrame* MainFrame = (CMainFrame*)GetParentFrame();
 MainFrame->SetAutoSize();
}

天下 2016-05-24 17:23 发表评论
]]>
在vc中用PCREhttp://www.shnenglu.com/aaxron/archive/2016/03/02/212909.html天下天下Wed, 02 Mar 2016 02:04:00 GMThttp://www.shnenglu.com/aaxron/archive/2016/03/02/212909.htmlhttp://www.shnenglu.com/aaxron/comments/212909.htmlhttp://www.shnenglu.com/aaxron/archive/2016/03/02/212909.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/212909.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/212909.html在vc中用PCRE
1. PCRE?br />正则表达?regular expression)Q通常写ؓregex、regexp或REQ用单个字W串来描q、匹配一pdW合某个句法规则的字W串?br />PCRE(Perl Compatible Regular Expressions)Q是一个函数库Q由Philip Hazel开发,该函数库使用与Perl5一L语法和语义实C正则表达式的模式匚w功能。PCRE是免费开源的Q它是由C语言实现。很多著名的开源Y件如Apache、PHP、KDE、Nginx {都使用了PCRE。官方主?#8211;http://www.pcre.orgQ目前(2016.03Q最新版本是8.38?/span>

2 ~译 PCRE
PCRE的作者Philip Hazel是在linux上工作的Q所以编译PCRE最好的办法自然是configure, make, make install三步曲了。在windows下, cygwin或者MinGW都支持这么做?br />在windows下编?nbsp;PCRE要用CMake?br />先从 http:
//www.cmake.org 上下载最新版的CMakeQ?/span>
在解压羃后的PCRE目录下徏个子目录buildQ比如我的D:\pcre-8.38\build?br />讄要编译的源代码的路径以及~译好的二进制文件存攄路径
CMake 会读取源代码目录下的文g CMakeLists.txt Q然后将d的配|以U颜色显C出来,此时可以Ҏ我们的需要适当的选择或去掉一些配|,比如加上 PCRE_SUPPORT_UTFQ去掉PCRE_SUPPORT_JIT(不需要嵌入式的代?、PCRE_BUILD_PCRECPP(我只惌c形式的库)Q还可以修改一些配|的|比如把PCRE_NEWLINE从LFҎCRLF。然后再点一?/span>"Configure”,最后点"Generate”Q你会发现在build目录里生成了一pd的vc6的工E文件以及一?h文g?c文g?br />
3 在工E中使用PCRE
包含头文?nbsp;#include “pcre.h”
链接静态库 #pragma comment(lib,“pcre.lib”)
在项?#8221;预处理器定义“中加上PCRE_STATIC

CZ代码Q?br />#include 
"stdafx.h"
#define PCRE_STATIC
#include 
"pcrecpp.h"
#include 
<vector>
#include 
<iostream>
#include 
<string>
#pragma comment(lib,
"lib/pcrecppd.lib")
#pragma comment(lib,
"lib/pcred.lib")
using namespace std;
using namespace pcrecpp;

int Test1()
{
    
#define OVECCOUNT 30    /* should be a multiple of 3 */
    pcre            
*re; 
    
const char      *error;
    
int             erroffset;
    
int             ovector[OVECCOUNT];
    
int             rc, i;

    
char            src    [] = "111 <title>Hello World</title> 222";
    
char            pattern   [] = "<title>(.*)</title>";

    printf(
"String : %s\n", src);
    printf(
"Pattern: \"%s\"\n", pattern);


    re 
= pcre_compile(pattern, 0&error, &erroffset, NULL);
    
if (re == NULL) {
        printf(
"PCRE compilation failed at offset %d: %s\n", erroffset, error);
        
return 1;
    }

    rc 
= pcre_exec(re, NULL, src, strlen(src), 00, ovector, OVECCOUNT);
    
if (rc < 0) {
        
if (rc == PCRE_ERROR_NOMATCH) printf("Sorry, no match \n");
        
else    printf("Matching error %d\n", rc);
        free(re);
        
return 1;
    }

    printf(
"\nOK, has matched \n\n");

    
for (i = 0; i < rc; i++) {
        
char *substring_start = src + ovector[2*i];
        
int substring_length = ovector[2*i+1- ovector[2*i];
        printf(
"%2d: %.*s\n", i, substring_length, substring_start);
    }

    free(re);
    
return 0
}


int main()  
{  
    Test1();
    
return 0;
}  




天下 2016-03-02 10:04 发表评论
]]>
WM_COMMANDQBN_CLICKEDQ实?/title><link>http://www.shnenglu.com/aaxron/archive/2016/01/20/212690.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Wed, 20 Jan 2016 03:23:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2016/01/20/212690.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/212690.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2016/01/20/212690.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/212690.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/212690.html</trackback:ping><description><![CDATA[<div style="font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all; background-color: #eeeeee;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->#include "stdafx.h"<br /><span style="color: #008000; ">//</span><span style="color: #008000; "> TestControl.c <br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">转自http:</span><span style="color: #008000; ">//</span><span style="color: #008000; ">www.cnblogs.com/memset/archive/2013/05/16/3081082.html Q稍加修?/span><span style="color: #008000; "><br /></span><br /><span style="color: #0000FF; ">#define</span> _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      <span style="color: #008000; ">//</span><span style="color: #008000; "> 某些 CString 构造函数将是显式的</span><br />#include <atlbase.h><br />#include <atlstr.h><br /><br />#include <WindowsX.h><br /><br />LRESULT CALLBACK ControlWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);<br /><br /><span style="color: #0000FF; ">void</span> RegisterControlClass(HINSTANCE hInstance)<br />{<br />    WNDCLASSEXW wce={0};<br /><br />    wce.cbSize = <span style="color: #0000FF; ">sizeof</span>(wce);<br />    wce.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);<br />    wce.hInstance = hInstance;<br />    wce.lpfnWndProc = ControlWindowProc;<br />    wce.lpszClassName = L"ControlClass";<br />    wce.style = CS_HREDRAW|CS_VREDRAW;<br /><br />    RegisterClassExW(&wce);<br /><br />}<br /><br /><br /><br />LRESULT CALLBACK ControlWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)<br />{<br />    <span style="color: #0000FF; ">static</span> HBRUSH hbrBlack,hbrRed;<br />    <span style="color: #0000FF; ">switch</span>(uMsg)<br />    {<br />    <span style="color: #0000FF; ">case</span> WM_CREATE:<br />        {<br />            hbrBlack = CreateSolidBrush(#000000);<br />            hbrRed = CreateSolidBrush(#ff0000);<br /><br />            <span style="color: #0000FF; ">return</span> 0;<br />        }<br />    <span style="color: #0000FF; ">case</span> WM_PAINT:<br />        {<br />            PAINTSTRUCT ps;<br />            HDC hdc;<br />            hdc = BeginPaint(hWnd,&ps);<br />            SelectObject(hdc,hbrBlack);<br />            Rectangle(hdc,0,0,100,50);<br /><br />            {<br />                CString text;<br />                ::GetWindowText(hWnd,text.GetBuffer(100),100);<br />                text.ReleaseBuffer();<br />                TextOutW(hdc,10,10,text,text.GetLength());<br />            }<br /><br />            EndPaint(hWnd,&ps);<br />            <span style="color: #0000FF; ">return</span> 0;<br /><br />        }<br />    <span style="color: #0000FF; ">case</span> WM_LBUTTONDOWN:<br />        {<br />            HDC hdc;<br />            hdc = GetDC(hWnd);<br />            SelectObject(hdc,hbrRed);<br />            Rectangle(hdc,0,0,100,50);<br />            SetTextColor(hdc,#ff0000);<br />            {<br />                CString text;<br />                ::GetWindowText(hWnd,text.GetBuffer(100),100);<br />                text.ReleaseBuffer();<br />                TextOutW(hdc,10,10,text,text.GetLength());<br />            }<br />            ReleaseDC(hWnd,hdc);<br />            SetCapture(hWnd);<br />            <span style="color: #0000FF; ">return</span> 0;<br />        }<br />    <span style="color: #0000FF; ">case</span> WM_LBUTTONUP:<br />        {<br />            HDC hdc;<br />            hdc = GetDC(hWnd);<br />            SelectObject(hdc,hbrBlack);<br />            Rectangle(hdc,0,0,100,50);<br />            SetTextColor(hdc,#000000);<br />            {<br />                CString text;<br />                ::GetWindowText(hWnd,text.GetBuffer(100),100);<br />                text.ReleaseBuffer();<br />                TextOutW(hdc,10,10,text,text.GetLength());<br />            }<br />            ReleaseDC(hWnd,hdc);<br />        <br />            BOOL bRet =  (GetCapture()==hWnd);<br />            ReleaseCapture();<br /><br />            HWND parent = ::GetParent(hWnd);<br />            HMENU hMenu = ::GetMenu(hWnd);<br /><br />            <span style="color: #008000; ">//</span><span style="color: #008000; ">POINT pt = MAKEPOINTS(lParam);</span><span style="color: #008000; "><br /></span>            POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };<br />            RECT rect;<br />            ::GetClientRect(hWnd,&rect);<br />            bRet = bRet && ::PtInRect(&rect,pt);<br />            <span style="color: #0000FF; ">if</span> (bRet)<br />                ::SendMessage(parent,WM_COMMAND,(WPARAM)hMenu,NULL);<br />            <span style="color: #0000FF; ">return</span> 0;<br />        }<br />    <span style="color: #0000FF; ">case</span> WM_DESTROY:<br />        DeleteObject(hbrBlack);<br />        DeleteObject(hbrRed);<br />        <span style="color: #0000FF; ">return</span> 0;<br />    }<br />    <span style="color: #0000FF; ">return</span> DefWindowProcW(hWnd,uMsg,wParam,lParam);<br />}<br /><br /><br />LRESULT CALLBACK MainWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)<br />{<br />    <span style="color: #0000FF; ">switch</span>(uMsg)<br />    {<br />    <span style="color: #0000FF; ">case</span> WM_CREATE:<br />        {<br />            HINSTANCE hInstance = GetModuleHandleW(NULL);<br /><br />            CreateWindowExW(0,L"Button",L"按键",WS_CHILD|WS_VISIBLE,0,0,100,50,hWnd,(HMENU)101,hInstance,NULL);<br />            CreateWindowExW(0,L"ControlClass",L"哈哈",WS_CHILD|WS_VISIBLE,200,200,100,50,hWnd,(HMENU)100,hInstance,NULL);<br />            CreateWindowExW(0,L"ControlClass",L"呵呵",WS_CHILD|WS_VISIBLE,400,400,100,50,hWnd,(HMENU)102,hInstance,NULL);<br /><br />            <span style="color: #0000FF; ">return</span> 0;<br />        }<br />    <span style="color: #0000FF; ">case</span> WM_COMMAND:<br />        {<br />            <span style="color: #0000FF; ">int</span> wmId    = LOWORD(wParam);<br />            CString msg;<br />            msg.Format(L"hWmd:0x%08x,wmId:%d",hWnd,wmId);<br />            MessageBox(hWnd,msg,L"提示",MB_OK|MB_ICONINFORMATION);<br />        }<br />        <span style="color: #0000FF; ">break</span>;<br />    <span style="color: #0000FF; ">case</span> WM_DESTROY:<br />        PostQuitMessage(0);<br />        <span style="color: #0000FF; ">return</span> 0;<br />    <span style="color: #0000FF; ">default</span>:<br />        <span style="color: #0000FF; ">break</span>;<br />    }<br />    <span style="color: #0000FF; ">return</span> DefWindowProcW(hWnd,uMsg,wParam,lParam);<br />}<br /><br /><span style="color: #0000FF; ">int</span> WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,<span style="color: #0000FF; ">int</span> nShowCmd)<br />{<br />    HWND hWnd;<br />    WNDCLASSEXW wce = {0};<br />    MSG msg;<br /><br />    RegisterControlClass(hInstance);<br /><br />    wce.cbSize = <span style="color: #0000FF; ">sizeof</span>(wce);<br />    wce.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);<br />    wce.hCursor = LoadCursor(NULL,IDC_ARROW);<br />    wce.hIcon = LoadIcon(NULL,IDI_APPLICATION);<br />    wce.hInstance = hInstance;<br />    wce.lpfnWndProc = MainWindowProc;<br />    wce.lpszClassName = L"MyWindowClass";<br />    wce.style = CS_HREDRAW|CS_VREDRAW;<br /><br />    RegisterClassExW(&wce);<br /><br />    hWnd = CreateWindowExW(0,L"MyWindowClass",L"试",WS_OVERLAPPEDWINDOW,<br />        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);<br /><br />    UpdateWindow(hWnd);<br />    ShowWindow(hWnd,nShowCmd);<br /><br />    <span style="color: #0000FF; ">while</span>(GetMessageW(&msg,NULL,0,0))<br />    {<br />        TranslateMessage(&msg);<br />        DispatchMessageW(&msg);<br />    }   <br />    <span style="color: #0000FF; ">return</span> 0;<br />}</div><img src ="http://www.shnenglu.com/aaxron/aggbug/212690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2016-01-20 11:23 <a href="http://www.shnenglu.com/aaxron/archive/2016/01/20/212690.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>H口子类化的一般方?/title><link>http://www.shnenglu.com/aaxron/archive/2015/08/10/211517.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Mon, 10 Aug 2015 02:02:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2015/08/10/211517.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/211517.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2015/08/10/211517.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/211517.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/211517.html</trackback:ping><description><![CDATA[<div>实现子类化的一般方?/div><div>从上面可以看出,子类化主要用几个API函数Q这几乎是所有实现子cd相同的方法。相关API说明如下Q?/div><div>1?WINUSERAPI LONG WINAPI GetWindowLongA(HWND hWnd, int nIndex);</div><div>WINUSERAPI LONG WINAPI GetWindowLongW(HWND hWnd,int nIndex);</div><div>2?SetWindowLong ?CallWindowProc 函数q不再列出来了,都是_容易的Q?/div><div>使用 ComCtl32.dll version 6 实现H口子类?/div><div>Windows XP 带的ComCtl32.dll version 6 提供?个可以让创徏子类化更单,q且可以消除前面提到的缺L函数。这些新的函数封装了对多l参考数据(multiple sets of reference dataQ的理操作Q得开发者能精力集中到具体的程序特性而不是对子类的管理上。这些新的函CؓQ?/div><div>SetWindowSubclass</div><div>GetWindowSubclass</div><div>RemoveWindowSubclass</div><div>DefSubclassProc</div><div>下面是对q些函数的描q?/div><div>SetWindowSubclass</div><div>q个函数用来子类化一个窗口。每个子cd以用p pfnSubclass ?uIdSubclass QSetWindowSubclass的参敎ͼ唯一标识。多个子cd以共享同一个子c过E,而用标识QIDQ来区分。改变参考数据可以提供再一ơ调用SetWindowSubclass 来实现。一个重要的优点是每一个子cd例可以拥有自q参考数据?/div><div>子类q程的声明和传统的窗口过E有点细微的差别Q它多了两个参数Q子cID和参考数据。参看下面这个函数声明的最后两个参敎ͼ</div><div>LRESULT CALLBACK MyWndProc (HWND hWnd, UINT msg,WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass,</div><div>DWORD_PTR dwRefData);</div><div>每次新的H口q程收到一个消息时Q它同时得到了一个子cID和参考数据?/div><div>注意Q所有作为参C递给该函数的字符串均为UnicodeQ不有没有定义Unicode~译选项?/div><div>GetWindowSubclass</div><div>该函数取回一个子cȝ信息。比如你可以用GetWindowSubclass 来访问参考数据?/div><div>RemoveWindowSubclass</div><div>该函数移除一个子c? RemoveWindowSubclass ?SetWindowSubclass 联合使用可以动态添加和删除子类.</div><div>DefSubclassProc</div><div>q个函数调用子类链中的下一个处理者。这个函数可以自行取得正的ID和参考数据ƈ传递给下一个窗口过E?/div><div>大家都知道每个窗口都有默认的H口函数来进行对H口消息的处?</div><div></div><div>OutputDebugString</div><div>SetProp()</div><div>SetWindowSubclass</div><div>BOOL SetWindowSubclass(          </div><div>    HWND hWnd,</div><div>    SUBCLASSPROC pfnSubclass,</div><div>    UINT_PTR uIdSubclass,</div><div>    DWORD_PTR dwRefData</div><div>);</div><div>SUBCLASSPROC</div><div>DefSubclassProc</div><div></div><div>LRESULT CALLBACK MyWndProc (HWND hWnd, UINT msg,WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass,DWORD_PTR dwRefData);</div><img src ="http://www.shnenglu.com/aaxron/aggbug/211517.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2015-08-10 10:02 <a href="http://www.shnenglu.com/aaxron/archive/2015/08/10/211517.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>H口销毁的相关函数与消?/title><link>http://www.shnenglu.com/aaxron/archive/2015/08/01/211447.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Sat, 01 Aug 2015 06:24:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2015/08/01/211447.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/211447.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2015/08/01/211447.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/211447.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/211447.html</trackback:ping><description><![CDATA[<div>H口销毁的相关函数与消?/div><div></div><div>DestroyWindow函数</div><div>DestroyWindow销毁窗口的正牌函数?/div><div></div><div>DestroyWindows的MSDN说明如下Q?/div><div></div><div>The DestroyWindow function destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window's menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).</div><div></div><div>If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window.</div><div></div><div>DestroyWindow also destroys modeless dialog boxes created by the CreateDialog function.</div><div></div><div>A thread cannot use DestroyWindow to destroy a window created by a different thread.</div><div></div><div>If the window being destroyed is a child window that does not have the WS_EX_NOPARENTNOTIFY style, a WM_PARENTNOTIFY message is sent to the parent.</div><div></div><div>DestroyWindow的处理过Eȝ要点如下Q?nbsp;</div><div>1. 向父H口发送WM_PARENTNOTIFY消息Q仅当窗口具有WS_EX_NOPARENTNOTIFY样式Q; </div><div>2. 向窗口发送WM_DESTROY消息Q?nbsp;</div><div>3. 使窗口{入非zd状态,U除键盘焦点Q?nbsp;</div><div>4. 销毁子H口Q应该是通过递归调用DestroyWindow完成Q; </div><div>5. 销毁目标窗口资源:销毁菜单,清空U程的消息队列,销毁与H口q程相关的定时器Q解除窗口对剪脓板的拥有权,打断剪脓板器的查看链Q?nbsp;</div><div>6. 向窗口发送WM_NCDESTROY消息Q?/div><div></div><div>上述条目大致从前往后执行(1??的顺序不一定,5?的顺序不一定)。依据是Q?nbsp;</div><div>1. ҎWM_PARENTNOTIFY说明Q销毁窗口时Q系l在M销毁窗口的操作执行前发送WM_PARENTNOTIFY至父H口Q?nbsp;</div><div>2. ҎWM_DESTROY说明Q此消息先被发送至目标H口Q然后发送给目标H口的所有子H口Q处理此消息Ӟ可以假定所有子H口q存在着Q?nbsp;</div><div>3. ҎDestroyWindow说明Q函数先销毁子H口及所拥有的窗口,然后销毁目标窗口; </div><div>4. ҎWM_NCDESTROY说明Q与WM_DESTROY相反的是Q此消息在所有子H口销毁之后发送; 没有ȝ汇编代码Q只是根据各个MSDN说明来大致推的Q基本够用了吧?/div><div></div><div>ҎMSDN说明Q不能在非创建线E上调用DestroyWindowQ若要在其它U程上关闭窗口,不可以直接调用DestroyWindowQ错?拒绝讉K"Q,也不可以只发送WM_DESTROYQ因为DestroyWindow才能完整的关闭窗口,WM_DESTROY消息只是关闭程的一部分Q甚x最"无用"的一部分--WM_DESTROY只是用户响应的接口,而真正清理窗口的工作由DestroyWindow的其它部分完成?nbsp;</div><div>要在其它U程上关闭窗口,可以向窗口发送WM_CLOSE消息Q若H口q程未在WM_CLOSE的处理中取消关闭操作Q则DefWindowProc会默认调用DestroyWindowQ彼时自然是在窗口的创徏U程上)?/div><div></div><div>WM_CLOSE消息</div><div>WM_CLOSE的MSDN说明如下Q?/div><div></div><div>An application can prompt the user for confirmation, prior to destroying a window, by processing the WM_CLOSE message and calling the </div><div>DestroyWindow function only if the user confirms the choice.</div><div></div><div>By default, the DefWindowProc function calls the DestroyWindow function to destroy the window.</div><div></div><div>WM_CLOSE消息提供取消关闭H口操作的接口,也可以作为窗口关闭的兌处理的统一入口。点ȝ口右上角的关闭按钮将DH口收到WM_CLOSE消息Q一般情况下Q菜单中的Exit的处理代码中也应向H口发送WM_CLOSE消息Q这样可以无论何种方式触发的窗口关闭操作,其程序流均会入WM_CLOSE消息的处理过E。在WM_CLOSE中可以对E序状态进行确认,自动或由用户认是否取消关闭操作?nbsp;</div><div>与接下来的其它消息相比,WM_CLOSE的特D之处在于它发生在销毁过E启动之前。用户处理完WM_CLOSE消息后,如未取消Q则DefWindowProc调用DestroyWindow来关闭窗口,一旦进入DestroyWindowQ则关闭q程不可逆{?/div><div></div><div>WM_DESTROY消息</div><div>WM_DESTROY的MSDN说明如下Q?/div><div></div><div>The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen.</div><div></div><div>This message is sent first to the window being destroyed and then to the child windows (if any) as they are destroyed. During the processing of the message, it can be assumed that all child windows still exist.</div><div></div><div>A window receives this message through its WindowProc function.</div><div></div><div>If the window being destroyed is part of the clipboard viewer chain (set by calling the SetClipboardViewer function), the window must remove itself from the chain by processing the ChangeClipboardChain function before returning from the WM_DESTROY message.</div><div></div><div>最后一句值得注意Q不q对剪脓板涉猎不多,暂且不究?/div><div></div><div>WM_PARENTNOTIFY消息</div><div>WM_PARENTNOTIFY的MSDN说明如下Q?/div><div></div><div>The WM_PARENTNOTIFY message is sent to the parent of a child window when the child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. When the child window is being created, the system sends WM_PARENTNOTIFY just before the CreateWindow or CreateWindowEx function that creates the window returns. When the child window is being destroyed, the system sends the message before any processing to destroy the window takes place.</div><div></div><div>A window receives this message through its WindowProc function.</div><div></div><div>WM_NCDESTROY消息</div><div>WM_NCDESTROY的MSDN说明如下Q?/div><div></div><div>The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY message. WM_DESTROY is used to free the allocated memory object associated with the window. The WM_NCDESTROY message is sent after the child windows have been destroyed. In contrast, WM_DESTROY is sent before the child windows are destroyed. A window receives this message through its WindowProc function. This message frees any memory internally allocated for the window.</div><div></div><div>关于WM_DESTROY与WM_NCDESTROYQ从各种说明可以看出Q一个大U充当关闭操作启动时的通知接口Q一个大U充当关闭操作完成时的通知接口。这也是我认为在DestroyWindow的处理流E中Q第6条在W?条之后的原因?nbsp;</div><div>另外Q说明中有个值得一提的地方在于QWM_DESTROY用于释放兌刎ͼassociated toQ窗口的已分配内存对象,WM_NCDESTROY用于释放内部为窗口分配的Qinternally allocated forQ内存?可以惌Q后者应当指H口的内核数据,但前者则有各U可能,菜单资源QGDI资源Q异或是子窗口资源?q个׃好说了?而且Q根据这两句话的表述Q似乎这两个清理操作是在消息的处理过E中发生的,然而显然又不是qh完成的工作,那么应当是在DefWindowProc中完成的了。ؓ什么不直接拿到Destroywindow中来执行呢?</div><div></div><div>ActiveX控g的销?/div><div>销毁控件的最好方法是销毁宿ȝ口。可以通过调用 CWindow::DestroyWindow ?DestroyWindow API 昑ּ地进行销毁,或者让宿主H口的父U窗口的毁坏D其死亡,从而隐式地q行销毁。这些方法的M一U都安全地销毁寄宿的控g。请注意QCAxWindow 对象的毁?不会"D基础"AtlAxWin7"H口的毁坏?nbsp;</div><div>来自Qhttp://technet.microsoft.com/zh-cn/query/cc468138</div><img src ="http://www.shnenglu.com/aaxron/aggbug/211447.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2015-08-01 14:24 <a href="http://www.shnenglu.com/aaxron/archive/2015/08/01/211447.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IniFileGetValue,IniFileSetValuehttp://www.shnenglu.com/aaxron/archive/2015/07/10/211216.html天下天下Fri, 10 Jul 2015 09:25:00 GMThttp://www.shnenglu.com/aaxron/archive/2015/07/10/211216.htmlhttp://www.shnenglu.com/aaxron/comments/211216.htmlhttp://www.shnenglu.com/aaxron/archive/2015/07/10/211216.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/211216.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/211216.htmlstatic CString GetAppDirectory()
{
    CString sPath;
    GetModuleFileName(NULL,sPath.GetBuffer(MAX_PATH+1),MAX_PATH);
    //GetCurrentDirectory(MAX_PATH,sPath.GetBuffer(MAX_PATH+1));

    sPath.ReleaseBuffer ();
    int nPos;
    nPos=sPath.ReverseFind ('\\');
    sPath=sPath.Left(nPos+1);
    return sPath;
}

static CString IniFileGetValue(const CString& strFileName,const CString& strKeyPath,const CString& strDefault="")
{
    CStringArray strKeys;
    CString strValue;
    int last_pos = 0;
    int pos;
    int new_pos;
    CString strKey;
    while (1)
    {
        pos = strKeyPath.Find("/",last_pos);
        new_pos = pos;
        if (pos==-1)
            new_pos = strKeyPath.GetLength();
        strKey   = strKeyPath.Mid(last_pos,new_pos - last_pos);
        last_pos = pos+1;
        if (!strKey.IsEmpty())
            strKeys.Add(strKey);
        if (pos==-1)
            break;
    }
    if (strKeys.GetSize()!=2)
        return strDefault;
    GetPrivateProfileString(strKeys[0],strKeys[1],0,strValue.GetBuffer(4096),4095,strFileName);
    strValue.ReleaseBuffer();
    if (strValue.IsEmpty())
        return strDefault;
    return strValue;
}

static BOOL IniFileSetValue(const CString& strFileName,const CString& strKeyPath,const CString& strValue)
{
    CStringArray strKeys;
    int last_pos = 0;
    int pos;
    int new_pos;
    CString strKey;
    while (1)
    {
        pos = strKeyPath.Find("/",last_pos);
        new_pos = pos;
        if (pos==-1)
            new_pos = strKeyPath.GetLength();
        strKey   = strKeyPath.Mid(last_pos,new_pos - last_pos);
        last_pos = pos+1;
        if (!strKey.IsEmpty())
            strKeys.Add(strKey);
        if (pos==-1)
            break;
    }
    if (strKeys.GetSize()!=2)
        return FALSE;
    
    return WritePrivateProfileString(strKeys[0],strKeys[1],strValue,strFileName);
}

天下 2015-07-10 17:25 发表评论
]]>
Win32d自定义消?/title><link>http://www.shnenglu.com/aaxron/archive/2014/07/04/207508.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Fri, 04 Jul 2014 00:33:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2014/07/04/207508.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/207508.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2014/07/04/207508.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/207508.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/207508.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008000">//</span><span style="color: #008000">1、注册消?/span><span style="color: #008000"><br /></span><span style="color: #000000">UINT32 MSG_SUBTHREAD_CMD </span><span style="color: #000000">=</span><span style="color: #000000"> ::RegisterWindowMessage(</span><span style="color: #000000">"</span><span style="color: #000000">MSG_SUBTHREAD_CMD</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><br /></span><span style="color: #008000">//</span><span style="color: #008000">2、添加消息处理函?/span><span style="color: #008000"><br /></span><span style="color: #000000">BEGIN_MESSAGE_MAP(CApplicationService1Dlg, CDialogEx)<br />    ON_WM_PAINT()<br />    ON_WM_QUERYDRAGICON()<br />    ON_BN_CLICKED(ID_BTN_SERVICE_RUN, </span><span style="color: #000000">&</span><span style="color: #000000">CApplicationService1Dlg::OnBnClickedBtnServiceRun)<br />    ON_REGISTERED_MESSAGE(MSG_SUBTHREAD_CMD,</span><span style="color: #000000">&</span><span style="color: #000000">CApplicationService1Dlg::OnMsgSubThreadCmd)<br />END_MESSAGE_MAP()<br /><br /></span><span style="color: #008000">//</span><span style="color: #008000">2.1 消息处理函数</span><span style="color: #008000"><br /></span><span style="color: #000000">LRESULT CApplicationService1Dlg::OnMsgSubThreadCmd(WPARAM wParam, LPARAM lParam)<br />{<br /><br />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />}<br /><br /></span><span style="color: #008000">//</span><span style="color: #008000">3.发送消?/span><span style="color: #008000"><br /></span><span style="color: #000000">LRESULT result </span><span style="color: #000000">=</span><span style="color: #000000"> ::SendMessage(AfxGetApp()</span><span style="color: #000000">-></span><span style="color: #000000">GetMainWnd()</span><span style="color: #000000">-></span><span style="color: #000000">GetSafeHwnd(),MSG_SUBTHREAD_CMD,(WPARAM)</span><span style="color: #000000">&</span><span style="color: #000000">request,(LPARAM)</span><span style="color: #000000">&</span><span style="color: #000000">response);<br />TRACE(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,result);</span></div> <img src ="http://www.shnenglu.com/aaxron/aggbug/207508.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2014-07-04 08:33 <a href="http://www.shnenglu.com/aaxron/archive/2014/07/04/207508.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows 清除|络密码http://www.shnenglu.com/aaxron/archive/2014/04/09/206511.html天下天下Wed, 09 Apr 2014 01:21:00 GMThttp://www.shnenglu.com/aaxron/archive/2014/04/09/206511.htmlhttp://www.shnenglu.com/aaxron/comments/206511.htmlhttp://www.shnenglu.com/aaxron/archive/2014/04/09/206511.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/206511.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/206511.htmlnet use * /d /y

天下 2014-04-09 09:21 发表评论
]]>
调试VC的控制台E序Q提C找不到mmvcr70.dll,mmvcp70.dll{。。?/title><link>http://www.shnenglu.com/aaxron/archive/2013/12/12/204748.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Thu, 12 Dec 2013 07:29:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2013/12/12/204748.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/204748.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2013/12/12/204748.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/204748.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/204748.html</trackback:ping><description><![CDATA[<div><span style="font-size: 12px;">调试VC的控制台E序Q提C找不到mmvcr70.dll,mmvcp70.dll{。。?/span></div><div><span style="font-size: 12px;">“找不到coredll.dll”?</span></div><div><span style="font-size: 12px;">dll盘application试~译器system</span></div><div><span style="font-size: 12px;"> 重装pȝ后又重装了VS2008  写了一个win32 console application的helloworld做测试,l果提示“找不到coredll.dll”Q下载到该dll到system32下,又提C找不到mmvcr70.dll,mmvcp70.dll。全部下载后再次~译Q提C?#8220;无法定位序数?..?#8221;?/span></div><div><span style="font-size: 12px;">    初步分析为dll库版本问题,但苦于找不到正确的版本。在另一台机器上拯时发现该机器也没有上qDLL文g。但用该机器新徏工程试通过Q故分析错误应该是出于工E设|或库\径等处。后在JAVAEYE上找到解x案,在项?属?清单工具中将使用FAT32解决办法改ؓ“?#8221;Q重新生成,试通过?/span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">    最l找出问题的原因应该在于盘格式Q我的TEST工程是徏立在FAT32格式的盘中,q里应该属于VS2008的一个BUGQ即安装在FAT32格式盘下或工程路径在FAT32格式盘下时Q编译器即会报上q错误?/span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">Project/Properties/Manifest Tool/General/Use FAT32 Work-around => Yes</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">"链接?/"清单文g"/"生成清单"??</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")</span></div><div><span style="font-size: 12px;"><br /></span></div><div style="font-family: Tahoma; font-size: 11px;"></div><img src ="http://www.shnenglu.com/aaxron/aggbug/204748.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2013-12-12 15:29 <a href="http://www.shnenglu.com/aaxron/archive/2013/12/12/204748.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Win32讑֤上下?Device Contexts)http://www.shnenglu.com/aaxron/archive/2013/06/04/200786.html天下天下Tue, 04 Jun 2013 01:08:00 GMThttp://www.shnenglu.com/aaxron/archive/2013/06/04/200786.htmlhttp://www.shnenglu.com/aaxron/comments/200786.htmlhttp://www.shnenglu.com/aaxron/archive/2013/06/04/200786.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/200786.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/200786.html
讑֤上下?讑֤内容)
Device Contexts
A device context is a structure that defines a set of graphic objects and their associated attributes, as well as the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations. The remainder of this section is divided into the following three areas. 

About Device Contexts
Device independence is one of the chief features of Microsoft Windows. Applications can draw and print output on a variety of devices. The software that supports this device independence is contained in two dynamic-link libraries. The first, Gdi.dll, is referred to as the graphics device interface (GDI); the second is referred to as a device driver. The name of the second depends on the device where the application draws output. For example, if the application draws output in the client area of its window on a VGA display, this library is Vga.dll; if the application prints output on an Epson FX-80 printer, this library is Epson9.dll. 

An application must inform GDI to load a particular device driver and, once the driver is loaded, to prepare the device for drawing operations (such as selecting a line color and width, a brush pattern and color, a font typeface, a clipping region, and so on). These tasks are accomplished by creating and maintaining a device context (DC). A DC is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations. Unlike most of the structures, an application never has direct access to the DC; instead, it operates on the structure indirectly by calling various functions. 

This overview provides information on the following topics: 

Graphic Objects 
Graphic Modes 
Device Context Types 
Device Context Operations 
ICM-Enabled Device Context Functions 
An important concept is the layout of a DC or a window, which describes the order in which GDI objects and text are revealed (either left-to-right or right-to-left). For more information, see "Window Layout and Mirroring" in Window Features and the GetLayout and SetLayout functions. 

Device Context Types
There are four types of DCs: display, printer, memory (or compatible), and information. Each type serves a specific purpose, as described in the following table. 

Device context Description 
Display Supports drawing operations on a video display. 
Printer Supports drawing operations on a printer or plotter. 
Memory Supports drawing operations on a bitmap. 
Information Supports the retrieval of device data. 

讑֤上下文是windows~程中最重要的概念之一。widnows下的所有绘N是通过讑֤上下文进行的?nbsp;
讑֤上下文是一U包含有x个设备(如显C器或打印机Q的l制属性信息的 Windows 数据l构。所有绘制调用都通过讑֤上下文对象进行,q些对象装了用于绘制线条、Ş状和文本?Windows API。设备上下文允许?Windows 中进行与讑֤无关的绘制。设备上下文可用于绘制到屏幕、打印机或者图元文件?/div>

讑֤上下文(Device ContextQDC 
DC实际上是GDI内部保存的数据结构?/div>
DC与特定的昄讑֤Q如昄器或打印机)相关?/div>
对于昄器,DCL与显C器上的特定视窗相关?/div>
DC中的有些值是囑Ş「属性」,q些属性定义了GDIl图函数工作的细节?/div>
例如Q对於TextOutQDC的属性确定了文字的颜艌Ӏ文字的背景艌Ӏx坐标和y坐标映射到视H的昄区域的方式,以及昄文字时Windows使用的字体?/div>
MSDN的解? 一个DC是一个结构,它定义了一pd囑Ş对象的集合以及它们相关的属性,以及影响输出效果的一些图形模式。这些图形对象包括一个画U的W,一个填充和painting的画P一个用来向屏幕拯的位图,一个定义了一pd颜色集合的调色板Q一个用来剪裁等操作的区域,一个做painting和drawing操作的\径?/div>

讑֤上下?/div>
当您惛_一个图形输备(诸如屏幕或者打印机Q上l图Ӟ您首先必获得一个设备上下文Q或者DCQ的句柄。将句柄传回l程序时QWindowsq了您使用讑֤的权限。然后您在GDI函数中将q个句柄作ؓ一个参敎ͼ向Windows标识您想在其上进行绘囄讑֤?/div>

讑֤上下文中包含许多定GDI函数如何在设备上工作的目前「属性」,q些属性允怼递给GDI函数的参数只包含起始坐标或者尺怿息,而不必包含Windows在设备上昄对象旉要的所有其它信息。例如,呼叫TextOutӞ您只需要在函数中给备上下文句柄、v始坐标、文字和文字的长度。您不必指定字体、文字颜艌Ӏ文字后面的背景色彩以及字符间距Q因些属性都是设备上下文的一部分。当您想改变q些属性之一Ӟ您呼叫一个可以改变设备上下文中属性的函数Q以后针对该讑֤上下文的TextOut呼叫来用改变后的属性?/div>
取得讑֤上下文句?/div>

Windows提供了几U取得设备上下文句柄的方法。如果在处理一个消息时取得了设备上下文句柄Q应该在退出窗口函C前释攑֮Q或者删除它Q。一旦释放了句柄Q它׃再有效了。对于打印机讑֤上下文句柄,规则没有这么严根{在W十三章会讨论打印?/div>
最常用的取得ƈ释放讑֤上下文句柄的Ҏ是,在处理WM_PAINT消息Ӟ使用BeginPaint和EndPaint呼叫Q?/div>
hdc = BeginPaint (hwnd, &ps) ;
//do something
EndPaint (hwnd, &ps) ;

WindowsE序q可以在处理非WM_PAINT消息时取得设备上下文句柄Q?/div>
hdc = GetDC (hwnd) ;
//do something
ReleaseDC (hwnd, hdc) ;
        
WindowsE序q可以取得适用于整个窗口(而不仅限于窗口的昄区域Q的讑֤上下文句柄:
hdc = GetWindowDC (hwnd) ;
//do something
ReleaseDC (hwnd, hdc) ;
        
q个讑֤上下文除了显C区域之外,q包括窗口的标题列、菜单、滚动条和框ӞframeQ。GetWindowDC函数很少使用Q如果想试用一用它Q则必须拦截处理WM_NCPAINT消息QWindows使用该消息在H口的非昄区域上绘图?/div>
BeginPaint、GetDC和GetWindowDC获得的设备上下文都与视讯昄器上的某个特定窗口相兟뀂取得设备上下文句柄的另一个更通用的函数是CreateDCQ?/div>
hdc = CreateDC (pszDriver, pszDevice, pszOutput, pData) ;
//do something
DeleteDC (hdc) ;


讑֤上下文就是一个windows对象,即DC的句柄,而windows则是一U图形环境,其图形系lo人难以自信地灉|和强大。而实质上Qwidnows下的所有绘N是通过讑֤上下文进行的Q而不是直接对H口和设备本w进行?/div>

作ؓwindows的对象,讑֤上下文实际上是一Uwindows内部的数据结构?/div>
讑֤上下文同样具有着它自w的属性,只是属性比较多而已Q如下表∶

讑֤上下文属?span style="white-space: pre" class="Apple-tab-span"> 属性默认?/div>
背景?background color)  白色(white)
背景模式(background mode)  不透明(opaque)
位图(bitmap) ?none)
刷子(brush) 白色刷子(white brush)
刷子L(brush origin)  0,0
剪切?clipping region)  整个H口或设备表?entire window or device surface)
调色?color palette)  默认调色?default palette)
ȝ位置(pen position)  0,0
l图模式(drawing mode)  r2_copypen
字体(font)  pȝ字体
字间?intercharater spacing)  0
影射模式(mapping mode)  mm_text
ȝ(pen)  黑色(black)
多边形填充模?mapping mode)  alternate
伸羃模式(stretching mode)  blackonwhite
文本?text color)  黑色(black)
视口L(viewport origin)  0,0
视口范围(viewport extents)  1,1
H口L(window origin)  0,0
H口范围(window extents)  1,1



天下 2013-06-04 09:08 发表评论
]]>linux分析命o行参数getopthttp://www.shnenglu.com/aaxron/archive/2013/04/16/199484.html天下天下Tue, 16 Apr 2013 07:40:00 GMThttp://www.shnenglu.com/aaxron/archive/2013/04/16/199484.htmlhttp://www.shnenglu.com/aaxron/comments/199484.htmlhttp://www.shnenglu.com/aaxron/archive/2013/04/16/199484.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/199484.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/199484.htmlgetopt
getoptQ分析命令行参数Q?br />相关函数
表头文g
#include<unistd.h>
定义函数:
int getopt(int argc,char * const argv[ ],const char * optstring);
extern char *optarg;
extern int optind, opterr, optopt;
函数说明 getopt()用来分析命o行参数。参数argc和argv是由main()传递的参数个数和内宏V?br />参数optstring为选项字符Ԍ告知 getopt()可以处理哪个选项以及哪个选项需要参敎ͼ如果选项字符串里的字母后接着冒号“:”Q则表示q有相关的参敎ͼ
全域变量optarg 即会指向此额外参数。如果在处理期间遇到了不W合optstring指定的其他选项getopt()显CZ个错误消息,q将全域变量optarg设ؓ“?”字符Q如果不希望getopt()打印出错信息Q则只要全域变量opterr设ؓ0卛_?br />getopt() 所讄的全局变量包括Q?br />optarg——指向当前选项参数Q如果有Q的指针?nbsp;
optind——再次调用 getopt() 时的下一?nbsp;argv 指针的烦引?nbsp;
optopt——最后一个已知选项?br />补充说明下optstring中的指定的内容的意义Q例如getopt(argc, argv, "ab:c:de::");
1.单个字符Q表C选项Q(如上例中的abcde各ؓ一个选项Q?br />2.单个字符后接一个冒P表示该选项后必跟一个参数。参数紧跟在选项后或者以I格隔开。该参数的指针赋loptarg。(如上例中的b:c:Q?br />3 单个字符后跟两个冒号Q表C选项后必跟一个参数。参数必ȝ跟在选项后不能以I格隔开。该参数的指针赋loptarg?如上例中的e::)


天下 2013-04-16 15:40 发表评论
]]>win32下用getopt,从qt中弄了个getop.chttp://www.shnenglu.com/aaxron/archive/2013/04/16/199482.html天下天下Tue, 16 Apr 2013 07:24:00 GMThttp://www.shnenglu.com/aaxron/archive/2013/04/16/199482.htmlhttp://www.shnenglu.com/aaxron/comments/199482.htmlhttp://www.shnenglu.com/aaxron/archive/2013/04/16/199482.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/199482.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/199482.html//getopt.h
#pragma once
#ifdef __cplusplus
extern "C" {
#endif

extern int opterr;        /* if error message should be printed */
extern int optind;        /* index into parent argv vector */
extern int optopt;            /* character checked for validity */
extern int optreset;        /* reset getopt */
extern char    *optarg;        /* argument associated with option */
int getopt(int argc, char * const argv[], const char *optstring);

#ifdef __cplusplus
}    
#endif

getopt.c 从qt中弄?一行都没改

//getopt.c 从qt中弄?一行都没改

/* $Id: getopt.c,v 1.2 2005/07/07 16:34:06 dron Exp $ */

/*
 * Copyright (c) 1987, 1993, 1994
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 
*/

#if 0
static char sccsid[] = "@(#)getopt.c    8.3 (Berkeley) 4/27/95";
__RCSID("$NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $");
#endif

#include <stdio.h>
#include <string.h>

int    opterr = 1,        /* if error message should be printed */
    optind = 1,        /* index into parent argv vector */
    optopt,            /* character checked for validity */
    optreset;        /* reset getopt */
char    *optarg;        /* argument associated with option */

#define    BADCH    (int)'?'
#define    BADARG    (int)':'
#define    EMSG    ""

/*
 * getopt --
 *    Parse argc/argv argument vector.
 
*/
int getopt(int argc, char * const argv[], const char *optstring)
{
    static char *place = EMSG;        /* option letter processing */
    char *oli;                /* option letter list index */

    if (optreset || *place == 0) {        /* update scanning pointer */
        optreset = 0;
        place = argv[optind];
        if (optind >= argc || *place++ != '-') {
            /* Argument is absent or is not an option */
            place = EMSG;
            return (-1);
        }
        optopt = *place++;
        if (optopt == '-' && *place == 0) {
            /* "--" => end of options */
            ++optind;
            place = EMSG;
            return (-1);
        }
        if (optopt == 0) {
            /* Solitary '-', treat as a '-' option
               if the program (eg su) is looking for it. 
*/
            place = EMSG;
            if (strchr(optstring, '-') == NULL)
                return -1;
            optopt = '-';
        }
    } else
        optopt = *place++;

    /* See if option letter is one the caller wanted */
    if (optopt == ':' || (oli = strchr(optstring, optopt)) == NULL) {
        if (*place == 0)
            ++optind;
        if (opterr && *optstring != ':')
            (void)fprintf(stderr,
                                      "unknown option -- %c\n", optopt);
        return (BADCH);
    }

    /* Does this option need an argument? */
    if (oli[1] != ':') {
        /* don't need argument */
        optarg = NULL;
        if (*place == 0)
            ++optind;
    } else {
        /* Option-argument is either the rest of this argument or the
           entire next argument. 
*/
        if (*place)
            optarg = place;
        else if (argc > ++optind)
            optarg = argv[optind];
        else {
            /* option-argument absent */
            place = EMSG;
            if (*optstring == ':')
                return (BADARG);
            if (opterr)
                (void)fprintf(stderr,
                                        "option requires an argument -- %c\n",
                                        optopt);
            return (BADCH);
        }
        place = EMSG;
        ++optind;
    }
    return (optopt);            /* return option letter */
}

gnu getopt的?
//main.c
#include<stdio.h>
#ifdef WIN32
    #include "getopt.h"
#else
    #include<unistd.h>
#endif

int main(int argc,char **argv)
{
    int ch;
    opterr = 1;
    while((ch = getopt(argc,argv,"a:bcde"))!= -1)
    {
        switch(ch)
        {
            case 'a': printf("option a:'%s'\n",optarg); break;
            case 'b': printf("option b :b\n"); break;
            default:  printf("other option :%c\n",ch);
        }
    }

    printf("optopt +%c\n",optopt);
    //system("pause");
    return 0;

}


天下 2013-04-16 15:24 发表评论
]]>MFC的CFileDialog的?/title><link>http://www.shnenglu.com/aaxron/archive/2013/03/08/198294.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Fri, 08 Mar 2013 07:04:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2013/03/08/198294.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/198294.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2013/03/08/198294.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/198294.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/198294.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008000">//</span><span style="color: #008000">保存文g,指定相应的扩展名</span><span style="color: #008000"><br /></span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">const</span><span style="color: #000000"> </span><span style="color: #0000ff">char</span><span style="color: #000000"> szFilter[] </span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">指纹模板文g(*.dat)|*.dat|</span><span style="color: #000000">"</span><span style="color: #000000">;<br /></span><span style="color: #0000ff">const</span><span style="color: #000000"> </span><span style="color: #0000ff">char</span><span style="color: #000000">*</span><span style="color: #000000"> pszExt </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">.dat</span><span style="color: #000000">"</span><span style="color: #000000">;<br />DWORD dwFlag </span><span style="color: #000000">=</span><span style="color: #000000"> OFN_HIDEREADONLY </span><span style="color: #000000">|</span><span style="color: #000000"> OFN_OVERWRITEPROMPT </span><span style="color: #000000">|</span><span style="color: #000000"> OFN_EXTENSIONDIFFERENT;<br />CFileDialog dlg(FALSE,pszExt,NULL,dwFlag,szFilter);<br /></span><span style="color: #0000ff">if</span><span style="color: #000000"> (dlg.DoModal()</span><span style="color: #000000">!=</span><span style="color: #000000">IDOK)<br />{<br />    </span><span style="color: #0000ff">return</span><span style="color: #000000">;<br />}<br /><br /><br /></span><span style="color: #008000">//</span><span style="color: #008000">打开文g</span><span style="color: #008000"><br /></span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">char</span><span style="color: #000000"> szFilter[] </span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">utf-8~码的文本文?*.txt)|*.txt|</span><span style="color: #000000">"</span><span style="color: #000000">;<br />CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY </span><span style="color: #000000">|</span><span style="color: #000000"> OFN_OVERWRITEPROMPT,szFilter);<br /></span><span style="color: #0000ff">if</span><span style="color: #000000"> (dlg.DoModal()</span><span style="color: #000000">!=</span><span style="color: #000000">IDOK)<br />{<br />    </span><span style="color: #0000ff">return</span><span style="color: #000000">;<br />}<br /></span></div><img src ="http://www.shnenglu.com/aaxron/aggbug/198294.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2013-03-08 15:04 <a href="http://www.shnenglu.com/aaxron/archive/2013/03/08/198294.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC判断目录是否存在及遍历目录指定的文g.http://www.shnenglu.com/aaxron/archive/2013/01/10/197177.html天下天下Thu, 10 Jan 2013 10:22:00 GMThttp://www.shnenglu.com/aaxron/archive/2013/01/10/197177.htmlhttp://www.shnenglu.com/aaxron/comments/197177.htmlhttp://www.shnenglu.com/aaxron/archive/2013/01/10/197177.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/197177.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/197177.html// MakePhotoLog.cpp : Defines the entry point for the console application.

#include 
"stdafx.h"

#pragma pack(
1)
typedef 
struct __tag_file_info
{
    DWORD    length;    
//文g长度
    DWORD    crc32;    //暂未使用
    char    name[38];//文g?/span>
    char    res[4];     
} file_info;            
//Total = 50
#pragma pack()

long GetLocalFileSize(const char* szFileName)
{
    
struct stat f_stat;
    
if (stat(szFileName, &f_stat) == -1) {
        
return -1;
    }
    
return (long)f_stat.st_size;
}

BOOL IsDirectory(CString strPath) 
{     
    WIN32_FIND_DATA wfd;     
    HANDLE hFind 
= FindFirstFile(strPath, &wfd);     
    BOOL bRet 
= ((hFind!=INVALID_HANDLE_VALUE) &&  (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY));
    FindClose(hFind);     
    
return bRet; 
}



int main(int argc, char *argv[])
{
    WIN32_FIND_DATA wfd;
    HANDLE hFind;
    CString strPath;
    CString strFileName;
    CString strFind;
    CString strJpgFile;

    
if (argc<2)
    {
        printf(
"Usage:%s <photo-log path>\r\n",argv[0]);
        
return -1;
    }

    strPath 
= argv[1];
    
if (!IsDirectory(strPath))
    {
        printf(
"\"%s\" not found\r\n",argv[1]);
        
return -1;
    }
    
    PathAddBackslash(strPath.GetBuffer(strPath.GetLength()
+2));
    strPath.ReleaseBuffer();


    strFileName     
= strPath;
    strFileName 
+= "photo_log.dat";
    
    FILE
* fp = fopen("photo_log.dat","w+b");
    
if (fp==NULL)
    {
        printf(
"open \"%s\" error \r\n",(LPCTSTR)strFileName);
        
return -1;
    }

    strFind 
= strPath + "*.jpg";
    hFind 
= FindFirstFile(strFind, &wfd);
    
if (hFind == INVALID_HANDLE_VALUE) 
    {
        printf (
"Invalid File Handle. GetLastError reports %d\n", GetLastError ());
        
return -1;
    }
    
    BOOL bRet 
= TRUE;
    file_info fi;
    
int nSucced = 0;
    
while(bRet)
    {
        strJpgFile 
= strPath + wfd.cFileName;
        
if (strlen(wfd.cFileName)>32)
        {
            
continue;
        }
        memset(
&fi,0,sizeof(fi));
        fi.length 
= wfd.nFileSizeLow;
        strcpy(fi.name,wfd.cFileName);

        
if (fwrite(&fi,1,sizeof(fi),fp) == sizeof(fi))
        {
            nSucced
++;
            printf(
"%d. make photo-log(%s) succed\r\n", nSucced,(LPCTSTR)strJpgFile );
        }
        
else{
            printf(
"make photo-log(%s) failed\r\n", (LPCTSTR)strJpgFile );
            
break;
        }

        bRet 
= FindNextFile(hFind,&wfd);
    }
    printf(
"make photo-log(%d) succed\r\n",nSucced);
    FindClose(hFind);
    
if (fp!=NULL)
    {
        fclose(fp);
    }
    
return 0;
}





天下 2013-01-10 18:22 发表评论
]]>l典win32 SDK E序http://www.shnenglu.com/aaxron/archive/2012/08/30/188701.html天下天下Thu, 30 Aug 2012 00:54:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/08/30/188701.htmlhttp://www.shnenglu.com/aaxron/comments/188701.htmlhttp://www.shnenglu.com/aaxron/archive/2012/08/30/188701.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/188701.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/188701.html#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit

#include <atlbase.h>
#include <atlstr.h>

#define MAX_LOADSTRING 100

HINSTANCE hInst;                                // current instance
TCHAR szTitle[MAX_LOADSTRING] = "Test Windows Message";                    // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING] = "MyTestWindows";            // the main window class name

HWND main_hWnd;
HWND btn_hwnd;
DWORD btn_style = WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_CHILD;
int times = 0;
// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);

#define MY_BUTTON_ID (1001)


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    
    MSG msg;

    MyRegisterClass(hInstance);

    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (msg.hwnd == main_hWnd)
        {
            ATLTRACE("%04u,[Loop Main]MSG:0x%04X,HWND:0x%06x \r\n",times++,msg.message,msg.hwnd);
        }
        if (msg.hwnd==btn_hwnd)
        {
            ATLTRACE("%04u,[Loop Button]MSG:0x%04X,HWND:0x%06x \r\n",times++,msg.message,msg.hwnd);
        }
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int) msg.wParam;
}



ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style            = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra        = 0;
    wcex.cbWndExtra        = 0;
    wcex.hInstance        = hInstance;
    //wcex.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN05));
    wcex.hIcon            = NULL;
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
    //wcex.lpszMenuName    = MAKEINTRESOURCE(IDC_WIN05);
    wcex.lpszMenuName    = NULL;
    wcex.lpszClassName    = szWindowClass;
    //wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
    wcex.hIconSm        = NULL;

    return RegisterClassEx(&wcex);
}

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{


   hInst = hInstance; 

   main_hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, 300, 200, NULL, NULL, hInstance, NULL);

   if (!main_hWnd)
   {
      return FALSE;
   }

   ShowWindow(main_hWnd, nCmdShow);
   UpdateWindow(main_hWnd);

   return TRUE;
}


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    ATLTRACE("%04u,[Main WndProc]MSG:0x%04X,HWND:0x%06x \r\n",times++,message,hWnd);
    switch (message)
    {
    case WM_CREATE:
        {
            //ATLTRACE("Main HWND:0x%06x \r\n",main_hWnd);
            
//ATLTRACE("WndProc HWND:0x%06x \r\n",hWnd);
            btn_hwnd = CreateWindowEx(0,"BUTTON","My button",btn_style,10,10,100,50,hWnd,(HMENU)(UINT_PTR)MY_BUTTON_ID,hInst,NULL);
            //ATLTRACE("Button HWND:0x%06x \r\n",btn_hwnd);
        }

        break;
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case 1001:
            
            //MessageBox(hWnd,"abc","bcd",MB_OK);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}


天下 2012-08-30 08:54 发表评论
]]>vc2010 tr1 regexp 试http://www.shnenglu.com/aaxron/archive/2012/05/15/174968.html天下天下Tue, 15 May 2012 06:00:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/05/15/174968.htmlhttp://www.shnenglu.com/aaxron/comments/174968.htmlhttp://www.shnenglu.com/aaxron/archive/2012/05/15/174968.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/174968.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/174968.html#include "stdafx.h"
#include 
<regex>
#include 
<iostream>
#include 
<string>
#include 
<map>
using namespace std;

int main(int argc, char* argv[])
{

    
// 正则替换
    puts("//c++ 0x regex_replace()");
    
string str = "Hello 333world";
    tr1::regex rx(
"\\d+world");
    
string replacement = "planet";
    
string str2 = tr1::regex_replace(str, rx, replacement);
    cout 
<< "result:" << str2 << endl;
    
    
// map + auto
    puts("\r\n//map + auto");
    map
<stringstring> m;
    m[
"aaa"= "a111111";
    m[
"bbb"= "b22222";
    m[
"ccc"= "c33333";
    
for(auto i = m.begin(); i != m.end(); i++
    {
        cout 
<< i->first << i->second << endl;
    }
    
    
// c++ 0x regex_match()
    puts("\r\n//c++ 0x regex_match() ");
    
const regex p("(\\w+) \\w+ (\\d+) \\w+ (\\d+).*");
    
char *= "aaa bbb 333 eee 555";
    cmatch re;
    
bool ret = regex_match(s, re, p);
    
//if (ret)
    {
        
string t;
        
for(auto i = re.begin(); i != re.end(); i++)
        {
            t 
= i->first;
            t 
= t.substr(0, i->second - i->first);
            cout 
<< t << endl;
        }
    }
    
// c++ 0x regex_search()
    puts("\r\n//c++ 0x regex_search()");
    
char *s2 = "hello world. 123";
    regex p2(
"\\d+", tr1::regex_constants::icase);
    cmatch re2;
    regex_search(s2, re2, p2);
    cout 
<< "Matched \""  << re2.str()     
    << "\" after \"" << re2.prefix()     
    
<< "\" at offset: " << re2.position()     
    << " with length: " << re2.length()
    
<< endl; 
    
    
    cout 
<< tr1::regex r"(Hello "world")"


    getchar();

    
return 0;
}



天下 2012-05-15 14:00 发表评论
]]>不带~存的I/O和标准I/Ohttp://www.shnenglu.com/aaxron/archive/2012/05/10/174468.html天下天下Thu, 10 May 2012 08:53:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/05/10/174468.htmlhttp://www.shnenglu.com/aaxron/comments/174468.htmlhttp://www.shnenglu.com/aaxron/archive/2012/05/10/174468.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/174468.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/174468.html不带~存的I/O和标准I/O

首先说说不带~存的I
/OQUNIX的文件I/O read、write是不带缓存的。不带缓存是指每个read、write都调用内核的一个系l调用,它们是POSIX.1的组成部分?br />二者的原型为:
ssize_t read( 
int fd, void* buf, size_t nbytes );    // 若成功返回读到的字节?/span>
ssize_t write( int fd, const void* buf, size_t nbytes );    // 若成功返回已写的字节?/span>

注意Q上面的buf不是指read、write带缓存,而是当read时用来存放读出的字节Qwrite时存攑־写的字节。对于readQnbytes表示每次最多读的字节数。但q个块的大小媄响I
/O的效率,其值和具体pȝ有关?br />
补充一下,不带~存的I
/OҎ件描q符操作Q下面带~存的I/O是针Ҏ的?br />
标准I
/O库就是带~存的I/OQ它由ANSI C标准说明。当Ӟ标准I/O最l都会调用上面的I/O例程。标准I/O库代替用户处理很多细节,比如~存分配、以优化长度执行I/O{?br />
标准I
/O提供~存的目的就是减调用read和write的次敎ͼ它对每个I/O自动进行缓存管理(标准I/O函数通常调用malloc来分配缓存)。它提供了三U类型的~存Q?br />
1) 全缓存。当填满标准I/O~存后才执行I/O操作。磁盘上的文仉常是全~存的?br />
2) 行缓存。当输入输出遇到新行W或~存满时Q才由标准I/O库执行实际I/O操作。stdin、stdout通常是行~存的?br />
3) 无缓存。相当于read、write了。stderr通常是无~存的,因ؓ它必d快输出?br />
一般而言Q由pȝ选择~存的长度,q自动分配。标准I
/O库在关闭的时候自动释攄存?br />
在标准I
/O库中Q一个效率不高的不之处是需要复制的数据量。当每次使用行函数fgets和fputsӞ通常需要复制两ơ数据:一ơ是在内核和标准I/O~存之间Q当调用read和writeӞQ第二次是在标准I/O~存Q通常pȝ分配和管理)和用L序中的行~存Qfgets的参数就需要一个用戯~存指针Q之间?br />
不管上面讲的到底懂没懂,C一点:

使用标准I
/O例程的一个优Ҏ无需考虑~存及最佳I/O长度的选择Qƈ且它q不比直接调用read、write慢多?br />
带缓存的文g操作是标准C 库的实现Q第一ơ调用带~存的文件操作函数时标准库会自动分配内存q且d一D固定大的内容存储在缓存中。所以以后每ơ的d操作q不是针对硬盘上的文件直接进行的Q而是针对内存中的~存的。何时从盘中读取文件或者向盘中写入文件有标准库的机制控制。不带缓存的文g操作通常都是pȝ提供的系l调用,更加低Q直接从盘中读取和写入文gQ由于IO瓉的原因,速度q不如意Q而且原子操作需要程序员自己保证Q但使用得当的话效率q不差?br />另外标准库中的带~存文gIO 是调用系l提供的不带~存IO实现的?br />
“术语不带~冲指的是每个read和write都调用内怸的一个系l调用。所有的盘I
/O都要l过内核的块~冲Q也U内核的~冲区高速缓存)Q唯一例外的是对原始磁盘设备的I/O。既然read或write的数据都要被内核~冲Q那么术?#8220;不带~冲的I/O“指的是在用户的进E中对这两个函数不会自动~冲Q每ơread或writepq行一ơ系l调用?#8220;

--------摘自<unix环境~程>


天下 2012-05-10 16:53 发表评论
]]>windows路径操作API函数http://www.shnenglu.com/aaxron/archive/2012/05/02/173495.html天下天下Wed, 02 May 2012 10:04:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/05/02/173495.htmlhttp://www.shnenglu.com/aaxron/comments/173495.htmlhttp://www.shnenglu.com/aaxron/archive/2012/05/02/173495.html#Feedback1http://www.shnenglu.com/aaxron/comments/commentRss/173495.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/173495.html阅读全文

天下 2012-05-02 18:04 发表评论
]]>
CRC32法Q查表法Q代?/title><link>http://www.shnenglu.com/aaxron/archive/2012/04/18/171890.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Wed, 18 Apr 2012 10:02:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2012/04/18/171890.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/171890.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2012/04/18/171890.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/171890.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/171890.html</trackback:ping><description><![CDATA[<div> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">#include </span><span style="color: #000000"><</span><span style="color: #000000">windows.h</span><span style="color: #000000">></span><span style="color: #000000"><br />#include </span><span style="color: #000000"><</span><span style="color: #000000">stdio.h</span><span style="color: #000000">></span><span style="color: #000000"><br /><br /></span><span style="color: #0000ff">void</span><span style="color: #000000"> PrintCrcTable()<br />{<br />    </span><span style="color: #008000">//</span><span style="color: #008000">Poly = 0xedb88320 WinRAR Poly</span><span style="color: #008000"><br /></span><span style="color: #000000">    DWORD Val;<br />    </span><span style="color: #0000ff">for</span><span style="color: #000000"> (DWORD i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> </span><span style="color: #000000">256</span><span style="color: #000000">; i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />    {<br />        Val </span><span style="color: #000000">=</span><span style="color: #000000"> i;<br />        </span><span style="color: #0000ff">for</span><span style="color: #000000"> (DWORD k </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; k </span><span style="color: #000000"><</span><span style="color: #000000"> </span><span style="color: #000000">8</span><span style="color: #000000">; k</span><span style="color: #000000">++</span><span style="color: #000000">)<br />        {<br />            </span><span style="color: #0000ff">if</span><span style="color: #000000"> (Val </span><span style="color: #000000">&</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">)<br />                Val </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0xedb88320L</span><span style="color: #000000"> </span><span style="color: #000000">^</span><span style="color: #000000"> (Val </span><span style="color: #000000">>></span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">);<br />            </span><span style="color: #0000ff">else</span><span style="color: #000000"><br />                Val </span><span style="color: #000000">=</span><span style="color: #000000"> Val </span><span style="color: #000000">>></span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">;<br />        }<br />        printf (</span><span style="color: #000000">"</span><span style="color: #000000">0x%08x, </span><span style="color: #000000">"</span><span style="color: #000000">, Val);<br />        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #000000">0</span><span style="color: #000000"> </span><span style="color: #000000">==</span><span style="color: #000000"> ((i</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">)</span><span style="color: #000000">%</span><span style="color: #000000">6</span><span style="color: #000000">))<br />            printf (</span><span style="color: #000000">"</span><span style="color: #000000">\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br />    }<br />}<br /><br /><br /><br /></span><span style="color: #0000ff">const</span><span style="color: #000000"> DWORD Crc32Table[] </span><span style="color: #000000">=</span><span style="color: #000000"><br />{<br />    </span><span style="color: #000000">0x00000000</span><span style="color: #000000">, </span><span style="color: #000000">0x77073096</span><span style="color: #000000">, </span><span style="color: #000000">0xee0e612c</span><span style="color: #000000">, </span><span style="color: #000000">0x990951ba</span><span style="color: #000000">, </span><span style="color: #000000">0x076dc419</span><span style="color: #000000">, </span><span style="color: #000000">0x706af48f</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xe963a535</span><span style="color: #000000">, </span><span style="color: #000000">0x9e6495a3</span><span style="color: #000000">, </span><span style="color: #000000">0x0edb8832</span><span style="color: #000000">, </span><span style="color: #000000">0x79dcb8a4</span><span style="color: #000000">, </span><span style="color: #000000">0xe0d5e91e</span><span style="color: #000000">, </span><span style="color: #000000">0x97d2d988</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x09b64c2b</span><span style="color: #000000">, </span><span style="color: #000000">0x7eb17cbd</span><span style="color: #000000">, </span><span style="color: #000000">0xe7b82d07</span><span style="color: #000000">, </span><span style="color: #000000">0x90bf1d91</span><span style="color: #000000">, </span><span style="color: #000000">0x1db71064</span><span style="color: #000000">, </span><span style="color: #000000">0x6ab020f2</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xf3b97148</span><span style="color: #000000">, </span><span style="color: #000000">0x84be41de</span><span style="color: #000000">, </span><span style="color: #000000">0x1adad47d</span><span style="color: #000000">, </span><span style="color: #000000">0x6ddde4eb</span><span style="color: #000000">, </span><span style="color: #000000">0xf4d4b551</span><span style="color: #000000">, </span><span style="color: #000000">0x83d385c7</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x136c9856</span><span style="color: #000000">, </span><span style="color: #000000">0x646ba8c0</span><span style="color: #000000">, </span><span style="color: #000000">0xfd62f97a</span><span style="color: #000000">, </span><span style="color: #000000">0x8a65c9ec</span><span style="color: #000000">, </span><span style="color: #000000">0x14015c4f</span><span style="color: #000000">, </span><span style="color: #000000">0x63066cd9</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xfa0f3d63</span><span style="color: #000000">, </span><span style="color: #000000">0x8d080df5</span><span style="color: #000000">, </span><span style="color: #000000">0x3b6e20c8</span><span style="color: #000000">, </span><span style="color: #000000">0x4c69105e</span><span style="color: #000000">, </span><span style="color: #000000">0xd56041e4</span><span style="color: #000000">, </span><span style="color: #000000">0xa2677172</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x3c03e4d1</span><span style="color: #000000">, </span><span style="color: #000000">0x4b04d447</span><span style="color: #000000">, </span><span style="color: #000000">0xd20d85fd</span><span style="color: #000000">, </span><span style="color: #000000">0xa50ab56b</span><span style="color: #000000">, </span><span style="color: #000000">0x35b5a8fa</span><span style="color: #000000">, </span><span style="color: #000000">0x42b2986c</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xdbbbc9d6</span><span style="color: #000000">, </span><span style="color: #000000">0xacbcf940</span><span style="color: #000000">, </span><span style="color: #000000">0x32d86ce3</span><span style="color: #000000">, </span><span style="color: #000000">0x45df5c75</span><span style="color: #000000">, </span><span style="color: #000000">0xdcd60dcf</span><span style="color: #000000">, </span><span style="color: #000000">0xabd13d59</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x26d930ac</span><span style="color: #000000">, </span><span style="color: #000000">0x51de003a</span><span style="color: #000000">, </span><span style="color: #000000">0xc8d75180</span><span style="color: #000000">, </span><span style="color: #000000">0xbfd06116</span><span style="color: #000000">, </span><span style="color: #000000">0x21b4f4b5</span><span style="color: #000000">, </span><span style="color: #000000">0x56b3c423</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xcfba9599</span><span style="color: #000000">, </span><span style="color: #000000">0xb8bda50f</span><span style="color: #000000">, </span><span style="color: #000000">0x2802b89e</span><span style="color: #000000">, </span><span style="color: #000000">0x5f058808</span><span style="color: #000000">, </span><span style="color: #000000">0xc60cd9b2</span><span style="color: #000000">, </span><span style="color: #000000">0xb10be924</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x2f6f7c87</span><span style="color: #000000">, </span><span style="color: #000000">0x58684c11</span><span style="color: #000000">, </span><span style="color: #000000">0xc1611dab</span><span style="color: #000000">, </span><span style="color: #000000">0xb6662d3d</span><span style="color: #000000">, </span><span style="color: #000000">0x76dc4190</span><span style="color: #000000">, </span><span style="color: #000000">0x01db7106</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x98d220bc</span><span style="color: #000000">, </span><span style="color: #000000">0xefd5102a</span><span style="color: #000000">, </span><span style="color: #000000">0x71b18589</span><span style="color: #000000">, </span><span style="color: #000000">0x06b6b51f</span><span style="color: #000000">, </span><span style="color: #000000">0x9fbfe4a5</span><span style="color: #000000">, </span><span style="color: #000000">0xe8b8d433</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x7807c9a2</span><span style="color: #000000">, </span><span style="color: #000000">0x0f00f934</span><span style="color: #000000">, </span><span style="color: #000000">0x9609a88e</span><span style="color: #000000">, </span><span style="color: #000000">0xe10e9818</span><span style="color: #000000">, </span><span style="color: #000000">0x7f6a0dbb</span><span style="color: #000000">, </span><span style="color: #000000">0x086d3d2d</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x91646c97</span><span style="color: #000000">, </span><span style="color: #000000">0xe6635c01</span><span style="color: #000000">, </span><span style="color: #000000">0x6b6b51f4</span><span style="color: #000000">, </span><span style="color: #000000">0x1c6c6162</span><span style="color: #000000">, </span><span style="color: #000000">0x856530d8</span><span style="color: #000000">, </span><span style="color: #000000">0xf262004e</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x6c0695ed</span><span style="color: #000000">, </span><span style="color: #000000">0x1b01a57b</span><span style="color: #000000">, </span><span style="color: #000000">0x8208f4c1</span><span style="color: #000000">, </span><span style="color: #000000">0xf50fc457</span><span style="color: #000000">, </span><span style="color: #000000">0x65b0d9c6</span><span style="color: #000000">, </span><span style="color: #000000">0x12b7e950</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x8bbeb8ea</span><span style="color: #000000">, </span><span style="color: #000000">0xfcb9887c</span><span style="color: #000000">, </span><span style="color: #000000">0x62dd1ddf</span><span style="color: #000000">, </span><span style="color: #000000">0x15da2d49</span><span style="color: #000000">, </span><span style="color: #000000">0x8cd37cf3</span><span style="color: #000000">, </span><span style="color: #000000">0xfbd44c65</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x4db26158</span><span style="color: #000000">, </span><span style="color: #000000">0x3ab551ce</span><span style="color: #000000">, </span><span style="color: #000000">0xa3bc0074</span><span style="color: #000000">, </span><span style="color: #000000">0xd4bb30e2</span><span style="color: #000000">, </span><span style="color: #000000">0x4adfa541</span><span style="color: #000000">, </span><span style="color: #000000">0x3dd895d7</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xa4d1c46d</span><span style="color: #000000">, </span><span style="color: #000000">0xd3d6f4fb</span><span style="color: #000000">, </span><span style="color: #000000">0x4369e96a</span><span style="color: #000000">, </span><span style="color: #000000">0x346ed9fc</span><span style="color: #000000">, </span><span style="color: #000000">0xad678846</span><span style="color: #000000">, </span><span style="color: #000000">0xda60b8d0</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x44042d73</span><span style="color: #000000">, </span><span style="color: #000000">0x33031de5</span><span style="color: #000000">, </span><span style="color: #000000">0xaa0a4c5f</span><span style="color: #000000">, </span><span style="color: #000000">0xdd0d7cc9</span><span style="color: #000000">, </span><span style="color: #000000">0x5005713c</span><span style="color: #000000">, </span><span style="color: #000000">0x270241aa</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xbe0b1010</span><span style="color: #000000">, </span><span style="color: #000000">0xc90c2086</span><span style="color: #000000">, </span><span style="color: #000000">0x5768b525</span><span style="color: #000000">, </span><span style="color: #000000">0x206f85b3</span><span style="color: #000000">, </span><span style="color: #000000">0xb966d409</span><span style="color: #000000">, </span><span style="color: #000000">0xce61e49f</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x5edef90e</span><span style="color: #000000">, </span><span style="color: #000000">0x29d9c998</span><span style="color: #000000">, </span><span style="color: #000000">0xb0d09822</span><span style="color: #000000">, </span><span style="color: #000000">0xc7d7a8b4</span><span style="color: #000000">, </span><span style="color: #000000">0x59b33d17</span><span style="color: #000000">, </span><span style="color: #000000">0x2eb40d81</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xb7bd5c3b</span><span style="color: #000000">, </span><span style="color: #000000">0xc0ba6cad</span><span style="color: #000000">, </span><span style="color: #000000">0xedb88320</span><span style="color: #000000">, </span><span style="color: #000000">0x9abfb3b6</span><span style="color: #000000">, </span><span style="color: #000000">0x03b6e20c</span><span style="color: #000000">, </span><span style="color: #000000">0x74b1d29a</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xead54739</span><span style="color: #000000">, </span><span style="color: #000000">0x9dd277af</span><span style="color: #000000">, </span><span style="color: #000000">0x04db2615</span><span style="color: #000000">, </span><span style="color: #000000">0x73dc1683</span><span style="color: #000000">, </span><span style="color: #000000">0xe3630b12</span><span style="color: #000000">, </span><span style="color: #000000">0x94643b84</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x0d6d6a3e</span><span style="color: #000000">, </span><span style="color: #000000">0x7a6a5aa8</span><span style="color: #000000">, </span><span style="color: #000000">0xe40ecf0b</span><span style="color: #000000">, </span><span style="color: #000000">0x9309ff9d</span><span style="color: #000000">, </span><span style="color: #000000">0x0a00ae27</span><span style="color: #000000">, </span><span style="color: #000000">0x7d079eb1</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xf00f9344</span><span style="color: #000000">, </span><span style="color: #000000">0x8708a3d2</span><span style="color: #000000">, </span><span style="color: #000000">0x1e01f268</span><span style="color: #000000">, </span><span style="color: #000000">0x6906c2fe</span><span style="color: #000000">, </span><span style="color: #000000">0xf762575d</span><span style="color: #000000">, </span><span style="color: #000000">0x806567cb</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x196c3671</span><span style="color: #000000">, </span><span style="color: #000000">0x6e6b06e7</span><span style="color: #000000">, </span><span style="color: #000000">0xfed41b76</span><span style="color: #000000">, </span><span style="color: #000000">0x89d32be0</span><span style="color: #000000">, </span><span style="color: #000000">0x10da7a5a</span><span style="color: #000000">, </span><span style="color: #000000">0x67dd4acc</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xf9b9df6f</span><span style="color: #000000">, </span><span style="color: #000000">0x8ebeeff9</span><span style="color: #000000">, </span><span style="color: #000000">0x17b7be43</span><span style="color: #000000">, </span><span style="color: #000000">0x60b08ed5</span><span style="color: #000000">, </span><span style="color: #000000">0xd6d6a3e8</span><span style="color: #000000">, </span><span style="color: #000000">0xa1d1937e</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x38d8c2c4</span><span style="color: #000000">, </span><span style="color: #000000">0x4fdff252</span><span style="color: #000000">, </span><span style="color: #000000">0xd1bb67f1</span><span style="color: #000000">, </span><span style="color: #000000">0xa6bc5767</span><span style="color: #000000">, </span><span style="color: #000000">0x3fb506dd</span><span style="color: #000000">, </span><span style="color: #000000">0x48b2364b</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xd80d2bda</span><span style="color: #000000">, </span><span style="color: #000000">0xaf0a1b4c</span><span style="color: #000000">, </span><span style="color: #000000">0x36034af6</span><span style="color: #000000">, </span><span style="color: #000000">0x41047a60</span><span style="color: #000000">, </span><span style="color: #000000">0xdf60efc3</span><span style="color: #000000">, </span><span style="color: #000000">0xa867df55</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x316e8eef</span><span style="color: #000000">, </span><span style="color: #000000">0x4669be79</span><span style="color: #000000">, </span><span style="color: #000000">0xcb61b38c</span><span style="color: #000000">, </span><span style="color: #000000">0xbc66831a</span><span style="color: #000000">, </span><span style="color: #000000">0x256fd2a0</span><span style="color: #000000">, </span><span style="color: #000000">0x5268e236</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xcc0c7795</span><span style="color: #000000">, </span><span style="color: #000000">0xbb0b4703</span><span style="color: #000000">, </span><span style="color: #000000">0x220216b9</span><span style="color: #000000">, </span><span style="color: #000000">0x5505262f</span><span style="color: #000000">, </span><span style="color: #000000">0xc5ba3bbe</span><span style="color: #000000">, </span><span style="color: #000000">0xb2bd0b28</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x2bb45a92</span><span style="color: #000000">, </span><span style="color: #000000">0x5cb36a04</span><span style="color: #000000">, </span><span style="color: #000000">0xc2d7ffa7</span><span style="color: #000000">, </span><span style="color: #000000">0xb5d0cf31</span><span style="color: #000000">, </span><span style="color: #000000">0x2cd99e8b</span><span style="color: #000000">, </span><span style="color: #000000">0x5bdeae1d</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x9b64c2b0</span><span style="color: #000000">, </span><span style="color: #000000">0xec63f226</span><span style="color: #000000">, </span><span style="color: #000000">0x756aa39c</span><span style="color: #000000">, </span><span style="color: #000000">0x026d930a</span><span style="color: #000000">, </span><span style="color: #000000">0x9c0906a9</span><span style="color: #000000">, </span><span style="color: #000000">0xeb0e363f</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x72076785</span><span style="color: #000000">, </span><span style="color: #000000">0x05005713</span><span style="color: #000000">, </span><span style="color: #000000">0x95bf4a82</span><span style="color: #000000">, </span><span style="color: #000000">0xe2b87a14</span><span style="color: #000000">, </span><span style="color: #000000">0x7bb12bae</span><span style="color: #000000">, </span><span style="color: #000000">0x0cb61b38</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x92d28e9b</span><span style="color: #000000">, </span><span style="color: #000000">0xe5d5be0d</span><span style="color: #000000">, </span><span style="color: #000000">0x7cdcefb7</span><span style="color: #000000">, </span><span style="color: #000000">0x0bdbdf21</span><span style="color: #000000">, </span><span style="color: #000000">0x86d3d2d4</span><span style="color: #000000">, </span><span style="color: #000000">0xf1d4e242</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x68ddb3f8</span><span style="color: #000000">, </span><span style="color: #000000">0x1fda836e</span><span style="color: #000000">, </span><span style="color: #000000">0x81be16cd</span><span style="color: #000000">, </span><span style="color: #000000">0xf6b9265b</span><span style="color: #000000">, </span><span style="color: #000000">0x6fb077e1</span><span style="color: #000000">, </span><span style="color: #000000">0x18b74777</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x88085ae6</span><span style="color: #000000">, </span><span style="color: #000000">0xff0f6a70</span><span style="color: #000000">, </span><span style="color: #000000">0x66063bca</span><span style="color: #000000">, </span><span style="color: #000000">0x11010b5c</span><span style="color: #000000">, </span><span style="color: #000000">0x8f659eff</span><span style="color: #000000">, </span><span style="color: #000000">0xf862ae69</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x616bffd3</span><span style="color: #000000">, </span><span style="color: #000000">0x166ccf45</span><span style="color: #000000">, </span><span style="color: #000000">0xa00ae278</span><span style="color: #000000">, </span><span style="color: #000000">0xd70dd2ee</span><span style="color: #000000">, </span><span style="color: #000000">0x4e048354</span><span style="color: #000000">, </span><span style="color: #000000">0x3903b3c2</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xa7672661</span><span style="color: #000000">, </span><span style="color: #000000">0xd06016f7</span><span style="color: #000000">, </span><span style="color: #000000">0x4969474d</span><span style="color: #000000">, </span><span style="color: #000000">0x3e6e77db</span><span style="color: #000000">, </span><span style="color: #000000">0xaed16a4a</span><span style="color: #000000">, </span><span style="color: #000000">0xd9d65adc</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x40df0b66</span><span style="color: #000000">, </span><span style="color: #000000">0x37d83bf0</span><span style="color: #000000">, </span><span style="color: #000000">0xa9bcae53</span><span style="color: #000000">, </span><span style="color: #000000">0xdebb9ec5</span><span style="color: #000000">, </span><span style="color: #000000">0x47b2cf7f</span><span style="color: #000000">, </span><span style="color: #000000">0x30b5ffe9</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xbdbdf21c</span><span style="color: #000000">, </span><span style="color: #000000">0xcabac28a</span><span style="color: #000000">, </span><span style="color: #000000">0x53b39330</span><span style="color: #000000">, </span><span style="color: #000000">0x24b4a3a6</span><span style="color: #000000">, </span><span style="color: #000000">0xbad03605</span><span style="color: #000000">, </span><span style="color: #000000">0xcdd70693</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0x54de5729</span><span style="color: #000000">, </span><span style="color: #000000">0x23d967bf</span><span style="color: #000000">, </span><span style="color: #000000">0xb3667a2e</span><span style="color: #000000">, </span><span style="color: #000000">0xc4614ab8</span><span style="color: #000000">, </span><span style="color: #000000">0x5d681b02</span><span style="color: #000000">, </span><span style="color: #000000">0x2a6f2b94</span><span style="color: #000000">,<br />    </span><span style="color: #000000">0xb40bbe37</span><span style="color: #000000">, </span><span style="color: #000000">0xc30c8ea1</span><span style="color: #000000">, </span><span style="color: #000000">0x5a05df1b</span><span style="color: #000000">, </span><span style="color: #000000">0x2d02ef8d</span><span style="color: #000000"><br />};<br /><br />DWORD GenerateCrc32(DWORD PartialCrc,PUCHAR  Buffer,DWORD   Length)<br />{<br />    DWORD crc;<br />    DWORD i;<br /><br />    </span><span style="color: #008000">//</span><span style="color: #008000"> Generate the CRC32 checksum.</span><span style="color: #008000"><br /></span><span style="color: #000000">    crc </span><span style="color: #000000">=</span><span style="color: #000000"> PartialCrc </span><span style="color: #000000">^</span><span style="color: #000000"> </span><span style="color: #000000">0xffffffffL</span><span style="color: #000000">;<br /><br />    </span><span style="color: #0000ff">for</span><span style="color: #000000"> (i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> Length; i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />    {<br />        crc </span><span style="color: #000000">=</span><span style="color: #000000"> Crc32Table[(crc </span><span style="color: #000000">^</span><span style="color: #000000"> Buffer[i]) </span><span style="color: #000000">&</span><span style="color: #000000"> </span><span style="color: #000000">0xff</span><span style="color: #000000">] </span><span style="color: #000000">^</span><span style="color: #000000"> (crc </span><span style="color: #000000">>></span><span style="color: #000000"> </span><span style="color: #000000">8</span><span style="color: #000000">);<br />    }<br /><br />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> (crc </span><span style="color: #000000">^</span><span style="color: #000000"> </span><span style="color: #000000">0xffffffffL</span><span style="color: #000000">);<br />}<br /><br /></span><span style="color: #008000">//</span><span style="color: #008000">试E序</span><span style="color: #008000"><br /></span><span style="color: #0000ff">int</span><span style="color: #000000"> main(</span><span style="color: #0000ff">int</span><span style="color: #000000"> argc,</span><span style="color: #0000ff">char</span><span style="color: #000000">*</span><span style="color: #000000"> argv[])<br />{<br />    </span><span style="color: #0000ff">char</span><span style="color: #000000">*</span><span style="color: #000000"> szFileName </span><span style="color: #000000">=</span><span style="color: #000000"> NULL;<br />    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (argc</span><span style="color: #000000"><</span><span style="color: #000000">2</span><span style="color: #000000">)<br />    {<br />        printf(</span><span style="color: #000000">"</span><span style="color: #000000">Usage:%s <filename> \r\n</span><span style="color: #000000">"</span><span style="color: #000000">,argv[</span><span style="color: #000000">0</span><span style="color: #000000">]);<br />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;<br />    }<br />    szFileName </span><span style="color: #000000">=</span><span style="color: #000000"> argv[</span><span style="color: #000000">1</span><span style="color: #000000">];<br />    FILE </span><span style="color: #000000">*</span><span style="color: #000000">fp </span><span style="color: #000000">=</span><span style="color: #000000"> fopen(szFileName,</span><span style="color: #000000">"</span><span style="color: #000000">rb</span><span style="color: #000000">"</span><span style="color: #000000">);<br />    </span><span style="color: #0000ff">if</span><span style="color: #000000">(NULL </span><span style="color: #000000">==</span><span style="color: #000000"> fp) <br />    {<br />        printf(</span><span style="color: #000000">"</span><span style="color: #000000">Open %s error:%d \r\n</span><span style="color: #000000">"</span><span style="color: #000000">,szFileName);<br />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />    }<br /><br />    DWORD crc32 </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />    BYTE c </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />    </span><span style="color: #0000ff">while</span><span style="color: #000000">(</span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000">==</span><span style="color: #000000"> fread(</span><span style="color: #000000">&</span><span style="color: #000000">c,</span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">1</span><span style="color: #000000">,fp))<br />        crc32 </span><span style="color: #000000">=</span><span style="color: #000000"> GenerateCrc32(crc32,</span><span style="color: #000000">&</span><span style="color: #000000">c,</span><span style="color: #000000">1</span><span style="color: #000000">);<br /><br />    fclose(fp);<br /><br />    printf(</span><span style="color: #000000">"</span><span style="color: #000000">CRC32 = 0x%08X</span><span style="color: #000000">"</span><span style="color: #000000">, crc32);<br />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />}</span></div></div><img src ="http://www.shnenglu.com/aaxron/aggbug/171890.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2012-04-18 18:02 <a href="http://www.shnenglu.com/aaxron/archive/2012/04/18/171890.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>条g~译宏小l?http://www.shnenglu.com/aaxron/archive/2012/04/18/171838.html天下天下Wed, 18 Apr 2012 02:41:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/04/18/171838.htmlhttp://www.shnenglu.com/aaxron/comments/171838.htmlhttp://www.shnenglu.com/aaxron/archive/2012/04/18/171838.html#Feedback1http://www.shnenglu.com/aaxron/comments/commentRss/171838.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/171838.html~码的时候经常要用到条g~译Q每ơ都到网上去查比较浪Ҏ_今天ȝ一下以备后?br />
    ~译?br />         GCC
        #ifdef __GNUC__
            #if __GNUC__ >= 3 // GCC3.0以上
        Visual C++
        #ifdef _MSC_VERQ非VC~译器很多地方也有定义)
            #if _MSC_VER >=1000 // VC++4.0以上
            #if _MSC_VER >=1100 // VC++5.0以上
            #if _MSC_VER >=1200 // VC++6.0以上
            #if _MSC_VER >=1300 // VC2003以上
            #if _MSC_VER >=1400 // VC2005以上
        Borland C++
        #ifdef __BORLANDC__
    UNIX
        UNIX
        #ifdef __unix
        or
        #ifdef __unix__
        Linux
        #ifdef __linux
        or
        #ifdef __linux__
        FreeBSD
        #ifdef __FreeBSD__
        NetBSD
        #ifdef __NetBSD__
    Windows
        32bit
        #ifdef _WIN32Q或者WIN32Q?br />         64bit
        #ifdef _WIN64
        GUI  App
        #ifdef _WINDOWS 
        CUI  App
        #ifdef _CONSOLE
        Windows的Ver … WINVER
        ※ PC机WindowsQ?5/98/Me/NT/2000/XP/VistaQ和Windows CE都定义了
            #if (WINVER >= 0x030a) // Windows 3.1以上
            #if (WINVER >= 0x0400) // Windows 95/NT4.0以上
            #if (WINVER >= 0x0410) // Windows 98以上
            #if (WINVER >= 0x0500) // Windows Me/2000以上
            #if (WINVER >= 0x0501) // Windows XP以上
            #if (WINVER >= 0x0600) // Windows Vista以上
        Windows 95/98/Me的Ver … _WIN32_WINDOWS
            MFC App、PCZQWindows CE没有定义Q?br />             #ifdef _WIN32_WINDOWS
            #if (_WIN32_WINDOWS >= 0x0400) // Windows 95以上
            #if (_WIN32_WINDOWS >= 0x0410) // Windows 98以上
            #if (_WIN32_WINDOWS >= 0x0500) // Windows Me以上
        Windows NT的Ver … _WIN32_WINNT
            #if (_WIN32_WINNT >= 0x0500) // Windows 2000以上
            #if (_WIN32_WINNT >= 0x0501) // Windows XP以上
            #if (_WIN32_WINNT >= 0x0600) // Windows Vista以上
        Windows CEQPocketPCQ?br />         #ifdef _WIN32_WCE
        Windows CE … WINCEOSVER
        Windows CE
        WCE_IF
        Internet Explorer的Ver … _WIN32_IE 
    Cygwin
        Cygwin
        #ifdef __CYGWIN__
        32bit版CygwinQ现在好像还没有64bit版)
        #ifdef __CYGWIN32__
        MinGWQ?mno-cygwin指定Q?br />         #ifdef __MINGW32__

转:http://blog.csdn.net/immcss/article/details/3881827



天下 2012-04-18 10:41 发表评论
]]>UTF-8字符?/title><link>http://www.shnenglu.com/aaxron/archive/2012/03/27/169116.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Tue, 27 Mar 2012 03:30:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2012/03/27/169116.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/169116.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2012/03/27/169116.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/169116.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/169116.html</trackback:ping><description><![CDATA[<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 />-->#include <atlbase.h><br /> <span style="color: #0000FF; ">int</span> main()<br /> {<br />     <span style="color: #0000FF; ">char</span>* pszOctText = "\344\270\273\346\234\272\345\220\215"; <span style="color: #008000; ">//</span><span style="color: #008000; ">"L? , 8q制格式,UTF-8~码</span><span style="color: #008000; "><br /></span>     <span style="color: #0000FF; ">char</span>* pszHexText = "\xe5\x8d\xa1\xe5\x8f\xb7";               <span style="color: #008000; ">//</span><span style="color: #008000; ">"卡号" ,   16q制格式,UTF-8~码</span><span style="color: #008000; "><br /></span>     <span style="color: #0000FF; ">char</span> *pszUnicodeText="\u73b0\u4ee3\u8857\u666f";           <span style="color: #008000; ">//</span><span style="color: #008000; ">C街景,Unicode character</span><span style="color: #008000; "><br /></span> <br />     CString strText1 = CA2W(pszOctText,CP_UTF8);<br />     CString strText2 = CA2W(pszHexText,CP_UTF8);<br /> <br />     <span style="color: #008000; ">//</span><span style="color: #008000; ">MessageBox(NULL,strText2,strText1,MB_OK);</span><span style="color: #008000; "><br /></span> <br />     puts(CW2A(strText1));<br />     puts(CW2A(strText2,CP_ACP));<br />     puts(pszUnicodeText);<br /> <br />     system("pause");<br />     <span style="color: #0000FF; ">return</span> 0;<br /> }</div><img src ="http://www.shnenglu.com/aaxron/aggbug/169116.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2012-03-27 11:30 <a href="http://www.shnenglu.com/aaxron/archive/2012/03/27/169116.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>单的CInfoTipc?/title><link>http://www.shnenglu.com/aaxron/archive/2012/02/18/165921.html</link><dc:creator>天下</dc:creator><author>天下</author><pubDate>Sat, 18 Feb 2012 09:36:00 GMT</pubDate><guid>http://www.shnenglu.com/aaxron/archive/2012/02/18/165921.html</guid><wfw:comment>http://www.shnenglu.com/aaxron/comments/165921.html</wfw:comment><comments>http://www.shnenglu.com/aaxron/archive/2012/02/18/165921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aaxron/comments/commentRss/165921.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aaxron/services/trackbacks/165921.html</trackback:ping><description><![CDATA[<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: #008000; ">//</span><span style="color: #008000; ">file:InfoTip.h</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">#pragma once<br />#include </span><span style="color: #000000; "><</span><span style="color: #000000; ">atlwin.h</span><span style="color: #000000; ">></span><span style="color: #000000; "><br /></span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> CInfoTip : <br />    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> ATL::CWindowImpl</span><span style="color: #000000; "><</span><span style="color: #000000; ">CInfoTip</span><span style="color: #000000; ">></span><span style="color: #000000; "> <br />{ <br /></span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">: <br />    DECLARE_WND_CLASS_EX(NULL, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">, COLOR_3DFACE) <br /><br />    LPCTSTR m_lpstrInfo; <br /><br />    </span><span style="color: #0000FF; ">enum</span><span style="color: #000000; "> { m_nToolTipID </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1313</span><span style="color: #000000; "> }; <br />    WTL::CToolTipCtrl m_tooltip; <br /><br /><br />    CInfoTip():m_lpstrInfo(NULL) <br />    { } <br /><br />    </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> Init(HWND hWnd, LPCTSTR lpstrName) <br />    { <br />        ATLASSERT(::IsWindow(hWnd)); <br />        SubclassWindow(hWnd); <br /><br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; "> Set tooltip </span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        m_tooltip.Create(m_hWnd); <br />        ATLASSERT(m_tooltip.IsWindow()); <br />        RECT rect; <br />        GetClientRect(</span><span style="color: #000000; ">&</span><span style="color: #000000; ">rect); <br />        CToolInfo ti(</span><span style="color: #000000; ">0</span><span style="color: #000000; ">, m_hWnd, m_nToolTipID, </span><span style="color: #000000; ">&</span><span style="color: #000000; ">rect, NULL); <br />        m_tooltip.AddTool(</span><span style="color: #000000; ">&</span><span style="color: #000000; ">ti); <br /><br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; "> set text </span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        m_lpstrInfo </span><span style="color: #000000; ">=</span><span style="color: #000000; "> lpstrName; <br />        </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(m_lpstrInfo </span><span style="color: #000000; ">==</span><span style="color: #000000; "> NULL) <br />            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">; <br /><br />        m_tooltip.UpdateTipText(m_lpstrInfo, m_hWnd, m_nToolTipID); <br />        m_tooltip.Activate(</span><span style="color: #0000FF; ">true</span><span style="color: #000000; ">); <br />    } <br /><br />    BEGIN_MSG_MAP(CInfoTip) <br />        MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST,OnMouseMessage) <br />    END_MSG_MAP() <br /><br />    LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL</span><span style="color: #000000; ">&</span><span style="color: #000000; "> bHandled) <br />    { <br />        </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(m_tooltip.IsWindow()) <br />        { <br />            MSG msg </span><span style="color: #000000; ">=</span><span style="color: #000000; "> { m_hWnd, uMsg, wParam, lParam }; <br />            m_tooltip.RelayEvent(</span><span style="color: #000000; ">&</span><span style="color: #000000; ">msg); <br />        } <br />        bHandled </span><span style="color: #000000; ">=</span><span style="color: #000000; "> FALSE; <br />        </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">; <br />    } <br />}; <br /><br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">使用:</span><span style="color: #008000; "><br /></span><span style="color: #000000; "><br />    CInfoTip m_InfoTipEdit;<br />    m_InfoTipEdit.Init(   GetDlgItem(   IDOK   ),   </span><span style="color: #000000; ">"</span><span style="color: #000000; ">输入密码 </span><span style="color: #000000; ">"</span><span style="color: #000000; ">     ); </span></div><img src ="http://www.shnenglu.com/aaxron/aggbug/165921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aaxron/" target="_blank">天下</a> 2012-02-18 17:36 <a href="http://www.shnenglu.com/aaxron/archive/2012/02/18/165921.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>How to move a dialog which does not have a caption(非标题栏Ud对话?http://www.shnenglu.com/aaxron/archive/2012/02/16/165724.html天下天下Thu, 16 Feb 2012 02:24:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/02/16/165724.htmlhttp://www.shnenglu.com/aaxron/comments/165724.htmlhttp://www.shnenglu.com/aaxron/archive/2012/02/16/165724.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/165724.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/165724.html
How to move a dialog which does not have a caption
Introduction
This article is aimed at beginners, and presents two ways to move a dialog which does not have a caption by dragging its client area.
1. WM_SYSCOMMAND message
Sending the WM_SYSCOMMAND message starts the move operation. Add the following code to handle the mouse down event:
BEGIN_MSG_MAP(CMainDlg)
    
//...
    MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
END_MSG_MAP()

LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
& bHandled)
{
    SendMessage(WM_SYSCOMMAND, SC_MOVE
|HTCAPTION);
    
return 0;
}


2. WM_NCHITTEST message
The idea is to handle the WM_NCHITTEST message to return HTCAPTION instead of HTCLIENT when the mouse is in the client area, to trick Windows to start moving the dialog.
BEGIN_MSG_MAP(CMainDlg)
    
//...
    MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)
END_MSG_MAP()

LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
& bHandled)
{
    
if (::DefWindowProc(m_hWnd, uMsg, wParam, lParam) == 
        HTCLIENT 
&& ::GetAsyncKeyState(MK_LBUTTON) < 0)
      
return HTCAPTION;

    
return 0;
}

//For MFC
//Devil for ever supplied the MFC solution that is shown below (thanks!). The idea is the same - to handle the WM_NCHITTEST message.
UINT OnNcHitTest(CPoint point)
{
    UINT nHit 
= CDialog::OnNcHitTest(point);
    
return (nHit == HTCLIENT ? HTCAPTION : nHit);
}


天下 2012-02-16 10:24 发表评论
]]>Win32SDK:GetModuleHandlehttp://www.shnenglu.com/aaxron/archive/2012/02/15/165648.html天下天下Wed, 15 Feb 2012 01:49:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/02/15/165648.htmlhttp://www.shnenglu.com/aaxron/comments/165648.htmlhttp://www.shnenglu.com/aaxron/archive/2012/02/15/165648.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/165648.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/165648.html
当一个文件被映射到调用进E的地址I间ӞGetModuleHandle函数得到其中某一模块的句柄?nbsp;
使用GetModuleHandle函数格式Q?/div>
HMODULE WINAPI GetModuleHandle( __in LPCTSTR lpModuleName );
 
参数 lpModuleNameQ?/div>
[in]用指针指向一个包含模块名以NULL字符l尾的串Q模块是.dll?exe文g?/div>
当指定一个\径时Q确定要用反斜线Q\Q,而不是斜U(/Q。这个模块名和当前映射到调用进E地址I间的模块名q行独立地比较? 
假如q个参数是NULLQ函数将q回创徏调用q程Q?exe文gQ的文g的句柄。 
 
q回| 
如果函数调用成功Q返回值是某一模块的句柄?如果函数调用p|Q返回NULL。要得知更多的出错信息,调用GetLastError。 


天下 2012-02-15 09:49 发表评论
]]>WTL::CFileDialoghttp://www.shnenglu.com/aaxron/archive/2012/02/13/165467.html天下天下Mon, 13 Feb 2012 03:09:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/02/13/165467.htmlhttp://www.shnenglu.com/aaxron/comments/165467.htmlhttp://www.shnenglu.com/aaxron/archive/2012/02/13/165467.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/165467.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/165467.html//MFC
CFileDialog dlg(TRUE,NULL,NULL,NULL,"数据文档(*.dat)|*.dat|模板文g(*.fpmb)|*.fpmb||"); 

//WTL  
WTL::CFileDialog dlg(TRUE,NULL,NULL,NULL,"数据文(*.dat)\0*.dat\0模板文g(*.fpmb)\0*.fpmb\0\0");

其中文gqo?MFC?/span>|分隔,而WTL以\0分隔.

WTL::CFileDialog dlg(TRUE,0,0,OFN_EXPLORER,_T("Pictures (*.bmp;*.jpg;*.png)\0*.bmp;*.jpg;*.png\0All files (*.*)\0 *.*\0"),*this);




天下 2012-02-13 11:09 发表评论
]]>捕获控制台等异常http://www.shnenglu.com/aaxron/archive/2012/02/07/165082.html天下天下Tue, 07 Feb 2012 03:02:00 GMThttp://www.shnenglu.com/aaxron/archive/2012/02/07/165082.htmlhttp://www.shnenglu.com/aaxron/comments/165082.htmlhttp://www.shnenglu.com/aaxron/archive/2012/02/07/165082.html#Feedback0http://www.shnenglu.com/aaxron/comments/commentRss/165082.htmlhttp://www.shnenglu.com/aaxron/services/trackbacks/165082.html#define WIN32_LEAN_AND_MEAN   
#include 
<windows.h>
#include 
<tchar.h>
#include 
<iostream>
#include 
<signal.h>


BOOL WINAPI ConsoleHandler(DWORD dwCtrlType );
                           
                          

int main(int argc, char *argv[])
{
    
if (SetConsoleCtrlHandler( (PHANDLER_ROUTINE)ConsoleHandler,TRUE)==FALSE)
    {
        
// unable to install handler 
        
// display message to the user
        printf("Unable to install handler!\n");
        
return -1;
    }


    
while(true)
    {

    }
}

BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
    
char mesg[128];

    
switch(CEvent)
    {
    
case CTRL_C_EVENT:
        MessageBox(NULL,
            _T(
"CTRL+C received!"),_T("CEvent"),MB_OK);
        
break;
    
//case CTRL_BREAK_EVENT:
    
//    MessageBox(NULL,
    
//        _T("CTRL+BREAK received!"),_T("CEvent"),MB_OK);
    
//    break;
    
//case CTRL_CLOSE_EVENT:
    
//    MessageBox(NULL,
    
//        _T("Program being closed!"),_T("CEvent"),MB_OK);
    
//    break;
    
//case CTRL_LOGOFF_EVENT:
    
//    MessageBox(NULL,
    
//        _T("User is logging off!"),_T("CEvent"),MB_OK);
    
//    break;
    
//case CTRL_SHUTDOWN_EVENT:
    
//    MessageBox(NULL,
    
//        _T("User is logging off!"),_T("CEvent"),MB_OK);
    
//    break;
    }
    
return TRUE;
}


天下 2012-02-07 11:02 发表评论
]]>
ݺɫݺݺݺݺɫۺϾþ | þþƷAVþþ| þþþþüƷþþ | ݺɫþۺͼƬ | þۺϾþþ| þĻר| Ʒþþ21p| þþþþþۺձ| þþþAVվ| ѾƷþ| þۺϾþۺϾþ| vaþþþ | һɫۺþ| ëƬþþþþùëƬ| ҹþþӰԺ| Ʒþþþþù| þþ޾Ʒ| ޹һɾþþƷۺ| ۺϾƷ㽶þ| þþþƷƵѹۿ| ҹþӰԺ| Ļɫ͵͵þ| ԾþþӰԺ| ھƷþþþþþþ | ŷ˾þۺһ | þѸƵ| պһþ| þ㽶߿ۿè?v| þþƷAVȫ| þݺҹҹavapp| ŷþþþþþѡ9999| 鶹ŷۺϾþ | þþƷѿ޹AV| þþŷղAV| ձ޿һþ| ݺݾþۺ˲| þùƷ| ŷ龫Ʒþþþ| 91þþžվ | þֻǾƷ23| ɫ͵͵88ŷƷþþ|