[英]Problem with transfer objects between contexts
I try to make some easy application which scrolling ECG singal which is drawing on bitmap grid.我尝试制作一些简单的应用程序,它在 bitmap 网格上绘制滚动 ECG 信号。 Environment which I use is Visual Studio 2013 with C++ MFC. My problem is with transfer gdi object like LineTo or Rectangle() function from dcMemory to my main device context (cdc).
我使用的环境是带有 C++ MFC 的 Visual Studio 2013。我的问题是从 dcMemory 传输 gdi object 或 Rectangle() function 到我的主设备上下文 (cdc)。 Before I make similar application using WinAPI and all go well.
在我使用 WinAPI 和所有 go 进行类似应用之前。 I spent a lot time with studying msdn and looking answer with google, and I have no idea why only bitmap from Bitmap.LoadBitmapW(IDB_BITMAP2) is printing.
我花了很多时间研究 msdn 并用谷歌寻找答案,但我不知道为什么只有 Bitmap.LoadBitmapW(IDB_BITMAP2) 中的 bitmap 正在打印。 Can anybody help me?
有谁能够帮助我?
Message when button from menu was calling:菜单按钮调用时的消息:
void CToradex_MFC_BitmapView::OnBitmapDraw()
{
Bitmap.LoadBitmapW(IDB_BITMAP2);
cdc.CreateDC(L"DISPLAY", NULL, NULL, NULL);
dcMemory.CreateCompatibleDC(&cdc);
LoadData();
GetObject(Bitmap, sizeof(bmpInfo), &bmpInfo);
dcMemory.SelectObject(&Pen);
dcMemory.Rectangle(100, 100, 200, 200);
dcMemory.LineTo(100, 300);
dcMemory.SelectObject(&Bitmap);
druk.DrawECG(&dcMemory, pointer, 3, SIGN_LEN);
}
Message on mouse button down:按下鼠标按钮时的消息:
void CToradex_MFC_BitmapView::OnLButtonDown(UINT,CPoint)
{
CToradex_MFC_BitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
POINT p;
GetCursorPos(&p);
x_start = p.x;
y_start = p.y;
}
Message on mouse move:鼠标移动消息:
void CToradex_MFC_BitmapView::OnMouseMove(UINT, CPoint)
{
POINT d;
//CDC * pDC = this->GetDC();
//this->GetClientRect(&rect);
//rect = CRect(rect.left, rect.top, rect.right, rect.bottom);
if (GetCursorPos(&d))
{
move_x = d.x - x_start;
move_y = d.y - y_start;
cdc.BitBlt(move_x, move_y, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
x_start = d.x;
y_start = d.y;
//Invalidate();
Sleep(10);
}
Below link for all.cpp file:以下是 all.cpp 文件的链接:
You need to select a bitmap into your DC first, then draw on top of it:您需要先将 select 和 bitmap 放入您的 DC,然后在其上绘制:
dcMemory.SelectObject(&Bitmap);
dcMemory.SelectObject(&Pen);
dcMemory.Rectangle(100, 100, 200, 200);
dcMemory.LineTo(100, 300);
druk.DrawECG(&dcMemory, pointer, 3, SIGN_LEN);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.