大家应该看过电子地图,在电子地图中,比如铁路,是一段黑,一段白组成的,请问想这样的线条如何绘制出来呢?
因为我们通常使用的 画笔对象(HPEN)不能达到这样的效果,ExtCreatePen也不行。
请问这样的线条应该如何绘制呢?非常感谢。
因为我们通常使用的 画笔对象(HPEN)不能达到这样的效果,ExtCreatePen也不行。
请问这样的线条应该如何绘制呢?非常感谢。
解决方案 »
- 使用API函数如何添加菜单
- 急需VC6利用api取主板序号号代码。
- dll不使用.lib文件可以吗?
- 如何实现拉出窗口,从托盘区慢慢拉出的那种
- [MFC]如何截获「服务器端网路故障导致数据不能发送」这样的一个消息?
- 滚动窗口中输出文字不见了
- cmemfile和cfile的区别??
- 求教:普通C++类怎么和MFC交互?
- 想在程序界面中实现这么一类按钮:包括UP,MOVE,DOWN,SELECTED,DISABLED几种状态,跟界面的背景图片无缝集成,怎么做?
- 关于MFC中复制文件问题
- 如何得到网页的刷新事件,虽然刷新触发OndownloadComplete,但是OndownloadComplete不一定是刷新
- PostQuitMessage和ExitProcess的区别是什么?
// Resource handle to bitmap.
HRSRC hRes;
// Global handles to bitmap resource.
HGLOBAL hData;
void* hLockedData;
CBrush brush;
// Find the resource handle.
hRes = ::FindResource(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BRUSH), RT_BITMAP);
if (hRes != NULL)
{
// Lock and Load (or Load and Lock).
if (((hData = ::LoadResource(AfxGetResourceHandle(),
hRes)) != NULL) &&
((hLockedData = ::LockResource(hData)) != NULL))
{
// Initialize the brush.
brush.CreateDIBPatternBrush((const void*)hLockedData,
DIB_RGB_COLORS);
// Select the brush into the device context.
CBrush* pOldBrush = pDC->SelectObject(&brush);
// Draw.
pDC->Rectangle(50, 50, 200, 200);
// Restore the original device context.
pDC->SelectObject(pOldBrush);
// Free the resource.
::FreeResource(hLockedData);
}
}
void CTestMuView::OnDraw(CDC* pDC)
{
CTestMuDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here CRect rect;
GetClientRect(&rect);
// Resource handle to bitmap.
HRSRC hRes;
// Global handles to bitmap resource.
HGLOBAL hData;
void* hLockedData;
CBrush brush;
// Find the resource handle.
hRes = ::FindResource(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BRUSH), RT_BITMAP);
if (hRes != NULL)
{
// Lock and Load (or Load and Lock).
if (((hData = ::LoadResource(AfxGetResourceHandle(),
hRes)) != NULL) &&
((hLockedData = ::LockResource(hData)) != NULL))
{
// Initialize the brush.
brush.CreateDIBPatternBrush((const void*)hLockedData,
DIB_RGB_COLORS);
// Select the brush into the device context.
CBrush* pOldBrush = pDC->SelectObject(&brush);
// Draw.
pDC->Rectangle(rect.left, rect.Height()/2, rect.right, rect.Height()/2+5);
// Restore the original device context.
pDC->SelectObject(pOldBrush);
// Free the resource.
::FreeResource(hLockedData);
}
}
}这些代码是从MSDN上看来的