简体   繁体   English

在上下文之间传输对象的问题

[英]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 文件的链接:

https://pastebin.com/h7hcLJbz https://pastebin.com/h7hcLJbz

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.

相关问题 在常量表达式上下文中修改对象 - Modification of objects in constant expression contexts 如何在两个 boost::intrusive::slist 对象之间传输节点 - How to transfer nodes between two boost::intrusive::slist objects 在C ++中是否可以在不兼容类型的std :: vector对象之间传输不同类型的缓冲区 - Is it possible in C++ to transfer a buffer of a different type between std::vector objects of incompatible types 我可以在 2 个 OpenGL 上下文、Android 之间共享外部纹理吗 - Can I share a external texture between 2 OpenGL contexts, Android 在OS X上的OpenGL上下文之间共享数据(不同的版本/配置文件) - Sharing data between OpenGL contexts on OS X (different version / profile) 使用GLFW3在OpenGL上下文之间共享纹理不起作用 - Sharing textures between OpenGL contexts with GLFW3 is not working 在Qt中的表单之间传输数据 - Transfer data between forms in Qt 在Linux中的进程之间传输套接字 - transfer socket between processes in Linux 如何在 C++ 中将对象从对象数组传输到另一个对象? - How to transfer objects from an array of objects to another in C++? 如何在“ mwArray *”和“ mxArray *”之间传输数据? - How can transfer data between “mwArray *” and “mxArray *”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM