??xml version="1.0" encoding="utf-8" standalone="yes"?>7777精品伊人久久久大香线蕉,粉嫩小泬无遮挡久久久久久,久久久久国产亚洲AV麻豆http://www.shnenglu.com/erran/category/5347.htmlzh-cnFri, 01 Jul 2011 07:08:53 GMTFri, 01 Jul 2011 07:08:53 GMT60Invalidate和UpdateWindow的区?/title><link>http://www.shnenglu.com/erran/archive/2011/07/01/149901.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Fri, 01 Jul 2011 05:55:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2011/07/01/149901.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/149901.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2011/07/01/149901.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/149901.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/149901.html</trackback:ping><description><![CDATA[<div>Invalidate和UpdateWindow的区?br />Invalidate在消息队列中加入一条WM_PAINT消息Q其无效Zؓ整个客户区?br />UpdateWindow直接发送一个WM_PAINT消息Q其无效围就是消息队列中WM_PAINT消息Q最多只有一条)的无效区?br />效果很明显,当调用Invalidate之后Q屏q不一定马上更斎ͼ因ؓWM_PAINT消息不一定在队列头部Q而调用UpdateWindow会WM_PAINT消息马上执行的,l过了消息队列?br />如果调用Invalidate之后想马上更新屏q,那就加上UpdateWindow()q条语句?</div> <div>MSDN的解?<br />UpdateWindow <br />The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT </div> <div>message to the window if the window's update region is not empty. The function sends a WM_PAINT</div> <div>message directly to the window procedure of the specified window, bypassing the application queue. </div> <div>If the update region is empty, no message is sent. </div> <div>InvalidateRect <br />The system sends a WM_PAINT message to a window whenever its update region is not empty and</div> <div>there are no other messages in the application queue for that window. </div> <div>译成中文大概的解释如下Q?<br />UpdateWindowQ如果有无效区,则马上sending a WM_PAINT message到窗口处理过E,不进消息队列q行排队{待Q立卛_新窗口,否则Q什么都不做?<br />InvalidateRectQ设|无效区Q如果ؓNULL参数Q则讄整个H口为无效区。当应用E序的那个窗口的消息队列为空Ӟ则sending a WM_PAINT message(即更新区域为空).在sending a WM_PAINT message的所有InvalidateRect的更新区域会累加?<br /></div> <div>1:讄无效?<br />InvalidateRect </div> <div>2Q立卛_?<br />UpdateWindow(); </div> <div>如果不调?InvalidateRectp?UpdateWindowQ那么UpdateWindow什么都不做???????<br />如果调用 InvalidateRect 后不调用UpdateWindowQ则pȝ会自动在H口消息队列为空的时候,pȝ自动发送一WM_PAINT消息?<br /></div> <div>调用UpdateWindow()时将会发送一个WM_PAINT消息Q而应用程序在接收到WM_PAINT消息后,自动地调用Invalidate(),所以,在程序代码中Q不一定要出现Invalidate()!</div> <div>UpdateWindow()是立即发送WM_PAINT消息,只对声明无效的区域v作用Q?<br />Invalidate()则是声明无效的方式之一?/div> <div>Invalidate()表示客户区域无效Q在下次WM_PAINT发生旉l。而WM_PAINT是由pȝq行l护的,每当CWnd的更新区域不为空Qƈ且在应用E序的窗口消息队列中没有其它消息ӞWindows发送一条WM_PAINT消息?<br />Invalidate里面有个bool型的参数Q用来标识重l的时候是否用背景色填充。是不是用SetBkcolor函数Q下ȝl研I?/div> <div>updateWindow则是要求pȝ对区域进行立即重l?/div> <div>看到有h在网上提出问题,他在Invalidate后面又写了绘囄函数但是没有执行Q因为invalidate执行q以后{到PAINT命o了。所以后面的都没有显C?/div> <div>也终于想通我l的图一直在闪啊闪,因ؓ我在PAINT里面用到Invalidate()函数Q所以他不停的自嵌套Q倒是l的图不停的闪?/div> <div></div> <div>Invalidate让客户区处于可以重画的状态,而UpdateWindow开始重画,但是它先判断客户区是否ؓI,不空UpdateWindow不执行,为空才执行重甅R?/div> <div></div> <div>Invalidat最后也是调用InvalidatRect,在windows API里只有InvalidatRect?/div><img src ="http://www.shnenglu.com/erran/aggbug/149901.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2011-07-01 13:55 <a href="http://www.shnenglu.com/erran/archive/2011/07/01/149901.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC中的一些常用方?/title><link>http://www.shnenglu.com/erran/archive/2007/10/14/34185.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 16:38:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2007/10/14/34185.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/34185.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2007/10/14/34185.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/34185.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/34185.html</trackback:ping><description><![CDATA[ <font face="Arial"> <br /> <strong>一、打开CD-ROM <br /></strong>mciSendString("Set cdAudio door open wait",NULL,0,NULL); <br /><br /><strong>二、关闭CD_ROM</strong> <br />mciSendString("Set cdAudio door closed wait",NULL,0,NULL); <br /><br /><strong>三、关闭计机 <br /></strong>OSVERSIONINFO OsVersionInfo; //包含操作pȝ版本信息的数据结构?br />OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); <br />GetVersionEx(&OsVersionInfo); //获取操作pȝ版本信息 <br />if(OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) <br />{ <br />//Windows98,调用ExitWindowsEx()函数重新启动计算机?br /><br />DWORD dwReserved; <br />ExitWindowsEx(EWX_REBOOT,dwReserved); //可以改变W一个参敎ͼ实现注销用户、?br />//x、关闭电源等操作 <br />// 退出前的一些处理程序?br />} <br /><br /><strong>四、重启计机 <br /></strong>typedef int (CALLBACK *SHUTDOWNDLG)(int); //昄x对话框函数的指针 <br />HINSTANCE hInst = LoadLibrary("shell32.dll"); //装入shell32.dll <br />SHUTDOWNDLG ShutDownDialog; //指向shell32.dll库中昄x对话框函数的指针 <br />if(hInst != NULL) <br />{ <br />//获得函数的地址q调用之 <br />ShutDownDialog = (SHUTDOWNDLG)GetProcAddress(hInst,(LPSTR)60); <br /><br />(*ShutDownDialog)(0); <br />} <br /><br /><strong>五、枚举所有字体?br /></strong>LOGFONT lf; <br />lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure <br />strcpy(lf.lfFaceName,""); <br />CClientDC dc (this); <br />// Enumerate the font families <br />::EnumFontFamiliesEx((HDC) dc,&lf,                                                                                       <br />(FONTENUMPROC) EnumFontFamProc,(LPARAM) this,0); <br />//枚D函数 <br />int CALLBACK EnumFontFamProc(LPENUMLOGFONT lpelf, <br />LPNEWTEXTMETRIC lpntm,DWORD nFontType,long lparam) <br /><br />{ <br />// Create a pointer to the dialog window <br />CDay7Dlg* pWnd = (CDay7Dlg*) lparam; <br />// add the font name to the list box <br />pWnd ->m_ctlFontList.AddString(lpelf ->elfLogFont.lfFaceName); <br />// Return 1 to continue font enumeration <br />return 1; <br />} <br />其中m_ctlFontList是一个列表控件变量?br /><br /><strong>六、一ơ只q行一个程序实例,如果已运行则退?/strong> <br />if( FindWindow(NULL,"E序标题")) exit(0); <br /><br /><strong>七、得到当前鼠标所在位|?/strong> <br />CPoint pt; <br />GetCursorPos(&pt); //得到位置 <br /><br /><strong>八、上下文菜单事g触发事gQOnContextMenu事g <br /></strong><br /><strong>九、显C和隐藏E序菜单 <br /></strong>CWnd *pWnd=AfxGetMainWnd(); <br />if(b_m) //隐藏菜单 <br />{ <br />pWnd->SetMenu(NULL); <br />pWnd->DrawMenuBar(); <br />b_m=false; <br />} <br />else <br />{ <br />CMenu menu; <br />menu.LoadMenu(IDR_MAINFRAME); ////昄菜单 也可改变菜单?br />pWnd->SetMenu(&menu); <br />pWnd->DrawMenuBar(); <br />b_m=true; <br />menu.Detach(); <br />} <br /><br /><strong>十、获取可执行文g的图?/strong> <br />HICON hIcon=::ExtractIcon(AfxGetInstanceHandle(),_T("NotePad.exe"),0); <br />if (hIcon &&hIcon!=(HICON)-1) <br />{ <br />pDC->DrawIcon(10,10,hIcon); <br /><br />} <br />DestroyIcon(hIcon); <br /><br /><strong>十一、窗口自动靠边程序演C?/strong> <br />BOOL AdjustPos(CRect* lpRect) <br />{//自动靠边 <br />int iSX=GetSystemMetrics(SM_CXFULLSCREEN); <br />int iSY=GetSystemMetrics(SM_CYFULLSCREEN); <br />RECT rWorkArea; <br />BOOL bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT), &rWorkAre <br />a, 0); <br />CRect rcWA; <br />if(!bResult) <br />{//如果调用不成功就利用GetSystemMetrics获取屏幕面积 <br />rcWA=CRect(0,0,iSX,iSY); <br />} <br />else <br />rcWA=rWorkArea; <br />int iX=lpRect->left; <br />int iY=lpRect->top; <br /><br />if(iX < rcWA.left + DETASTEP && iX!=rcWA.left) <br />{//调整左?br />//pWnd->SetWindowPos(NULL,rcWA.left,iY,0,0,SWP_NOSIZE); <br />lpRect->OffsetRect(rcWA.left-iX,0); <br />AdjustPos(lpRect); <br />return TRUE; <br />} <br />if(iY < rcWA.top + DETASTEP && iY!=rcWA.top) <br />{//调整上?br />//pWnd->SetWindowPos(NULL ,iX,rcWA.top,0,0,SWP_NOSIZE); <br />lpRect->OffsetRect(0,rcWA.top-iY); <br />AdjustPos(lpRect); <br />return TRUE; <br />} <br />if(iX + lpRect->Width() > rcWA.right - DETASTEP && iX !=rcWA.right-lpRect->W <br /><br />idth()) <br />{//调整?br />//pWnd->SetWindowPos(NULL ,rcWA.right-rcW.Width(),iY,0,0,SWP_NOSIZE); <br />lpRect->OffsetRect(rcWA.right-lpRect->right,0); <br />AdjustPos(lpRect); <br />return TRUE; <br />} <br />if(iY + lpRect->Height() > rcWA.bottom - DETASTEP && iY !=rcWA.bottom-lpRect <br />->Height()) <br />{//调整下?br />//pWnd->SetWindowPos(NULL ,iX,rcWA.bottom-rcW.Height(),0,0,SWP_NOSIZE); <br />lpRect->OffsetRect(0,rcWA.bottom-lpRect->bottom); <br />return TRUE; <br />} <br />return FALSE; <br />} <br />//然后在ONMOVEING事g中用所下过E调用?br /><br />CRect r=*pRect; <br />AdjustPos(&r); <br />*pRect=(RECT)r; <br /><br /><strong>十二、给pȝ菜单d一个菜单项 <br /></strong>l系l菜单添加一个菜单项需要进行下qC个步骤: <br />首先Q用Resource Symbols对话Q在View菜单中选择Resource SymbolsQ.Q可以显 <br />C对话Q定义菜单项IDQ该ID应大?x0F而小?xF000Q?br />其次Q调用CWnd::GetSystemMenu获取pȝ菜单的指针ƈ调用CWnd:: Appendmenu菜单?br />Ҏ加到菜单中。下例给pȝ菜单d两个新的 <br />int CMainFrame:: OnCreate (LPCREATESTRUCT lpCreateStruct) <br />{ <br />…?br />//Make sure system menu item is in the right range. <br /><br />ASSERT(IDM_MYSYSITEM<0xF000); <br />//Get pointer to system menu. <br />CMenu* pSysMenu=GetSystemMenu(FALSE); <br />ASSERT_VALID(pSysMenu); <br />//Add a separator and our menu item to system menu. <br />CString StrMenuItem(_T ("New menu item")); <br />pSysMenu->AppendMenu(MF_SEPARATOR); <br />pSysMenu->AppendMenu(MF_STRING, IDM_MYSYSITEM, StrMenuItem); <br />…?br />} <br /><br /><strong>十三、运行其它程?/strong> <br />//1、运行EMAIL或网址 <br />char szMailAddress[80]; <br />strcpy(szMailAddress,"mailto:netvc@21cn.com"); <br />ShellExecute(NULL, "open", szMailAddress, NULL, NULL, SW_SHOWNORMAL); <br /><br />//2、运行可执行E序 <br />WinExec("notepad.exe",SW_SHOW); //q行计事本?br /><br /><strong>十四、动态增加或删除菜单 <br /></strong>1、 增加菜单?br />//d <br />CMenu *mainmenu; <br />mainmenu=AfxGetMainWnd()->GetMenu(); //得到主菜单?br />(mainmenu->GetSubMenu (0))->AppendMenu (MF_SEPARATOR);//d分隔W?br />(mainmenu->GetSubMenu (0))->AppendMenu(MF_STRING,ID_APP_ABOUT,_T("Always on <br />&Top")); //d新的菜单?br />DrawMenuBar(); //重画菜单 <br />2、 删除菜单?br />//删除 <br />CMenu *mainmenu; <br />mainmenu=AfxGetMainWnd()->GetMenu(); //得到主菜单?br /><br />CString str ; <br />for(int i=(mainmenu->GetSubMenu (0))->GetMenuItemCount()-1;i>=0;i--) //取得菜?br />单的Ҏ。?br />{ <br />(mainmenu->GetSubMenu (0))->GetMenuString(i,str,MF_BYPOSITION); <br />//指定菜单项的标{拷贝到指定的缓冲区。MF_BYPOSITION的解释见上。?br />if(str=="Always on &Top") //如果是刚才我们增加的菜单,则删除。?br />{ <br />(mainmenu->GetSubMenu (0))->DeleteMenu(i,MF_BYPOSITION); <br />break; <br />} <br /><br /><strong>十五、改变应用程序的图标</strong> <br />静态更改: 修改图标资源IDR_MAINFRAME。它有两个图标,一个是16*16的,另一个是3 <br /><br />2*32的,注意要一起修攏V?br />动态更改: 向主H口发送WM_SETICON消息.代码如下Q?br />HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON); <br />ASSERT(hIcon); <br />AfxGetMainWnd()->SendMessage(WM_SETICON,TRUE,(LPARAM)hIcon); <br /><br /><strong>十六、另一U改变窗口标题的Ҏ</strong> <br />使用语句 CWnd* m_pCWnd = AfxGetMainWnd( )Q然后,再以如下形式调用SetWindowTe <br />xt()函数Q?br />SetWindowText( *m_pCWnd,(LPCTSTR)m_WindowText)Q?/ m_WindowText可以是一个CSt <br />ringcȝ变量。?br /><br /><strong>十七、剪切板上通过增强元文件拷贝图像数据?br /></strong>下面代码拯通过元文件拷贝图像数据到M应用E序Q其可以攄在CViewzcȝq?br /><br />C。?br />CMetaFileDC * m_pMetaDC = new CMetaFileDC(); <br />m_pMetaDC->CreateEnhanced(GetDC(),NULL,NULL,"whatever"); <br />//draw meta file <br />//do what ever you want to do: bitmaps, lines, text... <br />//close meta file dc and prepare for clipboard; <br />HENHMETAFILE hMF = m_pMetaDC->CloseEnhanced(); <br />//copy to clipboard <br />OpenClipboard(); <br />EmptyClipboard(); <br />::SetClipboardData(CF_ENHMETAFILE,hMF);                                                                                 <br />CloseClipboard(); <br /><br />//DeleteMetaFile(hMF); <br />delete m_pMetaDC; <br /><br /><strong>十八、剪切板上文本数据的传?/strong> <br />把文本放|到剪接板上Q?br />CString source; <br />//put your text in source <br />if(OpenClipboard()) <br />{ <br />HGLOBAL clipbuffer; <br />char * buffer; <br />EmptyClipboard(); <br />clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1); <br />buffer = (char*)GlobalLock(clipbuffer); <br />strcpy(buffer, LPCSTR(source)); <br />GlobalUnlock(clipbuffer); <br />SetClipboardData(CF_TEXT,clipbuffer); <br />CloseClipboard(); <br />} <br />从剪接板上获取文本: <br /><br />char * buffer; <br />if(OpenClipboard()) <br />{ <br />buffer = (char*)GetClipboardData(CF_TEXT); <br />//do something with buffer here <br />//before it goes out of scope <br />} <br />CloseClipboard(); <br /><br /><strong>十九、将捕捉屏幕囑փ到剪切版中?br /></strong>void CShowBmpInDlgDlg::OnCutScreen() <br />{ <br />ShowWindow(SW_HIDE); <br />RECT r_bmp={0,0,::GetSystemMetrics(SM_CXSCREEN), <br />::GetSystemMetrics(SM_CYSCREEN)};                                                                                       <br />HBITMAP hBitmap; <br />hBitmap=CopyScreenToBitmap(&r_bmp); <br /><br />//hWnd为程序窗口句柄?br />if (OpenClipboard()) <br />{ <br />EmptyClipboard(); <br />SetClipboardData(CF_BITMAP, hBitmap); <br />CloseClipboard(); <br />} <br />ShowWindow(SW_SHOW); <br />} <br />HBITMAP CShowBmpInDlgDlg::CopyScreenToBitmap(LPRECT lpRect) <br />{ <br />//lpRect 代表选定区域 <br />{ <br />HDC hScrDC, hMemDC; <br />// 屏幕和内存设备描q表 <br />HBITMAP hBitmap, hOldBitmap; <br />// 位图句柄 <br />int nX, nY, nX2, nY2; <br />// 选定区域坐标 <br />int nWidth, nHeight; <br />// 位图宽度和高度?br />int xScrn, yScrn; <br />// 屏幕分L率?br /><br />// 保选定区域不ؓI矩形?br />if (IsRectEmpty(lpRect)) <br />return NULL; <br />//为屏q创备描q表 <br />hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); <br />//为屏q设备描q表创徏兼容的内存设备描q表 <br />hMemDC = CreateCompatibleDC(hScrDC); <br />// 获得选定区域坐标 <br />nX = lpRect->left; <br />nY = lpRect->top; <br />nX2 = lpRect->right; <br />nY2 = lpRect->bottom; <br />// 获得屏幕分L率?br />xScrn = GetDeviceCaps(hScrDC, HORZRES); <br />yScrn = GetDeviceCaps(hScrDC, VERTRES); <br />//保选定区域是可见的 <br />if (nX<0) <br /><br />nX = 0; <br />if (nY<0) <br />nY = 0; <br />if (nX2>xScrn) <br />nX2 = xScrn; <br />if (nY2>yScrn) <br />nY2 = yScrn; <br />nWidth = nX2 - nX; <br />nHeight = nY2 - nY; <br />// 创徏一个与屏幕讑֤描述表兼容的位图 <br />hBitmap = CreateCompatibleBitmap <br />(hScrDC, nWidth, nHeight); <br />// 把新位图选到内存讑֤描述表中 <br />hOldBitmap =(HBITMAP)SelectObject(hMemDC, hBitmap); <br />// 把屏q设备描q表拯到内存设备描q表中?br />BitBlt(hMemDC, 0, 0, nWidth, nHeight, <br />hScrDC, nX, nY, SRCCOPY); <br />//得到屏幕位图的句柄?br />hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap); <br /><br />//清除 <br />DeleteDC(hScrDC); <br />DeleteDC(hMemDC); <br />// q回位图句柄 <br />return hBitmap; <br />} <br />} <br /><br /><strong>二十、如何将位图~放昄在Static控g中?br /></strong>//在Staic控g内显CZ图?br />void CShowBmpInDlgDlg::ShowBmpInStaic() <br />{ <br />CBitmap hbmp; <br />HBITMAP hbitmap; <br />//pStatic指向要显C的地方 <br />CStatic *pStaic; <br />pStaic=(CStatic*)GetDlgItem(IDC_IMAGE); <br />//装蝲资源 MM.bmp是我的一个文件名Q用你的替换 <br />hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),"MM.bmp", <br />IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); <br /><br />hbmp.Attach(hbitmap); <br />//获取囄格式 <br />BITMAP bm; <br />hbmp.GetBitmap(&bm); <br />CDC dcMem; <br />dcMem.CreateCompatibleDC(GetDC()); <br />CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp); <br />CRect lRect; <br />pStaic->GetClientRect(&lRect); <br />//昄位图 <br />pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Heigh <br />t(), <br />&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY); <br />dcMem.SelectObject(&poldBitmap); <br />}<br /></font> <img src ="http://www.shnenglu.com/erran/aggbug/34185.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2007-10-14 00:38 <a href="http://www.shnenglu.com/erran/archive/2007/10/14/34185.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转:如何在同一个工E里d多种语言 http://www.shnenglu.com/erran/archive/2007/10/13/34149.htmlerranerranSat, 13 Oct 2007 13:24:00 GMThttp://www.shnenglu.com/erran/archive/2007/10/13/34149.htmlhttp://www.shnenglu.com/erran/comments/34149.htmlhttp://www.shnenglu.com/erran/archive/2007/10/13/34149.html#Feedback1http://www.shnenglu.com/erran/comments/commentRss/34149.htmlhttp://www.shnenglu.com/erran/services/trackbacks/34149.html 原文Qhttp://dev.csdn.net/article/23/23538.shtm
作者:      

