CreateGraphics logic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vijay_3491@rediffmail.com

    #1

    CreateGraphics logic

    Hi,

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

    Pls help. Thanks in Advance.



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: CreateGraphics logic

    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]
    - mvp@spam.guard. caspershouse.co m

    <vijay_3491@red iffmail.comwrot e in message
    news:346b0164-c5c0-417f-b8ff-b05b92e522e2@e2 5g2000prg.googl egroups.com...
    Hi,
    >
    How to write a CreateGraphics method for a class similar to
    form.CreateGrap hics()?
    >
    Pls help. Thanks in Advance.
    >
    >
    >

    Comment

    • Ben Voigt [C++ MVP]

      #3
      Re: CreateGraphics logic


      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote in
      message news:OOIrou9RIH A.4476@TK2MSFTN GP06.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.FromIm age is appropriate, see
      http://msdn2.microsoft.com/en-us/lib...fromimage.aspx
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m
      >
      <vijay_3491@red iffmail.comwrot e in message
      news:346b0164-c5c0-417f-b8ff-b05b92e522e2@e2 5g2000prg.googl egroups.com...
      >Hi,
      >>
      >How to write a CreateGraphics method for a class similar to
      >form.CreateGra phics()?
      >>
      >Pls help. Thanks in Advance.
      >>
      >>
      >>
      >
      >

      Comment

      • vijay_3491@rediffmail.com

        #4
        Re: CreateGraphics logic

        Hi Nicholas/Ben,

        Thanks for your reply.

        I too used the Graphics.FromIm age() 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.guar d.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.c om
        >
        <vijay_3...@red iffmail.comwrot e in message
        >
        news:346b0164-c5c0-417f-b8ff-b05b92e522e2@e2 5g2000prg.googl egroups.com...
        >
        >
        >
        Hi,
        >
        How to write a CreateGraphics method for a class similar to
        form.CreateGrap hics()?
        >
        Pls help. Thanks in Advance.- Hide quoted text -
        >
        - Show quoted text -

        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: CreateGraphics logic

          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]
          - mvp@spam.guard. caspershouse.co m


          <vijay_3491@red iffmail.comwrot e in message
          news:c0a2af5b-27d5-4394-9101-7eaf4e567872@l6 g2000prm.google groups.com...
          Hi Nicholas/Ben,

          Thanks for your reply.

          I too used the Graphics.FromIm age() 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.guar d.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.c om
          >
          <vijay_3...@red iffmail.comwrot e in message
          >
          news:346b0164-c5c0-417f-b8ff-b05b92e522e2@e2 5g2000prg.googl egroups.com...
          >
          >
          >
          Hi,
          >
          How to write a CreateGraphics method for a class similar to
          form.CreateGrap hics()?
          >
          Pls help. Thanks in Advance.- Hide quoted text -
          >
          - Show quoted text -

          Comment

          Working...