• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

One more: is there a fundamental difference between saying something like:

Code:
bool done = TRUE;

and

Code:
bool done = true;

And likewise for false and FALSE?

Xcode is giving me the option for both.
 

wolfmat

Confirmed Asshole
Most people (and the Apple framework) use BOOL, and YES and NO, but there is no technical reason for you to do that (until they typedef BOOL differently and you end up with type incoherency without immediately understanding why, that is).

BOOL's YES is a signed char literal 1, so that's pretty cool. Use that!

Edit: bool is C99, by the way.

(Honestly though, pick what you want to, you'll be fine)
 
Hello guys.

I want to build a website with Python to test my skills. I have it running on Heroku with Flask, and want to implement a payment. Because I'm in Mexico I can't use Stripe, Authorize.Net, etc.

The only thing that seems to work is Paypal and the only API I've found for Python is pypi.python.org/pypi/paypal/ Have any of you used it? Do you recommend it? Do you know of any other ways to integrate Python with PayPal?

Thanks!
 
Oh school.....

Makes no mention of exceptions in minor software design project specification. Subsequently marks people down for not modelling exceptions.

Releases sample design. Doesn't model exceptions.
 
I'm working learning C, from Zed Shaw's Learn C The Hard Way series, but I can't get the second extra credit for Exercise 17. I've tried working my way backward as far as learning how to allocate memory for simpler structs to essentially a struct just step down in simplicity, however, I just can't figure out how I would go about solving this problem. Zed himself wants you to figure it out yourself, which would be fine if I hadn't been working on this problem for more than seven hours. Can anyone point me in the right direction?

Link to exercise: http://c.learncodethehardway.org/book/learn-c-the-hard-waych18.html#x23-8800018
 
Can anyone point me in the right direction?

This is a great series, kudos for going through it. This is the basic kernel of how to think about having non fixed size allocations:

Code:
struct Address {
  int id;
  int set;
  int namesz;
  char *name;
  int emailsz;
  char *email;
};

Once you grok what those members mean and how they affect your input/output and allocation strategy, you should have it solved.
 
This is a great series, kudos for going through it. This is the basic kernel of how to think about having non fixed size allocations:

Code:
struct Address {
  int id;
  int set;
  int namesz;
  char *name;
  int emailsz;
  char *email;
};

Once you grok what those members mean and how they affect your input/output and allocation strategy, you should have it solved.

I probably should have specifically said what my issue is, but I've gotten that far. My main issue is trying to figure out how to allocate memory for the strings within Address. Initially I was using

Code:
conn = malloc(sizeof(struct Connection)l
conn->db = malloc( (2*sizeof(int) + 2*size_of_string*sizeof(char)) * size_of_db + 2*sizeof(int));

But, I found that for any case other than create, I wound up with a segmentation fault.

Then I tried to allocate space for each string in a for loop by doing this after I returned from Database_load:

Code:
int i = 0;
for(i = 0; i < size_of_db; i++)
{
    Struct Address *addr = &conn->db->rows[i];
    addr->name = malloc(2*sizeof(int) + 2*size_of_string*sizeof(char));
    addr->email = malloc(2*sizeof(int) + 2*size_of_string*sizeof(char));
}

This got rid of the segfault, but reinitialized all of the fields of my character arrays, deleting whatever I had stored previously. I tried placing it before Database_load, but that just segfaulted.

After that, I just got frustrated and started changing things to the point that I thought it was better to re-type the original and try again. Unfortunately, I made next to no progress this attempt either. I know I'm probably doing something dumb with my mallocs, but coming from Java where I didn't have to worry about memory allocation at all, and C++ where I've not been placed in a situation in which I had to use it, I'm completely lost.
 

itxaka

Defeatist
I will just leave my git here with my crappy attemps at learning a variety of prog skills.

I got a rpg in python (text adventure!) which needs to be finished. A kind of social network in php which is pretty good IMO (It's crap, Im just proud of it) and something else in there.

Feel free to fork me anytime, collaborations welcome.

https://github.com/Itxaka
 

hateradio

The Most Dangerous Yes Man
^ I'll just say a few things about your social network code.

  • You're mixing a lot of HTML with your PHP. This isn't necessarily bad, but you should try to create templates to keep the presentation away from the script/program. You can try a template engine like Twig or Smarty. Some people don't like them because they might slow down the application due to their nature of replacing {{variables}} with PHP. An alternative is to create raw PHP templates.
    • Also, pages like about.php should be plain HTML. You don't need to wrap it up around PHP.
  • You're using strip slashes by default, but you should investigate first if slashes are being added.
  • In the future you should try out PDO to abstract your database a bit. You don't even have to escape inputs if used correctly. <3

Oh, last thing. Since you're posting these on Github, other people will grab your code. So you should always create a conf.template or conf.default.php where configuration variables are set. The users who then pull the code, can rename it to conf.php (or w/e) which would then get required inside of functions.php, in your case.

You'd also add conf.php to the Git ignore list, so that people don't accidentally push their credentials.

ie:
Code:
<?php
// This is conf.template
// Rename it to conf.php and update the variables
$db_host = 'localhost';
$db_database = '';
$db_username = '';
$db_password = '';
$appname = "YASN: Yet Another Social Network";

Code:
<?php
// This is functions.php

require 'conf.php';

// rest of code
 

itxaka

Defeatist
^ I'll just say a few things about your social network code.

  • You're mixing a lot of HTML with your PHP. This isn't necessarily bad, but you should try to create templates to keep the presentation away from the script/program. You can try a template engine like Twig or Smarty. Some people don't like them because they might slow down the application due to their nature of replacing {{variables}} with PHP. An alternative is to create raw PHP templates.
    • Also, pages like about.php should be plain HTML. You don't need to wrap it up around PHP.
  • You're using strip slashes by default, but you should investigate first if slashes are being added.
  • In the future you should try out PDO to abstract your database a bit. You don't even have to escape inputs if you use it correctly. And it's much more useful than plain mysql commands. <3

Oh, last thing. Since you're posting these on Github, other people will grab your code. So you should always create a conf.template or conf.default.php where configuration variables are set. The users who then pulls the code, can rename it to conf.php (or w/e) which would then gets required inside of functions.php, in your case.

You'd also add conf.php to the ignore list, so that people don't accidentally push their credentials.

Thank you :D

I was more interested on python but was hearing a lot about php and such so I got a book and kind of build it up in one week, after that I came back to end learning python.

So basically, I just jumped in and jumped out of the ship. Sooo much that I have no idea about, and I think it shows ;) I'll try to come back later to keep learning more about php/html/database abstraction.
 

Ambitious

Member
What's the difference between a closure and partial function application?

A closures captures all variables from outer scopes if they are used within the function, so you can write something like this:

Code:
def inc(x):
  def doInc(y):
    return x+y
  return doInc

incBy10 = inc(10)
incBy10(1) # 11

In Haskell, you could use partial function application:

Code:
let inc x y = x + y
let incBy10 = inc 10

incBy10 1 # 11

In both cases, you just make one of the arguments constant, but there certainly is some difference, probably in other examples?
 

bumpkin

Member
Okay, I feel sheepish... Had a problem, but I just looked at the code again - after sleeping on it - and found the problem.
 
Currently following a C# course, And I think I fucking love programming and didn't even know it. Running into some issues currently though, programming was really working out and I have no problem completing the programming assignments given to me as course work. However part of the course is apparently learning how to read and create UML diagrams, and nothing so far has made me shit bigger bricks. I didn't realize but I have the memory of a goldfish when it comes to drawing stuff, so currently I'm sort of cheating whenever possible by programming everything and then retroactively drawing the UML diagram. How likely am I to be responsible for drawing up UML diagrams in the future if I choose to pursue a career switch to programming. Basically can I just keep cheating or should I bunker down and fucking learn to remember this shit.

Edit: To further clarify, I have no problems reading them (with a reference book handy). I just can't draw them to save my life.
 

FillerB

Member
-Should I learn UML-story-

Learn them.

Whether you'll be forced to make them or not depends on what company you work for, UML is an excellent tool to determine how your program is going to function and how it will be structured. And a good structured program saves so much hassle later on when you need to bugfix or expand.

Yes, it is certainly possible to write good code without making a good design before hand but it is so rare, especially in novice programmers, that you better sit your ass down for a couple of hours and think your design through.

If that doesn't convince you then check out the following.
http://msdn.microsoft.com/en-us/library/ff657795.aspx

Visual Studio allows you to generate code from UML Class diagrams. So make your diagram and the software writes the classes, attributes, constructors/destructors and function declarations for you. How handy is that?

Also interesting, though not necessarily having to do with your question, is DoxyGen.
http://www.stack.nl/~dimitri/doxygen/

It's a documentation generator that makes great documentation in, among others, HTML-form from comment-blocks in your code (you should add these anyway) and is also capable of making simple graphs to show the relation between your functions. Not, as I said essential, but in my experience your teachers like it if you present something that looks professional.
 

wolfmat

Confirmed Asshole
Actually, some shops consider the practice of defaulting for generated code from UML harmful. The reasoning is that it creates a whole lot of boilerplate code, conventions and complexity that is rather hard to maintain down the road. Kills teams, productivity, motivation, overall team IQ, reduces code quality and increases copypasta; lots of problems that are not obvious unless you've run into them.
I use UML to describe systems. Pure design phase, good as a refactoring reference. I've only used it to generate actual code in uni as an exercise.

I'm not gonna bore you with the ol' "think through common practices before applying them to your project" speech because you've probably heard it a couple of times already.

Edit: Oh, sorry, I didn't explicitly say this: UML is basic knowledge. You have to know it. So work through it.
 

Slavik81

Member
My Software Engineering prof. taught us the basics of UML, but explicitly stated that he put little emphasis on it because few people in industry use much UML with rigorous adherence to the official specification. Even shops that do use UML extensively often have their own twist on it.

As far as I can tell, he was right. 90% of UML is useless. If you can model composition and inheritance in a diagram, you've covered almost everything you need to explain a system to someone. Details can be explained verbally (possibly with an ad-hoc addition to the diagram), and filled in by the actual code. That's all I've ever needed.
 

wolfmat

Confirmed Asshole
few people in industry use much UML with rigorous adherence to the official specification.
Yes. But they're gonna grill you if they're in the mood when you apply, regardless of whether they actually use it religiously or not. So you need to talk the lingo, at least, and know the basic concepts. Basically, if you can communicate that you're not gonna sit there for weeks contemplating suicide because the project lead posted some sort of UML diagram on the wiki, you're pretty much okay in the real world.
 

Magni

Member
Question for Tumblr custom theme writer GAF (if there is one), reposting from Stack Overflow:

I am currently writing a custom theme for Tumblr blogs to embed a widget after every post, regardless of their type. This widget requires the post's title, and if there is none, then it takes the blog's title.

According to Tumblr, {Title} refers to the blog title. However, if we have a Text post or a Chat post, {Title} refers to the post title.

Here is my code:

Code:
var title;
if ('{PostType}' === 'text' || '{PostType}' === 'chat') 
    title = '{Title}';
else if ('{PostType}' === 'photo' || '{PostType}' === 'photoset' || '{PostType}' === 'audio' || '{PostType}' === 'video')
    title = '{PlaintextCaption}';
else if ('{PostType}' === 'quote')
    title = '{PlaintextQuote}';
else if ('{PostType}' === 'link')
    title = '{PlaintextName}';
else if ('{PostType}' === 'answer')
    title = '{PlaintextQuestion}';

if (title === '')
    title = '{Title}';

If I have a Photo post with no caption for example, then title will be correctly set to the blog title. But if I have a Text post with no title, then title will be set to [empty string] instead of the blog title.

So my question is: how can I get the blog title when I am inside of a Text or Chat post?

Any takers? :)
 

IceCold

Member
UML can be summed up with his image (Java centric):

h3pAT.png


The only thing it's missing is aggregation relationships.
 

CrankyJay

Banned
Having a problem in C# overwriting a System.Byte[] column in a dataset with another System.Byte[] array...I put in an original value then later on overwrite it, but the column in the DB always shows 0x instead of my real byte data.

Anyone ever run into this? I can overwrite other columns just fine (like dates etc).

edit: NVM, found a bug in our framework =)
 