q应该是一个?span lang="EN-US">VC的一个小技巧,不过在打做之前Q在|上找了找,没有扑ֈQ可能是我填入的关键字不对,:-)Q,所以在q里l大家提供一个参考,希望对大家能提供方便Q不用象我找的这么辛苦?o:p>

意图Q实现多U语a在同一个工E里Q如果调试成功后Q即可以同时~译E序的多U语a版本?span lang="EN-US">

q_Q?span lang="EN-US">Win2000 Pro SP4Q?VCQ+6.0QSDK

一般情况下Q编写程序都会用工E制作向|生成的工E有两个~译版本Q一个是DebugQ另外一个就是ReleaseQ我的目的就是添加多U语a的编译版本,同时需要多U语a?rc文gQSource文gQ,然后l过一些简单的讄Q就Okay了?o:p>

       我添加很多的囄Q这h较容易理解,也少去读文字的痛苦(用电脑看大篇大篇的文字真的很痛苦Q?o:p>

  下面我们开始:

  1. 首先是以工程文g里的.rc文g为基Q制作多U语a?rc文gQ就是把有关对话框,属性页Q以及一些ID文字替换为其他的语言文字Q这里需要注意的 是,不同语言版本?rc文gQ包含很多相同的图标QIconQ,对话框(DialogQ,String TableQ在VC~译器的SourceView里都要选择相应的语U。比如:如果是EnglishQ以上说的这些都要选择EnglishQU.S.Q?/span>

  2. d多语a~译版本Q选择Build->ConfigurationsQ点击AddQ添加相应的语言~译版本Q我q里d的是English Release。随后添加多U语a版本?/span>

d多种语言的编译版?/span>


  3. ~辑不同语言版本的Project Setting。点击菜单Project->SettingsQ修改相应的讄
Output directoriesQ?包括Intermediate和Output filesQ我q里都设|ؓEnglish Release
Output file nameQ?我这里设|ؓEnglish_Release/ktrexe.exe

LanguageQ?/span>pQ美国)     

 

4. dSource Files

 

d后会弹出一个对话框Q不用理会它

此时你可以在你编译器?/span>ResourceView里看刎ͼ

 

以后如果需要修改不同的语言Q可以修改相应的resources文g?/span>


5. 点击Project->SettingsQ点M所点击?/span>.rc文g

 

选中Exclude file from build

 

选择“是”,每一U?/span>.rc文g分别选取相应的语a~译版本Q比?/span>Win32 English ReleaseQ选择Winapp1_English.rcQ然后在Exclude file from build打勾卛_?/span>

 

6. ~译Q?/span>

选择Build->Batch Build

 

选中您所要编译的语种Q选中Selection onlyQ点?/span>Rebuild All卛_?/span>

 

7. 此时Q您可以看到您的.dsp文g已经被修攏V?o:p>

 

       我曾l在CSDN论坛上问q此问题Q还有不同的解法Q我把他们帖出来Q?/span>

 

    我的操作是在VC++6.0里有一个用Win32E序向导生成的一个工E,此工E代码添加,调试Q运行都已经Okay?/span>

    ׃该工E是体中文的Q我x加其他的语言版本Q我在.rc复本的基上把体中文的目换成了其他的语言Q比如西班牙语)Q然后我?/span>Build->Configurations里添加了Spanish ReleaseQ在Project-?/span>Settings里设|了语言环境Q输入\径等{属性。随后我在Project-?/span>Add Filesd我刚才更换语a?/span>.rc文gdq来?/span>

    目的是用Debug调试Q然后在Build-?/span>Batch Build选项里选择我要~译的语aU类Q一ơ编译多U语a?/span>

    问题?/span>VC6.0提示说?/span>Multiple.rc files exist in this project. Only one can be marked as included in the build. The others will be excluded frome the build.?/span>

    请问Q如何解册个问题,我在|上找了两天了,在其他的Newsgroups上法帖,没有扑ֈ{案Q是不是我哪里设|错了,请高手给个提C。谢谢!

 

把你现在?/span>.rc保存Q然后把所有的中文换成其他语言Q别存ؓ其他other.rc?/span>

GetResourceInstance()得到资源句柄。换成另other.rc,(SetResourceHandle)

可以搞定?/span>

因ؓ所有的id没变Q?/span>所有程序都能正常运行?/span>

最好把资源做成dll,?/span>LoadResource切换

写成INI也是一个好办法Q?/span>

 

其他论坛的回{:

Several solutions:
1. Place all your resources into one big. rc file.
2. Exclude the additional rc files from the build and include them by the
resource includes (right mouse click on the resource file in the resource
editor). In this case you have to take care that bitmaps and others are only
included once!
3. Create seperate DLL's for each language and use the corresponding handle
to this DLL when loading resources. Read the docu to AfxSetResourceHandle
when you are using the MFC.

1)      use the "resource includes" menu item in VC C++ 6.0 and include one
resource in the other (i.e. #include "file.rc")  Make sure that there are no
conflicts and each resource is properly marked with the correct language.
Mark the RC file as excluded from the build.  It will get built anyway since
it was included in the main RC.

2)      have separate DLL (i.e. a separate sub-project) for each RC file (the
satellite DLL approach to localization)

If you are unhappy with having separate builds for each language then
you'll have to combine the .rc files with (or without if they doesn't use
same identifiers) the proper LANGUAGE ID #ifdef's. If you don't know
about these, use the Resource editor built into the Environment to create
a new .rc with element variants in several languages. Then open the file
and analyse it.

In VS.NET 2003 click on Build>Configuration Manager
You will find your project. Now it is possible to select New in the combo
"Active Solution Configuration" you can add new settings to the current ones
Debug/Release.
In VS6 click on Build->Configurations. You will find your project displayed
as a tree. Click on Add to add new configurations.
In both caes you will be asked what base configuratin should be copied.

Now you can create different Release modes like German/English/Bavarian and
so on...
For each configuration you can define diffrent rc files to be excluded from
the build. Also you can define different output directories.

The disadvantage is that you always have a complete binary for a language
and you can not switch the language on user request!

 

 

如果有问题,请和我联p:danielxu22@cellink.com.cn



erran 2007-10-13 21:24 发表评论
]]>
转:改变VC++应用E序H口的标?/title><link>http://www.shnenglu.com/erran/archive/2007/10/13/34140.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 12:02:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2007/10/13/34140.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/34140.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2007/10/13/34140.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/34140.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/34140.html</trackback:ping><description><![CDATA[ <div id="um6gaqu" class="Section1"> <p class="MsoNormal" style="line-height: 13.9pt; text-align: center;" align="center"> <font face="Arial" size="2"> <b> <span style="font-size: 16pt;">改变<span lang="EN">VC++应用E序H口的标?o:p></o:p></span></span> </b> </font> </p> <p class="MsoNormal" style="line-height: 13.9pt; text-align: center;" align="center"> <font face="Arial" size="2">上v卢湾Z余大?span lang="EN"><span style="">      </span>능?/span></font> </p> <p class="MsoNormal" style="margin-top: 15.1pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">?span lang="EN"><span style="">  </span>?讨论ZMFCcd的Windows应用E序设计?应用E序各种标题的改变方法?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">关键?span lang="EN">:MFC Windows~程标题Visual C++<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">0 引言<o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">有一个演C?span lang="EN">VC++中的消息处理的单文档应用E序。该E序开始运行的情况如下:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">H口中的初始文档标题竞显CZؓ<span lang="EN">Untitled,实在不尽人意?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">有些时?span lang="EN">, 实需要改变自~Windows应用E序H口的标题。比?想编一个标题名?Communication soft的Y件。虽然在Windows95或Windows NT?Visual C++(以下UVC)可以生成?Communication soft为名的工E?但该工程下的C++cȝ名称也要带上q么多的字符,l编E带来不ѝ可以采用的Ҏ是生成以"CS为名的工E?再把E序的标题改? "Communication Soft。再比如,在多文档应用E序?希望每个子窗口的标题q不?ȝ口标题t?ȝ口标?</span></span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;">……这U类?span lang="EN">,而是?COM1速率"?LPTq行?…?卛_H口标题与主H口标题无关。这旉需要改变各U窗口标题。下面介l一下改变窗口标题所用的Ҏ,所用的开发^台是usual C++5.0?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">1 单又挡接?SDI)典型H口标题的改?o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">首先<span lang="EN">,来看看Windows SD!cdH口标题栏的l构形式。用VC的AppWizard创徏一个名?Exam9的单文档cd的工E。开始运行时,E序ȝ口标题Ş式如?<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.9pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">Untitled-Exam9<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">其中<span lang="EN">"Untitied"为文档标?"Exam9"ZH口标题。当?File-Open</span></span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;">打开<span lang="EN">"wd1.exm"文裆以后,文档标题变ؓ"wd1.exm"?/span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span lang="EN">所以程序主H口标题栏的一般Ş式ؓ:<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">文裆标题<span lang="EN">----ȝ口标?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">1.1 又档标题的改?o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">既然文档标题是由工程中相应的文档cL控制?span lang="EN">,了解q一?可在相应的文档cM,利用SetTitle()函数来改变文档标题?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">例:改变<span lang="EN">CExam9Doc::onNewDocument()函数?<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">BOOL CExam9Doc::OnNewDocument()<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">{<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">if(!CDocument::OnNewDocument())<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 42pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return FALSE-<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">SetTitle("文档标题");<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return TRUE;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">}<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">q行E序<span lang="EN">,则每ơ选择选单中的"文g"?新徏"选项?标题变?文档标题-Exam9</span></span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;" lang="EN"> <o:p> </o:p> </span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt;"> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">1.2 ȝ口标题的改变<o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">ȝ口的标题默认是工E的文g?span lang="EN">,正如前面Appvvazied生成的Exam9工程执行?标题栏的形式Mؓ"文档标题-Exam9?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">改变ȝ口的标题Ҏ有两U?span lang="EN">:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">W一U方?span lang="EN">:利用ResourceView打开工程的资?修改String Table中的<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">IDR_MAINFRAME的倹{将原来?Exam9\n\nExam9\nEXMFile(*.exm)\n.exm\nExam9.Document\nExam9 Document"改ؓ"标题改变CZ<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">\n\nExam9\nEXM File(*.exm)\n.exm\nExam9.Document\nExam9 Document"。这h变后,ȝ口标题就变ؓ"-标题改变CZ"。第二种Ҏ:具体改变Ҏ如下:<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">改变<span lang="EN"> CMainFrame的成员函数PreCreateWindowO?<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">BOOL CMainFrame::PreCreateWindow(CREATESTRUCT&cs)<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">{<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">m_strTitle="上v市卢湑֌业余大学</span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;" lang="EN">;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return CFrameWnd::PreCreateWindow(cs);<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">}<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">q样改变?span lang="EN">,ȝ口标题的形式׃ؓ"-上v市卢湑֌业余大学"?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 0.7pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">M_strTile是CFrameWnd的保护成?要得到m_strTile更详l的信息,h开\msdev\mfc\include\afxwin.h文g)。CMainFrame则是CFrameWndcȝzcR?o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">在这两种改变Ҏ?span lang="EN">,W二U方法优先高。也是?改变了m_strTitle的值后,IDR_MAlNFRAME的值就不v作用?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 3.35pt;"> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">2 对多文挡接口(MDI)cdH口标题的改?o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">?span lang="EN">MDIcdH口?ȝ口标题和文档标题的次?和SDlcdH口中次序是不同的。结合具体例子说?用VC的AppWizard创徏一个名?MDITitle"的多文挡cd的工E。创建完工程?~译q行该工E?ȝ口标题Ş式如?"ȝ口标?文档标题"?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">2.l 文挡标题的改?o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">MDIcdH口的文档标题也是由相应的文档类控制的。改变方法同SDIcdH口cM,要改变标?只要在相应的文档cM利用SetTitle()函数来改变文档标题?o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">2.2 ȝ口标题的改变<o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">MDIcdȝ口标题的改变Ҏ同SDIcdH口cM。改变主H口标题也有两种Ҏ,通过改变IDR_MAINFRAME或m_strTitle的值就可实现改变主H口标题的目的。同?改变了m_strTitle值后,IDR_MAINFRAME的值就不v作用?o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <b> <span style="font-size: 10.5pt;" lang="EN">2.3 子窗口标题的改变<o:p></o:p></span> </b> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">在默认情况下<span lang="EN">,MFC自动子H口标题设ؓ该子H口所打开的文档标题。但实际?子窗口标题与该子H口标题所打开的文档标题可以不一栗可做如下改?<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">利用<span lang="EN">ResourceView打开资源,修改String Table中的IDR_MAINFRAME的gؓ"上v市卢湑֌业余大学",使得ȝ口标题变?上v市卢湑֌业余大学"?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">q将<span lang="EN">BOOL CMDlTitleDoc::OnNewDocument()函数改ؓ:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">BOOL CMDlTitleDoc::OnNewDocument()<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">{<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">if(!CDocument::OnNewDocument())<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 42pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return FALSE;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">static int count=0;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.9pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">char message[10];<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.2pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">wsprintf(message,"%s%d","文档",count);<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.2pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">SetTitle(message);<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 1.2pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">count++;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return TRUE;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">}<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">通过以上修改<span lang="EN">,ȝ口标题栏被设|ؓ:文档标题?上v市卢湑֌业余大学-文挡0"?上v市卢湑֌业余大学-文档1</span></span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;">…?b><span lang="EN"><o:p></o:p></span></b></span> </font> </p> <p class="MsoNormal" style="margin-top: 4.55pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">一下针对子H口标题的修改作如下改动<span lang="EN">:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">?span lang="EN">CChildFrame::PrecreateWindow()函数改ؓ:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">BOOL CChiidFrame::PrecreateWindow(CREATESTRUCT&cs)<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">cs.style &=~(LONG)FWS_ADDTOTlTLE;<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">return CMDIChildWnd::PrecreateWindow(cs);<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">}<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.15pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">要改变窗口类?span lang="EN">, q步工作必须做。常量问FWS_ADDTOTITLE是在文g\msdev\mfc\include\afxwin.h中定义?o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.6pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">?span lang="EN"> CMDlTitleViewcM增加OnlnitialUpdate()函数:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.6pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">void CMDlTitleView::OnlnitiaiUpdate()<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.6pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">{<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.6pt; text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">CView::OninitialUpdate();<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">Getparent()-〉SetWindowText(GetDocument()-)GetTitle()+</span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;" lang="EN">-上v卢湾Z余大?/span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">?/span> <span style="font-size: 10.5pt;" lang="EN">);<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">}<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">q样<span lang="EN">,子窗口的标题栏的形式׃ؓ"文档?上v卢湾Z余大??o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 14.6pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;">参考资?span lang="EN">:<o:p></o:p></span></span> </font> </p> <p class="MsoNormal" style="margin-top: 2.4pt;"> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">[1]Michaei Morrison:Sams Tech Yourself MFC in 24Hours<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">[2]David krugiinski:Programming Microsoft Visual C++,FiHh Edition<o:p></o:p></span> </font> </p> <p class="MsoNormal" style=""> <font face="Arial" size="2"> <span style="font-size: 10.5pt;" lang="EN">[3]Kate Gregory:Special Edition Using Visual C++5<o:p></o:p></span> </font> </p> </div> <img src ="http://www.shnenglu.com/erran/aggbug/34140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2007-10-13 20:02 <a href="http://www.shnenglu.com/erran/archive/2007/10/13/34140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CToolTipCtrl使用http://www.shnenglu.com/erran/archive/2007/10/13/34139.htmlerranerranSat, 13 Oct 2007 11:59:00 GMThttp://www.shnenglu.com/erran/archive/2007/10/13/34139.htmlhttp://www.shnenglu.com/erran/comments/34139.htmlhttp://www.shnenglu.com/erran/archive/2007/10/13/34139.html#Feedback0http://www.shnenglu.com/erran/comments/commentRss/34139.htmlhttp://www.shnenglu.com/erran/services/trackbacks/34139.html ToolTip是Win32中一个通用控gQMFC中ؓ其生成了一个类CToolTipCtrlQȝ说来其用方法是较简单的Q下面讲一下它的一般用法和高用法?/font>

