其中关键代码如下
是在响应WM_PAINT中的
#define RESOLUTION 256
后面的画直线代码其实就是画了很短的一条线,然后BitBlt把它变成扫描线了(我注释掉BitBlt后扫描线消失)
然后BitBlt的源DC与目标DC不同的话也不会有扫描线....
好像是源DC与目标DC相同的原因 以致出现扫描线, 不过只是我猜的,还请各位指教下!!还有就是 两次GetDC(g_hWndSample); 同一个窗口只能有一个DC句柄吗?void UpdateSample(void)
{
HDC hdc;
HBITMAP hbm;
RECT rt;
HPEN hPen; long width;
long height;
long pos; // Drawing Golf Ball hdc = GetDC(g_hWndSample); // SelectObject(hdc, (HGDIOBJ)GetStockObject(BLACK_BRUSH)); GetClientRect(g_hWndSample, &rt); width = rt.right - rt.left + 1;
height = rt.bottom - rt.top; hbm = CreateCompatibleBitmap(hdc, width * (RESOLUTION - 1) / RESOLUTION, height); SelectObject(hdc, hbm);
HDC hDC =GetDC(g_hWndSample); //自己测试加的 BitBlt(hdc, width / RESOLUTION, 0, width * (RESOLUTION - 1) / RESOLUTION, height, hDC, 0, 0, SRCCOPY); rt.right = rt.left + width / RESOLUTION; InvalidateRect(g_hWndSample, &rt, TRUE); UpdateWindow(g_hWndSample); // Drawing Grid // Drawing Line // Drawing Y accelerate register unsigned long color1 = ((g_sHistory & 0x02) ? RGB(0, 255, 0) : RGB(0, 0, 0));
register unsigned long width1 = ((g_sHistory & 0x02) ? 2 : 1); hPen = CreatePen(PS_SOLID, width1, color1); SelectObject(hdc, hPen); pos = height / 2 + (g_yCurrent - g_CaliInfo.y0) * height / (255 - g_CaliInfo.y0) / 2; pos = (height + pos) % height; MoveToEx(hdc, 0, pos, NULL); pos = height / 2 + (g_yHistory - g_CaliInfo.y0) * height / (255 - g_CaliInfo.y0) / 2; pos = (height + pos) % height; LineTo(hdc, width / RESOLUTION, pos);
DeleteObject(hPen); DeleteObject(hbm); ReleaseDC(g_hWndSample, hdc);
}图:
还有拉个窗口过去遮住它会有“残影"
是在响应WM_PAINT中的
#define RESOLUTION 256
后面的画直线代码其实就是画了很短的一条线,然后BitBlt把它变成扫描线了(我注释掉BitBlt后扫描线消失)
然后BitBlt的源DC与目标DC不同的话也不会有扫描线....
好像是源DC与目标DC相同的原因 以致出现扫描线, 不过只是我猜的,还请各位指教下!!还有就是 两次GetDC(g_hWndSample); 同一个窗口只能有一个DC句柄吗?void UpdateSample(void)
{
HDC hdc;
HBITMAP hbm;
RECT rt;
HPEN hPen; long width;
long height;
long pos; // Drawing Golf Ball hdc = GetDC(g_hWndSample); // SelectObject(hdc, (HGDIOBJ)GetStockObject(BLACK_BRUSH)); GetClientRect(g_hWndSample, &rt); width = rt.right - rt.left + 1;
height = rt.bottom - rt.top; hbm = CreateCompatibleBitmap(hdc, width * (RESOLUTION - 1) / RESOLUTION, height); SelectObject(hdc, hbm);
HDC hDC =GetDC(g_hWndSample); //自己测试加的 BitBlt(hdc, width / RESOLUTION, 0, width * (RESOLUTION - 1) / RESOLUTION, height, hDC, 0, 0, SRCCOPY); rt.right = rt.left + width / RESOLUTION; InvalidateRect(g_hWndSample, &rt, TRUE); UpdateWindow(g_hWndSample); // Drawing Grid // Drawing Line // Drawing Y accelerate register unsigned long color1 = ((g_sHistory & 0x02) ? RGB(0, 255, 0) : RGB(0, 0, 0));
register unsigned long width1 = ((g_sHistory & 0x02) ? 2 : 1); hPen = CreatePen(PS_SOLID, width1, color1); SelectObject(hdc, hPen); pos = height / 2 + (g_yCurrent - g_CaliInfo.y0) * height / (255 - g_CaliInfo.y0) / 2; pos = (height + pos) % height; MoveToEx(hdc, 0, pos, NULL); pos = height / 2 + (g_yHistory - g_CaliInfo.y0) * height / (255 - g_CaliInfo.y0) / 2; pos = (height + pos) % height; LineTo(hdc, width / RESOLUTION, pos);
DeleteObject(hPen); DeleteObject(hbm); ReleaseDC(g_hWndSample, hdc);
}图:
还有拉个窗口过去遮住它会有“残影"
解决方案 »
- vc中如何把剪贴板中的数据粘贴到excel中
- EVC组合框问题
- 郁闷
- 设置静态文本框时出的一点小的问题
- 延时的ft问题
- 请问那一个控件可以显示gif图片呢?
- 请问一个位图双缓冲的问题?
- 各位大侠,串口设置是不是有个数据控制流的参数,应该怎么设置?
- 初级问题!
- win32 下一个窗口类创建两个窗口,如和让两个窗口都关闭后winmain再退出
- ▓▓▓▓▓谁有ethereal抓包工具的安装文件跟汉化包???要能用的▓▓▓▓▓
- 基于MFC,利用MSComm控件做得串口通信,只能发送,不能接收,OnComm事件调试模式下发现没有触发,大家进来帮我看看啊,baidu、Google都用了没找到答案,先谢谢大家了
我感觉很强大...
我觉得应该只有一个DC,你看看两次GetDC获取的句柄相同不?