带绘图的奇怪问题(GDI) [英] Weird Issues w/ Drawing (GDI)

查看:69
本文介绍了带绘图的奇怪问题(GDI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我是一个嵌入式人,正在尝试使用核心win32 API做一些GUI应用程序。  我会尽力解释我所看到的这个奇怪的问题,让我感到非常困惑。  请光临我,我不是GDI专家!


1。  我的绘图结构如下:


案例WM_PAINT:


PAINTSTRUCT Ps;

HDC hDC = BeginPaint(hWnd,& Ps);


My_Paint_Function(hDC);


EndPaint(hWnd,& ; Ps);


休息;


2。  在My_Paint_Function中,我有其他函数调用其他函数,它们都传递了hDC参数。 (我在任何地方都没有任何递归调用) 我在那些与
相关的函数中调用的唯一相关函数是SelectObject,  SetDCPenColor,  SetBrushColor,Rectangle,Ellipse,MoveToEx和LineTo 。  


3。  问题是我绘制的一些线条遍布整个窗口。  矩形和椭圆很好。  真正奇怪的是,当我将My_Paint_Function
调用的所有不同子函数的所有逻辑组合在一起,并将对My_Paint_Function的调用替换为分解逻辑(不在函数内部)时,它可以正常工作。 / p>

4。  我有意义吗?  有人知道我在说什么吗?  我可以发布实际的源代码,如果有人慷慨,需要一些时间来帮助我:)



任何回复都非常感谢,因为我真的很接近放弃我的初始方法,使我的代码"漂亮"通过将其分解为许多不同的子函数,并将所有逻辑抛出WM_PAINT案例。

解决方案

可能某些常见变量未在函数之间正确共享或传递。如果可能,请显示您的功能。


Hi all,

I'm an embedded guy, that's trying to do some GUI apps using the core win32 API.  I'll do my best to explain this weird issue that I'm seeing, which has me really puzzled.  Please bare w/ me, I am no GDI expert !

1.  I've got my drawing structured as such:

case WM_PAINT:

PAINTSTRUCT Ps;
HDC hDC = BeginPaint(hWnd, &Ps);

My_Paint_Function(hDC);

EndPaint(hWnd, &Ps);

break;

2.  Inside My_Paint_Function, i have other functions which call other functions and they're all passing around the hDC parameter. (I don't have any recursive call anywhere)  The only relevant functions that I call within those functions that pertain to GDI are SelectObject, SetDCPenColor, SetBrushColor, Rectangle, Ellipse, MoveToEx, and LineTo.  

3.  The problem is that some of the lines that I draw are scattered all over the window.  The rectangles and ellipses are fine.  The really weird thing is that when I combine all the logic of all the different subfunctions that My_Paint_Function calls, and replace the call to My_Paint_Function with the broken up logic (not inside of functions), it works fine.

4.  Am I making any sense ?  Does anybody know what I'm talking about ?  I can post actual source code if someone is generous enough to take some time to help me :)

Any replies are greatly appreciated, as I'm really close to abandoning my initial approach of making my code "pretty" by breaking it up into many different sub-functions, and just throwing all the logic inside the WM_PAINT case.

解决方案

Maybe some of the common variables are not correctly shared or passed between functions. If possible, show your functions.


这篇关于带绘图的奇怪问题(GDI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