473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Question about IntPtr

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
3 1320
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carlos Guzmán Álvarez | last post by:
Hello: I'm trying to execute a function of a unmanaged dll using PInvoke, i have definied the function as: public static extern int isc_dsql_prepare( int status_vector, ref int...
7
by: Kevin | last post by:
Hi al I have an interesting question.... I am working witha Win API this is the Function Public Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As Long, ByVal...
16
by: Duncan Mole | last post by:
Hi, This is probably an easy one but it iy first bit of p/invoke. I am trying to use the following C struct in a call: typedef struct { BYTE SRB_Cmd; BYTE SRB_Status, BYTE ...
8
by: John Clark | last post by:
If I know the "title" of an open window of an application running on the same PC that my application is installed, say for example "Window abc", what's the best method of getting my vb.net to...
9
by: | last post by:
I need to call CreateEvent, but I am getting a runtime error An unhandled exception of type 'System.DllNotFoundException' occurred in aa.exe Additional information: Unable to load DLL...
18
by: Lars Netzel | last post by:
Hello! Thanx to this newgroup I have finally, with the help of you guys, gotten this to work halfway.. but the final action is still not working, clicking the "Button2" thru SendMessage(). ...
2
by: Laurent | last post by:
Hi again, I created a thread some days ago, while I was trying to access a C++ DLL using my C# program. First of all, I want to thanks all the guys who helped me. But I still have a...
11
by: michelqa | last post by:
Hello, I can retrieve column text from a ListView in another process but I cant figure out how to access to structure elements (LVCOLUMN) <code> //Handle variable is a valid ListView handle ...
11
by: michelqa | last post by:
When executing some win32 messages in c# I get unexpected results. The following example is suppose to return the handle of an image in a button control of another application but it return a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.