VB2005 pro Graphics [英] VB2005 pro Graphics

查看:73
本文介绍了VB2005 pro Graphics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从VB6(RAD)转到VB2005(SAD)


文档总是显示绘画事件中的图形画像


Private Sub Pictcolor_Paint(ByVal sender As Object,ByVal e _

As System.Windows.Forms.PaintEventArgs)处理PictColor.Paint


End Sub


但是我的VB6程序从许多不同的

潜艇中抽取到了图片盒PictColor。

我可以直接从子目录中绘制到PictColor,如下所示: br />
这里我绘制像素


Dim h As Graphics,g As Graphics,p As New Pen(Color.Black)

''绘制颜色方块

g = Me.PictColor.CreateGraphics

h = Me.picBW.CreateGraphics

对于intNumber0 = 0到255

对于intNumber1 = 0到255

p.Color = Color.FromArgb(intNumber0,255 - intNumber1,255 -

intNumber0)

g.DrawEllipse(p,intNumber1,intNumber0,1,1)

p.Color = Color.FromArgb(intNumber0,intNu mber0,intNumber0)

h.DrawEllipse(p,intNumber1,intNumber0,1,1)

下一页

下一页


我在这里绘制线条


Dim Incr,索引为短,g为图形,p为新笔(Color.Black),c为

颜色

g = Me.PictColor.CreateGraphics

c = Color.FromArgb(mlColors(0))

p.Color = c

Incr = 200/5

索引= 0到5步骤1

g.DrawLine(p,X1,Y1,X2,Y2 )

X1 = X1 + Incr

如果指数= 4那么X1 = X1 - 1

X2 = X1

下一个索引


或者我必须为PictColor制作大量不同的Paint事件吗?


如果我可以在Paint之外做事件,我可以在Form加载后声明CreateGraphics

吗?

GalenS

解决方案

Galen Somerville写道:

从VB6(RAD)转到VB2005(SAD)

文件总是s显示绘画事件中的图形画像

私人子Pictcolor_Paint(ByVal发送者为对象,ByVal e _
As System.Windows.Forms.PaintEventArgs)处理PictColor.Paint

结束子

但是我的VB6程序从许多不同的潜艇中抽取到了图片盒的PictColor。
我可以直接从潜水员绘制到PictColor,如下所示:

这里我画的像素

Dim h As Graphics,g As Graphics,p As New Pen(Color.Black)
''绘制颜色方块
g = Me.PictColor.CreateGraphics
对于intNumber0 = 0到255
对于intNumber1 = 0到255
p.Color = Color.FromArgb( intNumber0,255 - intNumber1,255 -
intNumber0)
g.DrawEllipse(p,intNumber1,intNumber0,1,1)
p.Color = Color.FromArgb(intNumber0,intNumber0,intNumber0)
h.DrawEllipse(p,intNumber1,intNumber0,1,1)
下一页

Dim Incr,索引为短,g为图形,p为新笔(Color.Black),c为
颜色
g = Me .PictColor.CreateGraphics
c = Color.FromArgb(mlColors(0))
p.Color = c
Incr = 200/5
索引= 0到5步骤1
g.DrawLine(p,X1,Y1,X2,Y2)
X1 = X1 + Incr
如果Index = 4那么X1 = X1 - 1
X2 = X1 下一个索引

或者我必须为PictColor制作大量不同的Paint事件吗?

如果我可以在Paint事件之外完成它,我可以声明CreateGraphics <表单加载后一次?

GalenS




在paint方法中执行此操作的原因是该事件每个对象需要刷新的时间被调用
。因此,如果窗口穿过您的表格

,现在需要重新绘制。你怎么知道什么时候重新绘制

你没有捕获PictureBox.Paint事件?


你可以从paint事件中调用一个sub并传递图形

对象。


希望这有帮助

Chris



" Chris" < no@spam.com>在消息中写道

新闻:Og ************** @ TK2MSFTNGP09.phx.gbl ...

Galen Somerville写道:< blockquote class =post_quotes>从VB6(RAD)转到VB2005(SAD)

文档总是显示绘图事件中的图形画像

Private Sub Pictcolor_Paint(ByVal)发送者作为对象,ByVal e _
As System.Windows.Forms.PaintEventArgs)处理PictColor.Paint

结束子

但我的VB6程序绘制到图片框PictColor来自许多不同的潜艇。
我可以直接从潜水画画到PictColor,如下所示:

这里我画的像素

Dim h As Graphics ,g作为图形,作为新笔(Color.Black)
''绘制颜色方块
g = Me.PictColor.CreateGraphics
h = Me.picBW.CreateGraphics
对于intNumber0 = 0到255
对于intNumber1 = 0到255
p.Color = Color.FromArgb(intNumber0,255 - intNumber1,255 -
intNumber0)
g.DrawEllipse(p,intNumber1,intNumber0,1,1)
p.Color = Color.FromArgb(intNumber0,intNumber0,intNumber0)
h.DrawEllipse(p,intNumber1,intNumber0,1, 1)
下一页

我在这里画线

Dim Incr,索引为短,g为图形,p为新笔(颜色) .Black),c As
颜色
g = Me.PictColor.CreateGraphics
c = Color.FromArgb(mlColors(0))
p.Color = c
Incr = 200/5
索引= 0到5步骤1
g.DrawLine(p,X1,Y1,X2,Y2)
X1 = X1 + Incr
如果索引= 4然后X1 = X1 - 1
X2 = X1


或者我必须为PictColor制作大量不同的Paint事件吗?

GalenS


,现在需要重新绘制。如果你没有捕获PictureBox.Paint事件,你怎么知道何时重新绘制?

你可以从paint事件中调用sub并传入图形对象。

希望这有帮助
Chris




ouch。当前程序实时显示心音。就是它b / b
像示波器一样扫过屏幕,新数据取代旧数据(5到10像素间隙)

>
他们可以冻结屏幕以查看当前显示。没有其他程序

被允许篡夺屏幕。


假设他们想要放置带延迟的标记(小垂直线)

毫秒。鼠标向下,鼠标向上移动和鼠标移动显示标记

和延迟并将其移动到波形中,直到他们对

放置感到满意为止。

现在他们可以添加其他标记(最多六个)。


这在VB6中很容易但是我无法理解为

在VB2005中完成此任务。


GalenS(如果我是另一个Galen,我会知道)



" Galen Somerville" < GA *** @ SPAM.surewest.net>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...



我甚至没有尝试在.Net中绘制任何东西,但.....你不能创建

a sub来绘制和从任何地方打电话再加上油漆

活动?听起来像VB6方式我知道< g>

GalenS(如果我是另一个Galen,我会知道)




也许你*是*其他盖伦没有人告诉你? < g>


-

Ken Halter - MS-MVP-VB(从VB6世界访问) - http://www.vbsight.com

请保持小组内的所有讨论..


Going from VB6 (RAD) to VB2005 (SAD)

The documentation always shows graphics drawing in a paint event like

Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles PictColor.Paint

End Sub

But my VB6 program draws to the picturebox PictColor from many different
subs.
Can I draw to PictColor directly from subs as follows:
Here I am drawing pixels

Dim h As Graphics, g As Graphics, p As New Pen(Color.Black)
''Draws the color squares
g = Me.PictColor.CreateGraphics
h = Me.picBW.CreateGraphics
For intNumber0 = 0 To 255
For intNumber1 = 0 To 255
p.Color = Color.FromArgb(intNumber0, 255 - intNumber1, 255 -
intNumber0)
g.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
p.Color = Color.FromArgb(intNumber0, intNumber0, intNumber0)
h.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
Next
Next

Here I am drawing lines

Dim Incr, Index As Short, g As Graphics, p As New Pen(Color.Black), c As
Color
g = Me.PictColor.CreateGraphics
c = Color.FromArgb(mlColors(0))
p.Color = c
Incr = 200 / 5
For Index = 0 To 5 Step 1
g.DrawLine(p, X1, Y1, X2, Y2)
X1 = X1 + Incr
If Index = 4 Then X1 = X1 - 1
X2 = X1
Next Index

Or do I have to make a cajillion different Paint events for PictColor ??

If I can do it outside of Paint events, can I declare the CreateGraphics
once after Form load ??
GalenS

解决方案

Galen Somerville wrote:

Going from VB6 (RAD) to VB2005 (SAD)

The documentation always shows graphics drawing in a paint event like

Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles PictColor.Paint

End Sub

But my VB6 program draws to the picturebox PictColor from many different
subs.
Can I draw to PictColor directly from subs as follows:
Here I am drawing pixels

