473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CreateGraphics logic

Hi,

How to write a CreateGraphics method for a class similar to
form.CreateGraphics()?

Pls help. Thanks in Advance.

Dec 26 '07 #1
4 2448
Well, what kind of class do you want to generate a device context for
(which the Graphics class is really a wrapper for).

What exactly are you trying to do? The device context is something that
is typically generated for you. Unless you have some sort of output device
which windows doesn't handle (which would be wrong, since you should go
through the hardware abstraction layer to get a device context to output on
anyways), you really shouldn't be creating a Graphics instance yourself.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<vi********@rediffmail.comwrote in message
news:34**********************************@e25g2000 prg.googlegroups.com...
Hi,

How to write a CreateGraphics method for a class similar to
form.CreateGraphics()?

Pls help. Thanks in Advance.

Dec 26 '07 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OO**************@TK2MSFTNGP06.phx.gbl...
Well, what kind of class do you want to generate a device context for
(which the Graphics class is really a wrapper for).

What exactly are you trying to do? The device context is something
that is typically generated for you. Unless you have some sort of output
device which windows doesn't handle (which would be wrong, since you
should go through the hardware abstraction layer to get a device context
to output on anyways), you really shouldn't be creating a Graphics
instance yourself.
Most likely Graphics.FromImage is appropriate, see
http://msdn2.microsoft.com/en-us/lib...fromimage.aspx
>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<vi********@rediffmail.comwrote in message
news:34**********************************@e25g2000 prg.googlegroups.com...
>Hi,

How to write a CreateGraphics method for a class similar to
form.CreateGraphics()?

Pls help. Thanks in Advance.


Dec 27 '07 #3
Hi Nicholas/Ben,

Thanks for your reply.

I too used the Graphics.FromImage() but I am facing some problems
using it in my control. Is there any other way to get the graphics?


On Dec 26, 9:28*pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
* * Well, what kind of class do you want to generate a device context for
(which the Graphics class is really a wrapper for).

* * What exactly are you trying to do? *The device context is something that
is typically generated for you. *Unless you have some sort of output device
which windows doesn't handle (which would be wrong, since you should go
through the hardware abstraction layer to get a device context to output on
anyways), you really shouldn't be creating a Graphics instance yourself.

--
* * * * * - Nicholas Paldino [.NET/C# MVP]
* * * * * - m...@spam.guard.caspershouse.com

<vijay_3...@rediffmail.comwrote in message

news:34**********************************@e25g2000 prg.googlegroups.com...
Hi,
How to write a CreateGraphics method for a class similar to
form.CreateGraphics()?
Pls help. Thanks in Advance.- Hide quoted text -

- Show quoted text -
Dec 27 '07 #4
You still haven't answered the question. What are you trying to get the
graphics instance of? Are you trying to manipulate an image? Or are you
trying to custom paint your control?

If you are trying to custom paint your control, and you are in a class
that derives from that control, then you can override the OnPaint method and
get the Graphics instance from the PaintEventArgs that is passed in to the
method.

If you want to do this outside of the control, you will have to
subscribe to the Paint event and then get the Graphics instance from the
PaintEventArgs passed to the event.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
<vi********@rediffmail.comwrote in message
news:c0**********************************@l6g2000p rm.googlegroups.com...
Hi Nicholas/Ben,

Thanks for your reply.

I too used the Graphics.FromImage() but I am facing some problems
using it in my control. Is there any other way to get the graphics?


On Dec 26, 9:28 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Well, what kind of class do you want to generate a device context for
(which the Graphics class is really a wrapper for).

What exactly are you trying to do? The device context is something that
is typically generated for you. Unless you have some sort of output device
which windows doesn't handle (which would be wrong, since you should go
through the hardware abstraction layer to get a device context to output
on
anyways), you really shouldn't be creating a Graphics instance yourself.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<vijay_3...@rediffmail.comwrote in message

news:34**********************************@e25g2000 prg.googlegroups.com...
Hi,
How to write a CreateGraphics method for a class similar to
form.CreateGraphics()?
Pls help. Thanks in Advance.- Hide quoted text -

- Show quoted text -

Dec 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: RickDee | last post by:
I really can't understand on how to use CreateGraphics. Even though I have follow what is shown in many sites, I can't get it working at all. For example. I have textbox name textbox1. I...
1
by: S Domadia | last post by:
hi, now actually i want to design custom combo in which combo's button (in which down arrow is there to perform clicking for dropdown type of combo) should be also black in color. so as it's not...
1
by: JH | last post by:
I have a tab control in my form. I am trying to create a dynamic pie chart. If I use the following code,it works fine on the main form. this.CreateGraphics().FillPie(brushtargeted,240,200,200, 200,...
1
by: takilroy | last post by:
Hi, I am trying to implement this snippet of code from the .Net help documentatiion so that I can modify the width of a textbox on one of my aspx forms. However, for some reason visual studio...
11
by: active | last post by:
picInfo is a PictureBox that I write into when the mouse moves. Below is a snip of the code. The text flashes on the screen but does not stay there. Anyone know why? Second question.-...
6
by: saunderl | last post by:
Hello Everyone, I'm trying to just play with managed VC++. I just want to draw a box on the form when it is clicked. Here is my click event handler System::Void Test_Click(System::Object^ ...
8
by: pigeonrandle | last post by:
Hi, Please pity me, i am on a dial-up connection for the first time in 5 years :( ! Does anyone know how the resulting Graphics objects differ ...? What i really mean is can someone explain it...
6
by: active | last post by:
I did the following and then wondered it's good practice. Me.CreateGraphics.DrawImage(Img, 0, 0) I'm thinking about disposing the Graphics object. A couple of lines after this I exit the sub...
3
by: bromptonville-un | last post by:
Hello, I'm an amateur in VB6, and I just switched to VB.Net (2003) . However, I've never used graphicals functions in neither those language... (Last time I drew something was in VB6). I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.