一般用法步骤:
  1. dCToolTipCtrl成员变量 m_tt?/font>

  2. 在父H口中调用EnableToolTips(TRUE);

  3. 在窗口的OnCreateQ或者其他适当的位|)中向ToolTip中添加需要显CTip的子H口Qƈ同时指定相应的显C字串CToolTipCtrl::AddTool(pWnd,"string to display")?/font>
  4. 重蝲父窗口的 BOOL PreTranslateMessage(MSG* pMsg) Q在函数中调?m_tt.RelayEvent(pMsg)?/font>

下面假设在窗口CWndYour中用CToolTipCtrl
				在类定义中添加变量说明:

class CWndYour:xxx
{
CToolTipCtrl m_tt;
}

在OnCreate中添加需要显CTip的子H口
CWndYour::OnCreate(....)
{
EnableToolTips(TRUE);
m_tt.Create(this);
m_tt.Activate(TRUE);
CWnd* pW=GetDlgItem(IDC_CHECK1);//得到H口指针
m_tooltip.AddTool(pW,"Check1");//d
........

}

在BOOL PreTranslateMessage(MSG* pMsg)中添加代?br />BOOL CWndYour::PreTranslateMessage(MSG* pMsg)
{
{
m_tt.RelayEvent(pMsg);
}
return CParentClass::PreTranslateMessage(pMsg);
}

