473,772 Members | 3,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(PaintEv entArgs e) {

this.rmm_Graphi cs = Graphics.FromHw nd(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 1346
Any intro to computer science text book using C. For example, mine was
"Introducti on 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*****@xilehd vecchi.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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(PaintEv entArgs e) {

this.rmm_Graphi cs = Graphics.FromHw nd(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.5989 81$HS4.4389660@ attbi_s01...
Any intro to computer science text book using C. For example, mine was
"Introducti on 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*****@xilehd vecchi.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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(PaintEv entArgs e) {

this.rmm_Graphi cs = Graphics.FromHw nd(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*****@xilehd vecchi.com> wrote in message
news:eS******** ******@TK2MSFTN GP10.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.5989 81$HS4.4389660@ attbi_s01...
Any intro to computer science text book using C. For example, mine was
"Introducti on 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*****@xilehd vecchi.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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(PaintEv entArgs e) {

this.rmm_Graphi cs = Graphics.FromHw nd(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
2521
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 trans_handle, ref int stmt_handle,
7
5535
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 FirstJob As Long, ByVal NoJobs As Long, ByVal Level As Long, pJob As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Lon Which I got from the API viewer that comes with VB 6. I have tried to convert it to the following ...
16
2506
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 SRB_HaId;
8
4090
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 "switch" to that window as if I'd clicked on the taskbar or pressed ALT+TAB? It should be simple, but I've had no luck so far .. Thanks, JC
9
1787
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 (kernel32.lib). Did I declare correctly? Dim hevent As System.UInt32 hevent = CreateEvent(IntPtr.Zero, True, False, "abc")
18
6567
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(). Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
2
1962
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 problem... My C++ DLL has a function which has the following prototype: long FF_Function(void* inInstance, char* inDate, FF_Struct**
11
3953
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 LV_COLUMN ListViewItem = new LV_COLUMN(); IntPtr ListViewItemPointer = IntPtr.Zero;
11
2353
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 negative handle...is anybody know why it return an invalid handle like "-989523277" ?? IntPtr ImageHandle = Win32.SendMessage(Handle,BM_GETIMAGE,IntPtr.Zero,IntPtr.Zero); MessageBox.Show(ImageHandle.ToString());
0
9620
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10104
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.