By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Question about IntPtr

P: n/a
I am creating my own MainMenu control similar to VS.Net. (yes I know theirs
some out their).
I have predominatly been a web developer for about 5 years and am playing
with Windows forms. So this should help me learn.

My question is about IntPtr.
Basically what is it, I know its a pointer but what is a pointer.(of course
I know it points to something but how) .
In my MenuControl I needed a graphics object in my OnPaint override.

This works great but I dont know why...
//////////////////////////////////
protected override void OnPaint(PaintEventArgs e) {

this.rmm_Graphics = Graphics.FromHwnd(this.Parent.Handle);

}

I think by understanding what pointers are and how they work I will
understand exactly how I extracted the grapics object from my containing
form.
Does any one know of some newbie windows resopurces that expain this on a
moronic level.
Thanks,
--
Ron Vecchi
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Any intro to computer science text book using C. For example, mine was
"Introduction to Computer Science Using C" by Roger Eggen. Highly
recommended.

The pointer contains a memory address. 32 bit operating systems use 32 bit
ints to address each available memory position. Conceptually, you can start
to get a handle on it by thinking of your street address "pointing" to your
house's physical location. Someone writes your address on a box and the USPS
delivers it to you. That's what a pointer can do.

Of coursed managed code complicates this because your "house" is moved when
the garbage collector runs.

"Ron Vecchi" <rv*****@xilehdvecchi.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am creating my own MainMenu control similar to VS.Net. (yes I know theirs some out their).
I have predominatly been a web developer for about 5 years and am playing
with Windows forms. So this should help me learn.

My question is about IntPtr.
Basically what is it, I know its a pointer but what is a pointer.(of course I know it points to something but how) .
In my MenuControl I needed a graphics object in my OnPaint override.

This works great but I dont know why...
//////////////////////////////////
protected override void OnPaint(PaintEventArgs e) {

this.rmm_Graphics = Graphics.FromHwnd(this.Parent.Handle);

}

I think by understanding what pointers are and how they work I will
understand exactly how I extracted the grapics object from my containing
form.
Does any one know of some newbie windows resopurces that expain this on a
moronic level.
Thanks,
--
Ron Vecchi

Nov 15 '05 #2

P: n/a
ok, I think I understand. using the IntPtr is like saying "at this memory
location"
so in my case am I abstractly saying "give me the graphics object from the
form at this memory location"

Oh, also Im an idiot, I didn't realize that the PaintEventArgs supplied a
graphics object. Although that didn't stop me from still wondering about
the IntPtr. It just accelerated it.
"Mountai Bikn' Guy" <vc@attbi.com> wrote in message
news:gyZEb.598981$HS4.4389660@attbi_s01...
Any intro to computer science text book using C. For example, mine was
"Introduction to Computer Science Using C" by Roger Eggen. Highly
recommended.

The pointer contains a memory address. 32 bit operating systems use 32 bit
ints to address each available memory position. Conceptually, you can start to get a handle on it by thinking of your street address "pointing" to your house's physical location. Someone writes your address on a box and the USPS delivers it to you. That's what a pointer can do.

Of coursed managed code complicates this because your "house" is moved when the garbage collector runs.

"Ron Vecchi" <rv*****@xilehdvecchi.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am creating my own MainMenu control similar to VS.Net. (yes I know

theirs
some out their).
I have predominatly been a web developer for about 5 years and am playing with Windows forms. So this should help me learn.

My question is about IntPtr.
Basically what is it, I know its a pointer but what is a pointer.(of

course
I know it points to something but how) .
In my MenuControl I needed a graphics object in my OnPaint override.

This works great but I dont know why...
//////////////////////////////////
protected override void OnPaint(PaintEventArgs e) {

this.rmm_Graphics = Graphics.FromHwnd(this.Parent.Handle);

}

I think by understanding what pointers are and how they work I will
understand exactly how I extracted the grapics object from my containing
form.
Does any one know of some newbie windows resopurces that expain this on a moronic level.
Thanks,
--
Ron Vecchi


Nov 15 '05 #3

P: n/a
Personally, I would first try to understand pointers outside the context of
dotnet. I wouldn't try to understand IntPtr without understanding a plain
generic pointer. That's just my opinion. BTW, the text book I mentioned is
available for $15 used at
http://www.amazon.com/exec/obidos/tg...books&n=507846

But I'm sure you can find coverage of this topic by searching on Google.

In general, a pointer holds the address of another variable. It's that
simple.

"Ron Vecchi" <rv*****@xilehdvecchi.com> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
ok, I think I understand. using the IntPtr is like saying "at this memory location"
so in my case am I abstractly saying "give me the graphics object from the
form at this memory location"

Oh, also Im an idiot, I didn't realize that the PaintEventArgs supplied a
graphics object. Although that didn't stop me from still wondering about
the IntPtr. It just accelerated it.
"Mountai Bikn' Guy" <vc@attbi.com> wrote in message
news:gyZEb.598981$HS4.4389660@attbi_s01...
Any intro to computer science text book using C. For example, mine was
"Introduction to Computer Science Using C" by Roger Eggen. Highly
recommended.

The pointer contains a memory address. 32 bit operating systems use 32 bit
ints to address each available memory position. Conceptually, you can start
to get a handle on it by thinking of your street address "pointing" to

your
house's physical location. Someone writes your address on a box and the

USPS
delivers it to you. That's what a pointer can do.

Of coursed managed code complicates this because your "house" is moved

when
the garbage collector runs.

"Ron Vecchi" <rv*****@xilehdvecchi.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am creating my own MainMenu control similar to VS.Net. (yes I know

theirs
some out their).
I have predominatly been a web developer for about 5 years and am

playing with Windows forms. So this should help me learn.

My question is about IntPtr.
Basically what is it, I know its a pointer but what is a pointer.(of

course
I know it points to something but how) .
In my MenuControl I needed a graphics object in my OnPaint override.

This works great but I dont know why...
//////////////////////////////////
protected override void OnPaint(PaintEventArgs e) {

this.rmm_Graphics = Graphics.FromHwnd(this.Parent.Handle);

}

I think by understanding what pointers are and how they work I will
understand exactly how I extracted the grapics object from my containing form.
Does any one know of some newbie windows resopurces that expain this
on a moronic level.
Thanks,
--
Ron Vecchi



Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.