q样当鼠标移动到相应的子H口上时会显C出相应的ToolTip?/font>

动态改变ToolTip的显C内容的Ҏ及步骤:

  1. 上面所讲的1??步骤?/font>
  2. 在增加ToolTip时不指定昄的字Ԍ而是使用LPSTR_TEXTCALLBACK?/font>
  3. 在窗口中增加消息映射 ON_NOTIFY_EX( TTN_NEEDTEXT, 0, SetTipText )?/font>
  4. 在窗口中增加一个函数用于动态提供显C内容,其原型ؓ BOOL SetTipText( UINT id, NMHDR * pTTTStruct, LRESULT * pResult )Q下面的代码可以Ҏ传入的参数判定应该显C的内容?/font>

				BOOL CWndYour::SetTipText( UINT id, NMHDR * pTTTStruct, LRESULT * pResult )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pTTTStruct;
UINT nID =pTTTStruct->idFrom; //得到相应H口IDQ有可能是HWND
if (pTTT->uFlags & TTF_IDISHWND) //表明nID是否为HWND
{
nID = ::GetDlgCtrlID((HWND)nID);//从HWND得到ID|当然你也可以通过HWND值来判断
switch(nID)
case(IDC_YOUR_CONTROL1)
strcpy(pTTT->lpszText,your_string1);//讄
return TRUE;
break;
case(IDC_YOUR_CONTROL2)
//讄相应的显C字?br /> return TRUE;
break;
}
return(FALSE);
}