Dim h As Graphics, g As Graphics, p As New Pen(Color.Black)
''Draws the color squares
g = Me.PictColor.CreateGraphics
h = Me.picBW.CreateGraphics
For intNumber0 = 0 To 255
For intNumber1 = 0 To 255
p.Color = Color.FromArgb(intNumber0, 255 - intNumber1, 255 -
intNumber0)
g.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
p.Color = Color.FromArgb(intNumber0, intNumber0, intNumber0)
h.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
Next
Next

Here I am drawing lines

Dim Incr, Index As Short, g As Graphics, p As New Pen(Color.Black), c As
Color
g = Me.PictColor.CreateGraphics
c = Color.FromArgb(mlColors(0))
p.Color = c
Incr = 200 / 5
For Index = 0 To 5 Step 1
g.DrawLine(p, X1, Y1, X2, Y2)
X1 = X1 + Incr
If Index = 4 Then X1 = X1 - 1
X2 = X1
Next Index

Or do I have to make a cajillion different Paint events for PictColor ??

If I can do it outside of Paint events, can I declare the CreateGraphics
once after Form load ??
GalenS



The reason to do it in the paint method is that event gets called each
time the object needs to refresh. So if a window goes across your form
and it now needs to be repainted. How will you know when to repaint if
you don''t capture the PictureBox.Paint event?

You can call a sub from inside the paint event and pass in the graphics
object.

Hope this helps
Chris



"Chris" <no@spam.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...

Galen Somerville wrote:

Going from VB6 (RAD) to VB2005 (SAD)

The documentation always shows graphics drawing in a paint event like

Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles PictColor.Paint

End Sub

But my VB6 program draws to the picturebox PictColor from many different
subs.
Can I draw to PictColor directly from subs as follows:
Here I am drawing pixels

Dim h As Graphics, g As Graphics, p As New Pen(Color.Black)
''Draws the color squares
g = Me.PictColor.CreateGraphics
h = Me.picBW.CreateGraphics
For intNumber0 = 0 To 255
For intNumber1 = 0 To 255
p.Color = Color.FromArgb(intNumber0, 255 - intNumber1, 255 -
intNumber0)
g.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
p.Color = Color.FromArgb(intNumber0, intNumber0, intNumber0)
h.DrawEllipse(p, intNumber1, intNumber0, 1, 1)
Next
Next

Here I am drawing lines

Dim Incr, Index As Short, g As Graphics, p As New Pen(Color.Black), c As
Color
g = Me.PictColor.CreateGraphics
c = Color.FromArgb(mlColors(0))
p.Color = c
Incr = 200 / 5
For Index = 0 To 5 Step 1
g.DrawLine(p, X1, Y1, X2, Y2)
X1 = X1 + Incr
If Index = 4 Then X1 = X1 - 1
X2 = X1
Next Index

Or do I have to make a cajillion different Paint events for PictColor ??

If I can do it outside of Paint events, can I declare the CreateGraphics
once after Form load ??
GalenS



The reason to do it in the paint method is that event gets called each
time the object needs to refresh. So if a window goes across your form
and it now needs to be repainted. How will you know when to repaint if
you don''t capture the PictureBox.Paint event?

You can call a sub from inside the paint event and pass in the graphics
object.

Hope this helps
Chris



ouch. The current program displays Heart sounds in real time. That is it
sweeps across the screen like an oscilloscope with the new data replacing
the old data (with a 5 to 10 pixel gap)

They can freeze the screen to look at the current display. No other program
is allowed to usurp the screen.

Say they want to place a Marker (small vertical line) with the Latency in
milliseconds. The Mouse down, Mouse up and Mouse move displays the Marker
and latency and moves it across the waveform until they are happy with
placement.

Now they can add other Markers (up to six).

This was easy in VB6 but I just can''t get it into my mind as to
accomplishing this in VB2005.

GalenS (if I were the other Galen, I would know)



"Galen Somerville" <ga***@SPAM.surewest.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...



This was easy in VB6 but I just can''t get it into my mind as to
accomplishing this in VB2005.
I haven''t even attempted drawing anything in .Net but..... can''t you create
a sub that does the drawing and call that from "anywhere" plus the paint
event? Sounds like "the VB6 way" I know <g>
GalenS (if I were the other Galen, I would know)



Maybe you *are* the other Galen and no one told you? <g>

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..


这篇关于VB2005 pro Graphics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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