奇怪的,不一致的程序行为 [英] odd, inconsistant program behavior

查看:100
本文介绍了奇怪的,不一致的程序行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在主窗口中单击获取卡"控件.将创建一个卡片窗口,然后用户选择他的卡片.然后隐藏该卡窗口,然后在主窗口中显示这2张卡(有效 罚款),并绘制带有新数据的图形,以及不相关的箭头.这有3个回合.

i have an application where on the main window the user clicks on a get cards control.  a cards window is created, and the user picks his cards.  that card window is then hidden and back in the main window those 2 cards are displayed (which works fine) and a graph with new data is drawn, as is an unrelated arrow.  there are 3 rounds of this.

在首次创建主窗口时,图形绘图起作用.但是出于某种原因,偶尔,只有在第一轮领料卡中,我要绘制的图形和箭头才会显示.即使我使用相同的播放顺序, 相同的卡输入,通常可以使用,但有时不起作用.这样怎么会前后矛盾呢?相同的代码,相同的数据,但偶尔会有不同的行为.

when the main window is first created, the graph drawing works.  but for some reason, occasionally, and only in the first round of picking cards, the graph and arrow i want to draw don't show up.  even when i use the same sequence of play, the same cards input, it usually works but sometimes not.  how can that be inconsistant like that?  same code, same data, yet occasionlly different behavior.

顺便说一句,我注意到如果没有显示图形绘图,如果我最小化窗口然后将其扩展,图形的确会显示出来.我认为调用OnPaint函数并进行第二次绘画尝试?

btw, i notice if the graph drawing doesn't show up, if i minimize the window and then expand it, the graph does show up.  i think that calls the OnPaint function and the second attempt at paint works?

无论如何,也许以某种方式绘制图形的笔刷不起作用?我知道程序可以到达绘制图形的代码,因为它位于指示显示卡片的位置相同(并且效果很好).反正, 我使用几种颜色绘制图形数据.我为画笔绘制图形所用的代码如下:

anyway, perhaps somehow the brushes that draw the graph aren't functioning?  i know the program reaches the code for drawing the graph because it's in the same place where the cards are instructed to be displayed (and that works fine).  anyway, i use several colors to draw the graph data.  the code i have for the brushes to draw the graph is as follows:

在对话框功能中,我创建了画笔:

in the dialog function, i create the brushes:

penBlack.CreatePen(PS_SOLID,2,RGB(0,0,0));
penBlackThin.CreatePen(PS_SOLID,1,RGB(0,0,0));

penBlack.CreatePen(PS_SOLID,2,RGB(0,0,0));
penBlackThin.CreatePen(PS_SOLID,1,RGB(0,0,0));

然后在OnPaint()中

then in OnPaint(),

pOldPen =(CPen *)dc.SelectObject(& penBlack);
CBrush * pOldBrush;
pOldBrush =(CBrush *)dc.SelectObject(& brGreen);

pOldPen=(CPen*)dc.SelectObject(&penBlack);
CBrush* pOldBrush;
pOldBrush=(CBrush*)dc.SelectObject(&brGreen);


总之,

1)始终在显示/绘制主窗口时始终成功用笔绘制图形
2)间歇性地,在第一轮领料卡之后,根本看不到该图
3)之后的每一轮,都会绘制图形.

1) a graph is always successfully drawn with pens when the main window first is displayed/painted
2) intermitantly, after the first round of picking cards, the graph is not seen at all
3) every round after that, the drawing of the graph works.

顺便说一句,我的Visual C ++调试模式无法正常工作,这使得调试变得更加困难.

btw, my debug mode of visual c++ is not functioning, which makes it harder to debug.

为什么这通常会起作用但并非总是如此?

any ideas why this usually works but not always?

推荐答案

检查是否 选择了 pOldBrush 和其他对象 SelectObject .同时检查是否 CPaintDC .在调试模式下显示有关问题的详细信息.

Check if pOldPen, pOldBrush and other objects were selected back with SelectObject at the end of OnPaint. Also check if dc is a CPaintDC. Show details about the problems in Debug mode.


这篇关于奇怪的,不一致的程序行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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