Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey all,

 

Im a recent convert to VB2008 Express from VB6.0 Enterprise [1.5 days now:)]

 

Anyway, the program im writing has a graph, which i want to fade in (most recent data brighter)

 

in vb6 i would use something like

 

for x=1 to 149
picbox.line(x-1,data(x-1))-(x,data(x)), [b]rgb(105 + x,0,0)[/b]
next x

 

Ive highlighted the bit im struggling with in VB2008, from what ive read on MSDN, and the really crap help file included with VB it seems I need to:

 

create a brush

create a pen from the brush

draw a line

destroy the pen

destroy the brush

 

REPEAT 150 times

 

surely this cant be right, i just want to use a custom color for my line, I can use a built in color without problem, but i need to be able to specify RGB values.

 

Here is the line of code i have for VB2008:

e.Graphics.DrawLine([b]Pens.Red[/b], AccelChartX - 1, 40 - AccelChartPrevX, AccelChartX, 40 - AccelChartTempX)

 

The bold bit is the problem, i have tried color.fromARGB(105+AccelChartX,0,0) but it didnt work.

 

 

2nd issue, Send Input.

 

I have been searching for the easiest way to impliment SendInput API. I need to inject key up, and key down messages into the the keyboard buffer.

 

All the examples i have found have all the code for mouse input blended into into the example or are mouse only. Im looking for the simplest solution that will let me inject keystrokes {F1} {F2} etc into the input stream AS EARLY AS POSSIBLE so that they can be processed as if physically typed on the keyboard (im open to alternatives to sendinput, but need it to work way upstream)

 

Sorry for the long post, but I hoped to give potential helpers as much info as possible.

 

Regards

 

:thumb:Gangsta

  • Leaders
Posted

You list the steps for drawing a colored line as:

create a brush

create a pen from the brush

draw a line

destroy the pen

destroy the brush

[/Quote]

You don't need to create a brush at all, just the pen. What's more, you can change the color of the pen and re-use it for differently-colored lines.

 

[color="SeaGreen"]' Draw 256 lines in different shades of gray
' using one pen[/color]
Using p As Pen = New Pen(Color.Beige)) 
   For i As Integer = 0 To 255
       e.Graphics.DrawLine(p, i, 0, i, 256)
       p.Color = Color.FromArgb(i, i, i)
   Next
End Using

 

 

As for Color.fromARGB(105+AccelChartX,0,0), what was the problem? A compiler error? Exception thrown? What was the error? Or was the result not what you were expecting?

 

With SendInput, what is the problem with a solution that has mouse support? Is there a reason you can't just ignore the part you don't need?

[sIGPIC]e[/sIGPIC]
Posted

Hi Marble_Eater,

 

Thanks for the prompt response, the pen worked perfect - I think i was using it in the wrong place when trying to set the color, either way its fixed now and running exactly as I would like.

 

The SendInput, the reason I dont want all the mouse stuff in there is that it looks really untidy, and im not sure what bits are required - as the samples I have seen all seem to fill an array with data then copymemory to whereever it needs to go before passing it to sendInput, I just want the absolute basics needed to send keys to a pygame window.

 

Regards

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...