✅ PaintEventArgs and Graphics
I have the answers to a question yet i dont get how they can write
gr = pea.Graphics;
when i try it i cant and i think its cuz gr is not declared, am i wrong or are the answers wrong? the first snippet is the starting code and at the place of the comment is the longer code (that youd need to write urself)31 Replies
(for context this program should create a red dot on the cursor and make a blue box the height of the cursor that fades to aqua, the amount of times clicked are the amount of shades of blue in the box
Please don't share your code as screenshots, use $code instead
Posting Code Snippets
To post a code snippet type the following:
```cs
// code here
```
Notes:
- Get an example by typing
$codegif
in the chat.
- Change the language by replacing cs
with the language of your choice (for example sql
or cpp
).
- If your code is too long, you can post it to https://paste.mod.gg/ and share the link.gr
is just a variable, and we can't see the declaration of it on the right side but I'd be very concerned about keeping a reference to a graphics object retrieved from an event args outside the event handler for said eventthis is from textbook its an image lmao
well where is your code
mine?
when i try it i cant and i think its...yes
i know gr isnt declared
but its weird the answers dont either, and i dont know how to declare it, cuz Graphics gr = pea.Graphics doesnt work either
I can see this is winforms, but this is a highly unorthodox way of doing things
normally you create classes for each of your forms, inheriting from
Form
, instead of creating a local instance of Form
whats the error on void teken
?doesnt scherm inherit form form?
no,
scherm
is a variable of type Form
i added a ; 🤦
yep
that is it
SECOND TIME THIS WEEK
ty anyways!
I'd highly recommend doing some more practice on variables and variable scopes. These are fundamentals that are the backbone of any code.
variable scopes?
$scopes
thing a
is available in scope A
and scope B
thing b
is available only in scope B
$structure
oh like that
ye i think its cuz the course
is imperative programming
mhm
so we never use 2 things at once if that makes sense
its all line by line
no fucking clue why you'd use an OOP GUI framework to practice imperative programming
thats... just stupid 🙂
uni 🙂
ty anyways tho
Yeah I mean that the course design is stupid
ye exactly
we had if statement after like while and paint and shit
idrk what they are on
Well, if you feel that the thread is over, feel free to $close it
Use the /close command to mark a forum thread as answered