I probably should have specifically said what my issue is, but I've gotten that far. My main issue is trying to figure out how to allocate memory for the strings within Address.

Code:
struct Address {
    int id;
    int set;
    int namesz;
    char* name;
    int emailsz;
    char* email;
};

struct Database {
    int nrows;
    struct Address* rows;
};

db->nrows = nrows;
db->rows = (struct Address*) malloc( sizeof( Address ) * nrows );

for ( int i = 0; i < nrows; i++ )
{
    // fill in db->rows[i]
   db->rows[i].name = (char*) malloc( db->rows[i].namesz * sizeof( char ) );
   // etc.
}
 

(._.)

Banned
Hey I'm working on a bubble shooter with two friends and need some help. We have a hexagon grid but are having some problems in programming the collision and snapping the bubbles to the grid when they shoot. How would you guys go about programing this? Could you explain some concepts or where to start o making this? We are working in Flash using actionscript.
 

wolfmat

Confirmed Asshole
So it's 2D, right?

I'm gonna tell you concepts that'll help you figure it out yourself.

Collision:
You want to be able to tell whether a point is in a circle. I propose checking whether the distance from the point to the center of the circle is smaller than the radius of the circle.
You want to know how deep inside the point is once you know it's colliding. You already computed the distance to check whether it's inside the circle. So subtract the distance from the radius of the circle.
You want to have a vector from the center of the circle to the point. Said vector is the difference between the location vector of the center and the location vector of the point.

