我就是弄不清先后用什么函数
解决方案 »
- 对话库 和 窗口,是什么关系呀?基于“对话框”的工程,能称作基于‘窗口’的工程吗?
- Microsoft Visual Studio.Net(VS2005/2008)中如何使用 custom control
- 本人用VC整了一个数据库(管理)应用软件,免费提供注册码给大家使用,需要的吱一声
- 请教: virtual BOOL CADoc::OnNewDocument()和afx_msg void CWinApp::OnFileNew()两者的调用的关系.谢谢
- 有没有白天上msn的而又不能上QQ的
- 有关try,catch的问题,有100分相送
- 不知道各位高手遇到过这个问题马?(在线)
- 小问题,关于 EDIT 和 SPIN 组合控件。。。。
- 用installshield打包开发软件,为什么在另外的主机上不能卸载安装包
- 这种情况下如何画圆
- 在GetDlgItem(IDC_TISHI_STATIC)->SetWindowText("文字");之后用Sleep(4000);就有可能不及时显示上述文字??
- 在DataGrid控件中的设计过程中,能否增加列?
2.直接可以在hdc上作图了:例如:
case WM_PAINT:
hdc = ::BeginPaint( hWnd, & ps );
assert( hdc );
hdcMem = ::CreateCompatibleDC( hdc );
assert( hdcMem ); ::SelectObject( hdcMem, hbmpBkground );
::BitBlt(
hdc,
0, 0,
cxClient, cyClient,
hdcMem,
0, 0,
SRCCOPY );
::DeleteDC( hdcMem );
::EndPaint( hWnd, & ps );
return 0;
1,获取设备环境类,建立内存环境类:
CClientDC dc(p_myWnd);
CDC memDc;
memDc.CreateCompatibleDC(p_myWnd);
2, 装载位图:CBitmap myMap;
myMap.LoadBitmap(IDC_BITMAP1);
3, 将位图选入memDc中:CBitmap *pold = memDc.SelectObject(&myMap);
4, 将内存DC中位图画到控健DC中:
dc.BitBlt(0, 0, 100, 100, &memDc, 0, 0, SRCCOPY);
5, memDc.SelectObject(pold);//释放资源。
错了,是:
memDc.CreateCompatibleDC(dc);
BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop );Return ValueNonzero if the function is successful; otherwise 0.函数成功,返回非零值,否则为0。 ParametersxSpecifies the logical x-coordinate of the upper-left corner of the destination rectangle.指定目标矩形左上角的逻辑X坐标。 ySpecifies the logical y-coordinate of the upper-left corner of the destination rectangle.指定目标矩形左上角的逻辑Y坐标。 nWidthSpecifies the width (in logical units) of the destination rectangle and source bitmap.指定目标矩形和源位图的宽度(逻辑单位)。 nHeightSpecifies the height (in logical units) of the destination rectangle and source bitmap.指定目标矩形和源位图的高度(逻辑单位)。 pSrcDCPointer to a CDC object that identifies the device context from which the bitmap will be copied. It must be NULL if dwRop specifies a raster operation that does not include a source.指向CDC对象的指针,标识待拷贝位图的设备上下文。如果dwRop指定不包括源的光栅操作,则它必须为NULL。 xSrcSpecifies the logical x-coordinate of the upper-left corner of the source bitmap.指定源位图左上角的逻辑X坐标。 ySrcSpecifies the logical y-coordinate of the upper-left corner of the source bitmap.指定源位图左上角的逻辑Y坐标。 dwRopSpecifies the raster operation to be performed. Raster-operation codes define how the GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. The following lists raster-operation codes for dwRop and their descriptions: 指定要执行的光栅操作。光栅操作代码定义GDC如何合并输出操作中的颜色,包括当前画刷、可能的源位图和目标位图。下面对dwRop列出光栅操作代码及其描述: BLACKNESS Turns all output black.所有输出变黑。
DSTINVERT Inverts the destination bitmap.反转目标位图。
MERGECOPY Combines the pattern and the source bitmap using the Boolean AND operator.使用布尔AND操作符合并特征与源位图
MERGEPAINT Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator.使用布尔OR操作符合并特征与源位图。
NOTSRCCOPY Copies the inverted source bitmap to the destination.拷贝反转源位图到目标。
NOTSRCERASE Inverts the result of combining the destination and source bitmaps using the Boolean OR operator.反转使用布尔OR操作符合并源和目标位图的结果。
PATCOPY Copies the pattern to the destination bitmap.拷贝特征到目标位图。
PATINVERT Combines the destination bitmap with the pattern using the Boolean XOR operator.使用布尔XOR操作符合并目标位图和特征
PATPAINT Combines the inverted source bitmap with the pattern using the Boolean OR operator. Combines the result of this operation with the destination bitmap using the Boolean OR operator.使用布尔OR操作符合并反转源位图和特征。用布尔OR操作符合并这项操作结果与目标位图。
SRCAND Combines pixels of the destination and source bitmaps using the Boolean AND operator.使用布尔AND操作符合并目标像素和源位图。
SRCCOPY Copies the source bitmap to the destination bitmap.拷贝源位图到目标位图。
SRCERASE Inverts the desination bitmap and combines the result with the source bitmap using the Boolean AND operator.反转目标位图并用布尔AND操作符合并这个结果和源位图。
SRCINVERT Combines pixels of the destination and source bitmaps using the Boolean XOR operator.使用布尔XOR操作符合并目标像素和源位图
SRCPAINT Combines pixels of the destination and source bitmaps using the Boolean OR operator.SRCPAINT 使用布尔OR操作符合并目标像素和源位图
WHITENESS Turns all output white.
WHITENESS 所有输出变白
For a complete list of raster-operation codes, seeAbout Raster Operation Codes in the Appendices section of the Win32 SDK Programmer’s Reference.有关光栅操作代码的完整列表,请参阅联机文档“Win32 SDK程序员参考”附录节中的“关于光栅操作代码”ResCopies a bitmap from the source device context to this current device context. 从源设备上下文拷贝位图到这个当前设备上下文。 The application can align the windows or client areas on byte boundaries to ensure that the BitBlt operations occur on byte-aligned rectangles. (Set the CS_BYTEALIGNWINDOW or CS_BYTEALIGNCLIENT flags when you register the window classes.) 应用可以在字节边界上对齐窗口或客户区域,保证BitBlt操作发生在以字节对齐的矩形上(登记窗口类时设置设备CS_BYTEALLGNWINDOW或CS_BYTE-ALIGHCLIENT标记) BitBlt operations on byte-aligned rectangles are considerably faster than BitBlt operations on rectangles that are not byte aligned. If you want to specify class styles such as byte-alignment for your own device context, you will have to register a window class rather than relying on the Microsoft Foundation classes to do it for you. Use the global function AfxRegisterWndClass.在字节对齐矩形上的BitBlt操作比未经字节对齐的矩形上的BitBlt操作快许多。如果想对自己的设备上下文指定字节对齐类风格,必须登记窗口类而不要依赖Microsoft基本类。可使用全局函数AfxRegisterWndClass。 GDI transforms nWidth and nHeight, once by using the destination device context, and once by using the source device context. If the resulting extents do not match, GDI uses the Windows StretchBlt function to compress or stretch the source bitmap as necessary.一旦使用目标设备上下文和使用源设备上下文,GDI变形nWidth和nHeight。如果结果延伸不匹配,必要时GDI使用Windows StretchBlt函数压缩或拉伸源位图。 If destination, source, and pattern bitmaps do not have the same color format, the BitBlt function converts the source and pattern bitmaps to match the destination. The foreground and background colors of the destination bitmap are used in the conversion. 如果目标、源和特征位图颜色格式不同,BitBlt转换源和特征位图以匹配目标。转换中使用目标位图的前景和背景色。 When the BitBlt function converts a monochrome bitmap to color, it sets white bits (1) to the background color and black bits (0) to the foreground color. The foreground and background colors of the destination device context are used. To convert color to monochrome, BitBlt sets pixels that match the background color to white and sets all other pixels to black. BitBlt uses the foreground and background colors of the color device context to convert from color to monochrome.BitBlt函数把单色位图转换为彩色时,它设置白色(1)为背景色,黑色(0)作为前景色。使用目标设备上下文的背景和前景色。要把彩色转换为单色,BitBlt把与背景色匹配的像素设置为白色,其余所有像素设置为黑色。在从彩色到单色的转换中,BitBlt使用彩色设备上下文的前景和背景色 Note that not all device contexts support BitBlt. To check whether a given device context does support BitBlt, use the GetDeviceCaps member function and specify the RASTERCAPS index.注意,并非所有的设备上下文都支持BitBlt。为检查给定设备上下文是否支持BitBlt,使用GetDeviceCaps成员函数并指定RASTERCAPS索引 CDC Overview | Class Members | Hierarchy ChartSee Also CDC::GetDeviceCaps, CDC::PatBlt, CDC::SetTextColor, CDC::StretchBlt,::StretchDIBits,::BitBlt