erran 2007-10-13 19:59 发表评论
]]>
VC中取代状态栏默认“就l”提C?/title><link>http://www.shnenglu.com/erran/archive/2007/10/13/34138.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 11:55:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2007/10/13/34138.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/34138.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2007/10/13/34138.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/34138.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/34138.html</trackback:ping><description><![CDATA[ <div id="kqay8is" class="cnt"> <p> <font face="Arial" size="2">在MFCE序中如果用默认的状态栏的话Q其W一栏在I闲时显C的是“就l”,如果用户点击菜单Q还会用于显C单栏的提C文本,如“徏立新文档”等。有时候我们不希望E序在状态栏中显C些东西,那该怎么办呢Q?/font> </p> <p> <font face="Arial" size="2">在MFC中,是用L架类中的CStatusBar对象m_wndStatusBar来管理状态栏的。CStatusBar中有一个SetPaneText的函数可用于讄状态栏中的文字。我们在CMainFramecM的OnCreate函数中添?/font> </p> <p> <font face="Arial" size="2">m_wndStatusBar.SetPaneText(0, "Hello");</font> </p> <p> <font face="Arial" size="2">则程序启动后Q状态栏上显C的文字为“Hello”。但是当我们点击菜单后,会发现这D|字会消失Q被替换成菜单的提示文本Q若菜单操作l束Q则又显C成“就l”了。那该如何禁止MFC自动修改状态栏文本呢?</font> </p> <p> <font face="Arial" size="2">我们再看看主框架cȝ源程序。当中有q么一D?/font> </p> <p> <font face="Arial" size="2">static UINT indicators[] =<br /> {<br /> ID_SEPARATOR,<br /> ID_INDICATOR_CAPS,<br /> ID_INDICATOR_NUM,<br /> ID_INDICATOR_SCRL,<br /> };</font> </p> <p> <font face="Arial" size="2">而在OnCreate中有q么一D?/font> </p> <p> <font face="Arial" size="2">m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))</font> </p> <p> <font face="Arial" size="2">q一句的作用是设|状态栏各部分的IDQ默认的ID由indicators数组指定。由于MFC中把状态栏的第一栏设|ؓID_SEPARATOR 了,q是一个MFC默认的IDQ所以它有一pd默认的操作,如显C“就l”二字。我们想止MFC自动操作状态栏必M改indicators数组?/font> </p> <p> <font face="Arial" size="2">我们打开Resource ViewQ修改String TableQ找到那堆ID_INDICATOR开头的Q在后面新加一个ID_INDICATOR_1。然后修改CMainFrame中indicators的声?/font> </p> <p> <font face="Arial" size="2">static UINT indicators[] =<br /> {<br /> ID_INDICATOR_1,<br /> ID_INDICATOR_CAPS,<br /> ID_INDICATOR_NUM,<br /> ID_INDICATOR_SCRL,<br /> };</font> </p> <p> <font face="Arial" size="2">然后~译q行E序。我们会发现QMFC不会再自动修改状态栏的文本了Q可是前面添加的一?br /> m_wndStatusBar.SetPaneText(0, "Hello");<br /> 也不起作用了。这是ؓ什么呢Q?/font> </p> <p> <font face="Arial" size="2"> <a >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_status_bars.3a_.updating_the_text_of_a_status.2d.bar_pane.asp</a> <br /> MSDN上有一介l如果修改状态栏文本的文章。当中有一?/font> </p> <p> <font face="Arial" size="2">Note   The SetText approach is recommended. It is possible to perform this task at a slightly lower level by calling the CStatusBar member function SetPaneText. Even so, you still need an update handler. Without such a handler for the pane, MFC automatically disables the pane, erasing its content.</font> </p> <p> <font face="Arial" size="2">意思大概是如果我们不ؓ状态栏dUPDATE的处理函敎ͼMFC会自动禁止状态栏的该?pane)。按照MSDN的说法,我们需要增加UPDATE的处理函数。在MainFrm.h中添?/font> </p> <p> <font face="Arial" size="2">afx_msg void OnUpdate1(CCmdUI *pCmdUI);</font> </p> <p> <font face="Arial" size="2">在MainFrm.cpp中添?/font> </p> <p> <font face="Arial" size="2">ON_UPDATE_COMMAND_UI(ID_INDICATOR_1, OnUpdate1)</font> </p> <p> <font face="Arial" size="2">void CMainFrame::OnUpdate1(CCmdUI *pCmdUI)<br /> {<br />  pCmdUI->Enable();<br /> }</font> </p> <p> <font face="Arial" size="2">q样我们可以往状态栏的第一栏写文字Q而避开MFC对其的自动修改了?/font> </p> </div> <img src ="http://www.shnenglu.com/erran/aggbug/34138.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2007-10-13 19:55 <a href="http://www.shnenglu.com/erran/archive/2007/10/13/34138.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>定制WndQ对话框Q窗口类?/title><link>http://www.shnenglu.com/erran/archive/2007/10/13/34126.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 09:43:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2007/10/13/34126.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/34126.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2007/10/13/34126.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/34126.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/34126.html</trackback:ping><description><![CDATA[<p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">定制WndQ对话框Q窗口类?br>               <br>一 ȝ口ؓCWnd的派生类</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">       BOOL CMainWnd::PreCreateWindow(CREATESTRUCT& cs) <br>      {<br>             WNDCLASS wndcls;<br> <br>             ZeroMemory( &wndcls, sizeof(WNDCLASS) );<br>             wndcls.style   = CS_DBLCLKS;<br>             wndcls.lpfnWndProc  = AfxWndProc;<br>             wndcls.hInstance  = AfxGetInstanceHandle();<br>             wndcls.hIcon   = theApp.LoadIcon( IDR_MAINFRAME );<br>             wndcls.hCursor   = theApp.LoadStandardCursor( IDC_ARROW );<br>             wndcls.hbrBackground = NULL;<br>             wndcls.lpszMenuName  = NULL;<br>             wndcls.lpszClassName = _T("MyMainWnd");<br> <br>             AfxRegisterClass( &wndcls );<br> <br>             cs.lpszClass = wndcls.lpszClassName;<br> <br>             return CMDIFrameWnd::PreCreateWindow( cs );<br>      }</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">?ȝ口ؓCDialog的派生类</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">       W一?在BOOL CMyApp::InitInstance()?声明Dialog对象之前d</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">                  WNDCLASS wndcls;<br>                  ::GetClassInfo( AfxGetInstanceHandle(), "#32770", &wndcls );<br>                  wndcls.lpszClassName = _T("MyDialog");<br>                  AfxRegisterClass( &wndcls );</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">      W二?nbsp; 有两U方?/p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">             a  直接修改××.rc文g</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">                  IDD_MY_DIALOG DIALOGEX 0, 0, 319, 152<br>                  STYLE DS_SETFONT | DS_MODALFRAME |  ……<br>                  EXSTYLE WS_EX_APPWINDOW<br>                  CAPTION "Lottery2"<br>                  CLASS "MyDialog"http://d此行卛_<br>                  FONT 9, "MS Shell Dlg", 0, 0, 0x1</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">             b  修改属?br>                 在IDE中修?#215;×.rc属?vc6 取消Enable MFC features</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">                                                    .net  Mfc mode = FALSE</p> <p style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">                 在Dialog属性中的class name 中 输入 MyDialog卛_<br><br><br>参考:<u><font color=#800080>VC++中定制个性化的对话框H口c?/font></u> <a >http://blog.csdn.net/chinawash/archive/2006/06/25/832338.aspx</a><br></p> <img src ="http://www.shnenglu.com/erran/aggbug/34126.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2007-10-13 17:43 <a href="http://www.shnenglu.com/erran/archive/2007/10/13/34126.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>__declspec(dllexport)?def文ghttp://www.shnenglu.com/erran/archive/2007/10/13/34120.htmlerranerranSat, 13 Oct 2007 09:01:00 GMThttp://www.shnenglu.com/erran/archive/2007/10/13/34120.htmlhttp://www.shnenglu.com/erran/comments/34120.htmlhttp://www.shnenglu.com/erran/archive/2007/10/13/34120.html#Feedback0http://www.shnenglu.com/erran/comments/commentRss/34120.htmlhttp://www.shnenglu.com/erran/services/trackbacks/34120.html