Hexagon grid bubble snap:
The center vector of a regular hexagon is the averaged sum per component of its vertices.
A bubble's center should therefore be at that vector for the bubble to be centered over a hexagon.
A bubble should snap to the hexagon with the smallest distance from hexagon center to bubble center.
If the hexagon center isn't trivially obtainable (probably is though), you might want to store it so that you don't have to compute it every frame.
 
I'm in the process of learning Python to use in personal projects. Since the beginning of the month, I've been going through Udacity CS101 and the Google Python class. Eventually I want to create GUI apps and maybe 2D games.

A few months ago I got myself the book "Quick Python" for reference, and have been scouring places like reddit's r/learnprogramming and r/python to get up to speed as quickly as I can. My plan is to take another class at Udacity class before diving deep into the GUI stuff.

For the Python-GAF gurus, does this seem like a reasonable plan? Any books, websites you recommend?
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Codeacademy recently added Python to its languages. Although I can't really vouch for its effectiveness since I've never tried their Js courses.
 
Code:
struct Address {
    int id;
    int set;
    int namesz;
    char* name;
    int emailsz;
    char* email;
};

struct Database {
    int nrows;
    struct Address* rows;
};

db->nrows = nrows;
db->rows = (struct Address*) malloc( sizeof( Address ) * nrows );

