473,568 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the pen class - Questions

Hello,

I'd like to create a drawing field on a form in which I can draw
(using the Pen class I guess). I've found tutorials on how to use the
GDI+ but I still haven't found out how to actually create a BOX (with
a specified size) in which the user can draw (he shouldn't be able to
draw on the whole form / window!). I will also need to be able to get
information on the drawn pixels in that box (specifically: i need to
draw a rectangular around a letter the user draws and copy that letter
into a smaller box.. comprimized to 10x10 pixels). Can anyone help me
to get on the right track doing that? Or maybe does someone have a
link to a suitable tutorial or even sample files?

i'd be really really thankful for any help!
greetings,

Tobias F.
Nov 15 '05 #1
3 1823
Tobias,

First, you should create a separate control for this. This will allow
you to handle the user not being able to draw outside of the control. Then
you would add your control onto the form.

To create a Box, you would use the DrawRectangle method on the Graphics
object. You would have to override the OnPaint method of your control and
then draw the rectangle if appropriate. The OnPaint method is like a state
machine. When the state of your control changes, you change the state
information stored in the object and then call Invalidate. This will
trigger a repaint. Once you have that, your OnPaint method should paint the
control according to the current state of the control.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Tobias Froehlich" <re*******@gmx. net> wrote in message
news:cl******** *************** *********@4ax.c om...
Hello,

I'd like to create a drawing field on a form in which I can draw
(using the Pen class I guess). I've found tutorials on how to use the
GDI+ but I still haven't found out how to actually create a BOX (with
a specified size) in which the user can draw (he shouldn't be able to
draw on the whole form / window!). I will also need to be able to get
information on the drawn pixels in that box (specifically: i need to
draw a rectangular around a letter the user draws and copy that letter
into a smaller box.. comprimized to 10x10 pixels). Can anyone help me
to get on the right track doing that? Or maybe does someone have a
link to a suitable tutorial or even sample files?

i'd be really really thankful for any help!
greetings,

Tobias F.

Nov 15 '05 #2
Thanks for your help.. but actually I still have questions :)

I'm a C# beginner.. how do I create a control in VS.NET? And with the
box i just meant a field for the user to draw in.. is that what you
described?

Nov 15 '05 #3
Tobias,

You would have to derive a class from the Control class in the
System.Windows. Forms namespace. Check out the section of the .NET framework
documentation titled "Developing Windows Forms Controls", located at (watch
for line wrap):

http://msdn.microsoft.com/library/de...mscontrols.asp
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Tobias Froehlich" <re*******@gmx. net> wrote in message
news:jh******** *************** *********@4ax.c om...
Thanks for your help.. but actually I still have questions :)

I'm a C# beginner.. how do I create a control in VS.NET? And with the
box i just meant a field for the user to draw in.. is that what you
described?

Nov 15 '05 #4

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

Similar topics

16
3506
by: Merlin | last post by:
Hi Been reading the GOF book and started to make the distinction between Class and Interface inheritance. One question though: Do pure abstract classes have representations? (data members?) What about abstract classes? Should abstract classes have a destructor and or constructor? What about pure abstract classes?
14
2338
by: Tony Johansson | last post by:
Hello Experts! Assume I have a class called SphereClass as the base class and a class called BallClass that is derived from the SphereClass. The copy constructor initialize the left hand object in this case object b2 below. It also initialize subobject from class SphereClass. The BallClass copy constructor looks like this....
121
9969
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather...
2
1462
by: Niklas Norrthon | last post by:
I want to share a technique I recently have found to be useful to get around some obstacles that data protection can raise. Consider the following class: // foo.h #ifndef H_FOO #define H_FOO class Foo
1
831
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead of time for any help or feedback. Cheers, Peter
0
2197
by: tccode97 | last post by:
To whom it may concern, I am developing a socket application in VC++ that uses asynchronous connnection. After doing search on google, I found the following link http://msdn2.microsoft.com/en-us/library/system.net.sockets.udpclient.beginreceive.aspx First of all, thanks for microsoft team for this post.
3
1835
by: lars.uffmann | last post by:
Hi everyone! I am debugging a big piece of code on the search for memory leaks, using g++ under suse 9.3. Since I'm trying to eliminate ALL memory leaks, I now stumbled upon a class foo that is not ever instantiated (thus no constructor or destructor ever called), but instead, all of its member variables are defined as static in the...
1
8557
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but it doesn't seem to work at all. Below is my ASP.NET page, and further below, my VB.NET method that I am trying to call: <div id="admin-faq"...
1
4075
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score...
6
3208
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, can someone please let me know how I can read xml elements using object oriented program. I created a class to use the get and set properties however I dont know how I can pass the values from xml file to the class and use the values in my form. Thanks -- Nejadian
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.