__declspec(dllexport)?def文g


在VC++中,如果生成DLL可以不?def文g。只需要在VC++的函数定义前要加__declspec(dllexport)修饰可以了。但是用__declspec(dllexport)和?def文g是有区别的。如果DLL是提供给VC++用户使用的,只需要把~译DLL时生的.lib提供l用P它可以很L地调用你的DLL。但是如果DLL是供VB、PB、Delphi用户使用的,那么会生一个小ȝ。因为VC++对于__declspec(dllexport)声明的函Cq行名称转换Q如下面的函敎ͼ
    __declspec(dllexport) int __stdcall IsWinNT()
    会{换ؓIsWinNT@0Q这样你在VB中必这样声明:
    Declare Function IsWinNT Lib "my.dll" Alias "IsWinNT@0" () As Long
    @的后面的数由于参数类型不同而可能不同。这昄不太方便。所以如果要想避免这U{换,p使用.def文g方式?
    EXPORTS后面的数可以不给Q系l会自动分配一个数。对于VB、PB、Delphi用户Q通常使用按名U进行调用的方式Q这个数关系不大Q但是对于?lib链接的VCE序来说Q不是按名称q行调用Q而是按照q个数进行调用的Q所以最好给出。如Q?br>EXPORTS 
test @1 

  vc的dllQdelphi调用的方法:

////K9RtExpr.h
extern "C" __DECDLL
unsigned int _stdcall K9RtSysInterrupt(int nInterruptTag);

extern "C" __DECDLL
unsigned int _stdcall K9RtSysExprm(unsigned int nModuleTag,
           float fTimeout,  
           void * pTestPar, 
           void * pResultPar 
           );

// K9RtExpr.cpp
#include "K9RtExpr.h"
#include "RtCtrl.h"
extern "C" __DECDLL
unsigned int _stdcall K9RtSysInterrupt(int nInterruptTag)
{
 return CRelayTestControl::Instance()->InterruptTest(nInterruptTag);
}
extern "C" __DECDLL
unsigned int _stdcall K9RtSysExprm(unsigned int nModuleTag,
           float fTimeout,   
           void * pTestPar, 
           void * pResultPar 
           )
{
 return CRelayTestControl::Instance()->RelayTest(
      nModuleTag, fTimeout, pTestPar, pResultPar);
}

///K9RtExpr.def
LIBRARY      "K9RtExpr"
DESCRIPTION  K9RtExpr Windows Dynamic Link Library'

EXPORTS
K9RtSysInterrupt
K9RtSysExprm
    ; Explicit exports can go here


//delphi   调用文g
unit InterfaceFunc;

interface

uses
   UnitData,Types;
  
function K9RtSysExprm(nModuleTag:integer  ;
                        uTimeout:integer;
                        pTestPar:Pointer;
                        pResultPar:Pointer) : Integer; stdcall;

function K9RtSysInterrupt(nInterruptType:Integer) : Integer; stdcall;

implementation
const DLLPATH  = 'RtBsExpr.dll';
function K9RtSysExprm; external DLLPATH  name  'ExperimentRelayTest';
function K9RtSysInterrupt; external DLLPATH  name 'InterruptRelayTest';

end.



erran 2007-10-13 17:01 发表评论
]]>
MFC HANDLE集合http://www.shnenglu.com/erran/archive/2006/12/26/16879.htmlerranerranTue, 26 Dec 2006 11:12:00 GMThttp://www.shnenglu.com/erran/archive/2006/12/26/16879.htmlhttp://www.shnenglu.com/erran/comments/16879.htmlhttp://www.shnenglu.com/erran/archive/2006/12/26/16879.html#Feedback0http://www.shnenglu.com/erran/comments/commentRss/16879.htmlhttp://www.shnenglu.com/erran/services/trackbacks/16879.htmlHACCEL       Handle to an accelerator table.
HANDLE       Handle to an object.
HBITMAP      Handle to a bitmap. 
HBRUSH       Handle to a brush.
HCONV        Handle to a dynamic data exchange (DDE) conversation.
HCONVLIST    Handle to a DDE conversation list.
HCURSOR      Handle to a cursor.
HDC          Handle to a device context (DC).
HDDEDATA     Handle to DDE data.
HDESK        Handle to a desktop.
HDROP        Handle to an internal drop structure.
HDWP         Handle to a deferred window position structure.
HENHMETAFILE Handle to an enhanced metafile.
HFILE        Handle to a file opened by OpenFile, not CreateFile.
HFONT        Handle to a font.
HGDIOBJ      Handle to a GDI object.
HGLOBAL      Handle to a global memory block.
HHOOK        Handle to a hook.
HICON        Handle to an icon.
HIMAGELIST   Handle to an image list.
HIMC         Handle to input context.
HINSTANCE    Handle to an instance.
HKEY         Handle to a registry key.
HKL          Input locale identifier.
HLOCAL       Handle to a local memory block.
HMENU        Handle to a menu.
HMETAFILE    Handle to a metafile.
HMODULE      Handle to a module. The value is the base address of the module.
HMONITOR     Handle to a display monitor.
HPALETTE     Handle to a palette.
HPEN         Handle to a pen. 
HRGN         Handle to a region.
HRSRC        Handle to a resource.
HSZ          Handle to a DDE string.
HWINSTA      Handle to a window station.
HWND         Handle to a window.