for ( int i = 0; i < nrows; i++ )
{
    // fill in db->rows[i]
   db->rows[i].name = (char*) malloc( db->rows[i].namesz * sizeof( char ) );
   // etc.
}

Strangely I'm still getting seg faults at the beginning of Database_set where it tries to access the set data member of the Address struct.This is my latest version of the program: http://codepad.org/7LzRzUri .

Oh, and I tried to malloc the strings in multiple places including right after the database was malloc'd, after the database was loaded, and what's in the above file is my last attempt where I tried to malloc when I initialize the values of the database.
 

roddur

Member
i know this thread is about c/c++ but i've a question about .net.

i want to set diff. font color to to diff. items in a combobox when the program loads. any idea how to do that. i'm using framework 1.1
 

ampere

Member
I didn't know we had a thread for this, cool!

I graduated from college in May with an Electrical Engineering degree and a little bit of programming experience (one class on C, two or three with Matlab, one with some assembly) and I'm now seeing a wealth of job opportunities in software engineering. I'm having trouble finding a job so I have started working on learning Python to get back into things. Any more experienced people here think it's a good place to start?
 

Chris R

Member
i know this thread is about c/c++ but i've a question about .net.

i want to set diff. font color to to diff. items in a combobox when the program loads. any idea how to do that. i'm using framework 1.1

This isn't just about C/C++.

As for your question, you need to look into the DrawItem event that the ComboBox will fire (as well as setting the DrawMode of the ComboBox to OwnerDrawVariable or OwnerDrawFixed).

Code:
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
	e.DrawBackground();
	string itemText = ((ComboBox)sender).Items[e.Index].ToString();
	Random r = new Random();
	Brush b = new SolidBrush(Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)));
	e.Graphics.DrawString(itemText, ((Control)sender).Font, b, e.Bounds.X, e.Bounds.Y);
}

And any reason in particular you are using 1.1?
 

Osiris

I permanently banned my 6 year old daughter from using the PS4 for mistakenly sending grief reports as it's too hard to watch or talk to her
i know this thread is about c/c++ but i've a question about .net.

i want to set diff. font color to to diff. items in a combobox when the program loads. any idea how to do that. i'm using framework 1.1

Edit: ^ Ewwwwww rhfb, single char variable names, <Vader>NoooOoooOooOooo</Vader> :p XD

You need to change the ComboBox.OwnerDraw property from Normal to DrawModeVariable, add an event handler for the ComboBox.DrawItem event, and add your code to populate this ComboBox via the DrawString method, DrawString accepts a Brush as one of the parameters which you can then use to individually change the texts ForeColor.

See:
http://blogs.cametoofar.com/post/Change-ComboBox-ForeColor-and-BackColor-e28093-C.aspx
 

roddur

Member
This isn't just about C/C++.

As for your question, you need to look into the DrawItem event that the ComboBox will fire (as well as setting the DrawMode of the ComboBox to OwnerDrawVariable or OwnerDrawFixed).

Code:
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
	e.DrawBackground();
	string itemText = ((ComboBox)sender).Items[e.Index].ToString();
	Random r = new Random();
	Brush b = new SolidBrush(Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)));
	e.Graphics.DrawString(itemText, ((Control)sender).Font, b, e.Bounds.X, e.Bounds.Y);
}

And any reason in particular you are using 1.1?

thanx a lot, DrawItem was the keyword i needed to know :). i figured it out before i saw ur code. but thanx again for ur help.

my company is not very keen to upgrade as they r not a s/w company. they used to use win 98, i asked the boss to upgrade to at least to xp. he told me he saved a lot of money by not listening to me (later they upgraded). from then i dont recommend anything as i try to work around what i've. i'm doing ok


thanx
 

Chris R

Member
thanx a lot, DrawItem was the keyword i needed to know :). i figured it out before i saw ur code. but thanx again for ur help.

my company is not very keen to upgrade as they r not a s/w company. they used to use win 98, i asked the boss to upgrade to at least to xp. he told me he saved a lot of money by not listening to me (later they upgraded). from then i dont recommend anything as i try to work around what i've. i'm doing ok

Good to know! Ask away if you need any more help, we all try to help out when we can if we know what the answer will be.

I guess I need to be thankful that at my office everyone is on Windows 7 and at least .Net 3.5. I'm slowly trying to get everyone up to 4.0+ but for now 3.5 will be just fine!

Edit: ^ Ewwwwww rhfb, single char variable names, <Vader>NoooOoooOooOooo</Vader> :p XD

Excuse my poor code, just threw something together in 10 seconds to make sure it worked :p
 

mantidor

Member
Guys I have one question, I'm implement payment in this project I'm working on but the thing is I know nothing about where to start, the internet hasn't been very good in giving me answers, has anyone had experience implementing credit card or paypal payment functionality?