erran 2006-12-26 19:12 发表评论
]]>双缓冲绘?/title><link>http://www.shnenglu.com/erran/archive/2006/11/25/15650.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 25 Nov 2006 01:23:00 GMT</pubDate><guid>http://www.shnenglu.com/erran/archive/2006/11/25/15650.html</guid><wfw:comment>http://www.shnenglu.com/erran/comments/15650.html</wfw:comment><comments>http://www.shnenglu.com/erran/archive/2006/11/25/15650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/erran/comments/commentRss/15650.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/erran/services/trackbacks/15650.html</trackback:ping><description><![CDATA[<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>VC</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">双缓冲绘?/span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>BOOL CGraphDlg::OnDraw(CDC* pDC)</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>{</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>CRect rc;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>GetClientRect(&rc);<span style="mso-tab-count: 1">  </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>CDC<span style="mso-spacerun: yes">  </span>MemDC; </span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>CBitmap<span style="mso-spacerun: yes">  </span>MemBitmap;<span style="mso-tab-count: 1">   </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemDC.CreateCompatibleDC(NULL);<span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemBitmap.CreateCompatibleBitmap(pDC, rc.Size().cx,rc.Size().cy);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);<span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemDC.BitBlt(0,0,rc.width, rc.height, pDC,0,0,SRCCOPY);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>m_pGraph->SetGraphDC(&MemDC);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>m_pGraph->DoGraphShowEvent();<span style="mso-tab-count: 1">   </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 2">              </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>pDC->BitBlt(0,0, rc.Size().cx,rc.Size().cy,&MemDC,0,0,SRCCOPY);<span style="mso-tab-count: 1">   </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemDC.SelectObject(pOldBit);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemBitmap.DeleteObject();</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">       </span>MemDC.DeleteDC();</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>}</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>Delphi </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">双缓冲绘图:</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>procedure TBkCoordi.Draw(Canvas : TCanvas);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>var</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp : TBitmap;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_width, _height : integer;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_top, _left : integer;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>begin</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_width := Round(m_width);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_height := Round(m_height);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_left := Round(m_topleft.x);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_top := Round(m_topleft.y);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp := Tbitmap.Create;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp.Handle := CreateCompatibleDC(Canvas.Handle);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp.Width :=<span style="mso-spacerun: yes">  </span>_width;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp.Height :=<span style="mso-spacerun: yes">  </span>_height;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>BitBlt(_bmp.Canvas.Handle,0,0,_width,_height, Canvas.Handle,_left,_top,SRCCOPY);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">                  </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">  </span><span style="mso-spacerun: yes">  </span>if m_showcross then m_cross.Draw(_bmp.Canvas);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>if @OnDrawing <> nil then OnDrawing(_bmp.Canvas);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>BitBlt(Canvas.Handle,_left,_top,_width,_height, _bmp.Canvas.Handle,0,0,SRCCOPY);</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US> <o:p></o:p></span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes">    </span>_bmp.Free;</span> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>end;</span> </p> <img src ="http://www.shnenglu.com/erran/aggbug/15650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/erran/" target="_blank">erran</a> 2006-11-25 09:23 <a href="http://www.shnenglu.com/erran/archive/2006/11/25/15650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>郁闷的error link 2019http://www.shnenglu.com/erran/archive/2006/06/02/8063.htmlerranerranThu, 01 Jun 2006 17:24:00 GMThttp://www.shnenglu.com/erran/archive/2006/06/02/8063.htmlhttp://www.shnenglu.com/erran/comments/8063.htmlhttp://www.shnenglu.com/erran/archive/2006/06/02/8063.html#Feedback1http://www.shnenglu.com/erran/comments/commentRss/8063.htmlhttp://www.shnenglu.com/erran/services/trackbacks/8063.html2006-06-01:  郁闷的error link 2019

          找了一两个时?019, 是不知道是什么原因error? 我都快要疯了, 所有的lib都没问题, 是link error, 想不到是什么原? 烦的我差Ҏ着睡着? ^_^,  最后我注释掉了lib中所有的链接p|的函?  没问题了,  鼠标在那些函C点着点着? H然发现, q些函数都是inline? ? 原来, 我可q同事忘了 #include "*.inl" ?  晕死, q样的错误叫我怎么扑֕,  我简?....... q好用了q么长时间找C. l于万事大吉?         

         晚上l个朋友演示了一下重载赋值操作符和拷贝构造函数的区别,  CBase base = 2; (=)执行的是拯构造函数CBase(const int& n ) ; ?CBase base; base = 2; (=)执行的是operator =(const int& n ).

         看到一个刚毕业的大本来我们公司面试,  是让他用C/C++随便写个排序法, 他居然华了一个多时q没写出? 才写了几行代? ?...不知道怎么说好..... 几乎所有的大学都有计算机系, 而且都还不小, 可是哪教? 哪老师, ?... 惛_了我毕业的时? 会了delphi, q培训过dotnet,   也学qVC, (惛_初自学VC, 哪滋味真? 最后毕业了也只会在界面上拖来拖ȝ, 哈哈).工作了才明白了当时的? 其实那些都是工具工具而已, 而关键的应该学好的反而没花多时间去? 反而没学好, 所以还在工作的时候回头来补C++一些基本的东西, 感觉真丢? 没想到最后会做C++开? 不过q是瞒好?  很喜ƢC++. 



erran 2006-06-02 01:24 发表评论
]]>
þ99Ʒ鶹| ŷ޾ƷþþavӰ| һaƬþëƬ16| þ㽶߿ۿ99| 99þѹƷ| ޹˾þۺ| ޺ݺۺϾþþþ | þþƷ91þۺ鶹| 97þù޾Ʒ| ľƷþþþùַ| þˬһ| Ʒþþþþþ | þþþþþ97| þҹӰ| þˬˬAV | þþƷһ| ƷþþĻ| ƷþþþþþĻ | ŷþþþþҹƷ| ޾Ʒtvþþþþþþ| þþĻձ| ƷþùƷ99| Ʒþþ21p| ޹˾þۺ| Ʒþþþù| ޹˾þþƷ| ɫAVԾþþþþ| Ʒþþþþ³| þûɫƵ| þùһ| Ʒþ޲| þþƷƷëƬ | þݺҹҹavapp| ɫۺϾþ88ɫۺ | 91þþƷӰ| þþƷ99Ӱ| ھƷþþþþþ97ţţ| պĻþ| 99ξþþŷƷվ| Ұ¾þһ| Ⱦþԭɫwww|