Oh I forgot, I`m working with .net C# MVC 3

EDIT: ok I actually found a nice introduction article here, but of course, any tips or recommendations are very welcomed.
 

Tantalus

Neo Member
Hey guys, quick question.

I'm working in C++ right now, and have been trying to wrap my mind around forward declarations and all things "#include" related in general. When should I be using a forward declaration that isn't to prevent a circular dependency?

I know that if Class A requires Class B and Class B requires class A that I can use a forward declaration, but is there any other use for them?

Also, general #include tips? I find myself getting lost in which headers are depending on other headers, files from the library I'm using (SFML) being included all over the place... I feel like I'm missing something really simple that makes this easier. Right now everything is so disorganised, it's anarchy with all these #includes :(
 

Lathentar

Looking for Pants
Use forward declarations whenever you can in header files in place of include files if possible. In addition to preventing circular dependencies it can significantly improve compile time as your projects get larger.

For tips on keeping things more straightforward you should not rely on things in other header files. Always include each header that you need. If you're thinking that you're including too many files you probably need to reconsider the structure of your code and try to reduce dependencies.
 

Bollocks

Member
huh? Just include the files you need, doesn't matter if file A depends on file B and both include file C, there's no redundancy, the compiler takes care of that.
 

Tantalus

Neo Member
Thanks to both you guys for your answers! That's helped to clarify things. I'm enjoying using C++ a lot; I've been working on a small 2D game engine using SFML to handle all of the media stuff and it's been a blast so far. Maybe I'll share the source in this thread if it ever gets anywhere near completed.
 

_Isaac

Member
Do any of you men and women have any experience with test-driven development? I've read about it, and it sounds kinda nice.
 

The Technomancer

card-carrying scientician
Thanks to both you guys for your answers! That's helped to clarify things. I'm enjoying using C++ a lot; I've been working on a small 2D game engine using SFML to handle all of the media stuff and it's been a blast so far. Maybe I'll share the source in this thread if it ever gets anywhere near completed.

I like SFML but I was getting bizarre performance differences between window resolutions that I traced back to SFML, and cursory research revealed it was an issue the developer was working on in the next version, and I got distracted and the project got shelved...I should revisit that.
 

usea

Member
Do any of you men and women have any experience with test-driven development? I've read about it, and it sounds kinda nice.
I have done plenty of unit testing, but never test-driven. It is a huge paradigm shift to use tests to lead the development/design process and we couldn't get the people at work to give it a real shot.
 

Kalnos

Banned
I like SFML but I was getting bizarre performance differences between window resolutions that I traced back to SFML, and cursory research revealed it was an issue the developer was working on in the next version, and I got distracted and the project got shelved...I should revisit that.

Was it on SFML 1.6 or 2.0? The latter is still a RC build and there are definitely still issues.
 

Slavik81

Member
Do any of you men and women have any experience with test-driven development? I've read about it, and it sounds kinda nice.
That's been something we've been pushing at work for a few years. I've done a fair amount of it. It requires you understand up front how to design interfaces, and it very difficult unless you have a clear concept of what you're building. That said, it's very satisfying, and it delivers great results.

Of course, TDD will not stop you from designing your software wrong. It nudges you sometimes, but there's a lot of aspects of a robust design that it won't bring to your attention.

In short, I really like it when I can use it. For what I do, I'd TDD most things.
 

Anustart

Member
Anyone proficient with C# and xna?

I've got a Windows Form that i've completed, and also an animation I've done in a seperate xna solution. What i'd like to do is be able to launch this xna 'game' from the winform. Anyone know how to accomplish this?

As of right now they are seperate solutions, not connected in anyway.
 

Osiris

I permanently banned my 6 year old daughter from using the PS4 for mistakenly sending grief reports as it's too hard to watch or talk to her
There's a few convoluted solutions out there for running the XNA's game.Run() on a second thread launched from a WinForm, however personally I'd stick to a simpler method, keep the solutions seperate and use Process.Start from the Systems.Diagnostics namespace to launch the games .exe from the form.
 

Lkr

Member
i started my object oriented class, and holy shit am i fucked. i need to write a program using structs that prints out a lot of data using functions. only problem is i forgot most of this stuff. part of my problem is probably the teacher, who is leaving out basic details in the assignment pdf such as whether we are reading in information from a file or making it all up
 

8byte

Banned
Don't know if anyone can help me, but I'm working on a project and I've kind of hit a road block.

I need to do 3 things in a Windows Form, and I just can't get it all to work right.

Here's an image of what I have:

T7gnq.jpg


Basically, I have to accomplish 3 things.

1) The text box in the top right (gray) has to display the coordinates of the mouse (does not have to be relative) to the large white box.

2) On MouseDown (or click?) I need to draw a dot on the big white panel (DrawingPane).

3) The coordinate of that dot needs to be added to the list box.

I can't get anything to work, lol. Any help would be greatly appreciated :)
 

8byte

Banned
What specifically is not working? Could you post some small samples of what you have so far?

Sure. I actually just got quite a bit of it working, the only thing that I can't seem to get to function correctly at the moment is my "Clear" button. I need it to Clear my list box (Coordinate List) as well as the big white pane to the left (which clears fine).

Here's the code I have so far:

Code:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Point firstpoint;

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            CoordinatePane.Clear();
            CoordinateList.Clear();
            
        }



        private void CoordinatePane_MouseDown(object sender, MouseEventArgs e)
        {
            CoordinatePane.DrawPoint(e.Location);
            CoordinateList.Items.Add(e.Location);
        }


        private void CoordinatePane_MouseMove(object sender, MouseEventArgs e)
        {
            CoordinateDisplay.Text = e.Location.ToString();
        }
    }
}

CoordinateList.Clear(); is giving me an error. Is there a different way to clear the ListBox?
 
Top Bottom