473,569 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System::IntPtr to HDC

How the hell do i convert System::IntPtr to HDC?

manuel
Nov 17 '05 #1
4 5379
How the hell do i convert System::IntPtr to HDC?


Call IntPtr::ToPoint er() and cast the result to HDC.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
I think that i have a compilation problem by mixing old code with new
directives for .net. (HDC)(int) returns an undifined value.
Any guess or suggestion to trace down the problem and find a possible
workaround?

manuel

"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:Ot******** ******@TK2MSFTN GP12.phx.gbl...
How the hell do i convert System::IntPtr to HDC?


Call IntPtr::ToPoint er() and cast the result to HDC.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #3
See below:

HWND hwnd = (HWND)textBox1->Handle.ToPoint er();
HDC hdc = GetDC(hwnd);
IntPtr dc = hdc;
HDC hdc_ = (HDC)dc.ToPoint er();
ReleaseDC(hwnd, hdc_);

XXXPtr value types have a "ToPointer( )" method, which give you a
"void*". You can convert void* to HWND, or HDC, which are actually
void*.

Ismail

Nov 17 '05 #4
It does not work.
Casting to HDC gives me an undifined value.
In this project i had some other weird problems like a stack overflow when a
specific constructor was invoked. I'm almost sure it is a problem with the
default directives for the .net compliance.

manuel
"ismailp" <pa*******@gmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
See below:

HWND hwnd = (HWND)textBox1->Handle.ToPoint er();
HDC hdc = GetDC(hwnd);
IntPtr dc = hdc;
HDC hdc_ = (HDC)dc.ToPoint er();
ReleaseDC(hwnd, hdc_);

XXXPtr value types have a "ToPointer( )" method, which give you a
"void*". You can convert void* to HWND, or HDC, which are actually
void*.

Ismail

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7554
by: Daisy | last post by:
Having a weird problem... Just moving some code into new classes & methods. Originally, I created a new instance of "Game" (my form), and it created a new DX Device using: _device = new Device(0, DeviceType.Hardware, _form, CreateFlags.SoftwareVertexProcessing, _presParams);
2
1512
by: ScOe | last post by:
I have directx namespace which contains few class-es (dx wrapper) Direct3d.Device expect System.IntPtr in passed parameters. When using it in main class i pass "this" as parameter .. how do i pass IntPtr from main class to my custom class? i tried with form.Handle but that doesnt work ...
10
4628
by: Tamir Khason | last post by:
I have a pointer to array and I want to apply indexing to this Array so I have function (name it IntPrt Func) to go to certain member I can use (as C++) Func, but in C# I recieve an error "Cannot apply indexing with to an expression of type 'System.IntPtr'". How to get rid of it? TNX --
2
6862
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public static explicit System.IntPtr (long);
6
1552
by: active | last post by:
I downloaded the Win32 Library which saved me MUCH work. Some (All?) of the returned handles are typed int. As I used them I often changed them in my copy of win32 to IntPtr because an argument that used it was typed IntPtr. Now I wonder if a Handle make more sense being an integer or an IntPtr. I believe it's really an index rather...
6
22435
by: Sushi | last post by:
I need to get a pointer of a variable... How can I get it ? for example: Dim a() as CStructure Dim z as System.IntPtr z = ?????? Sushi
24
17448
by: Marcus Kwok | last post by:
Hello, I am working on cleaning up some code that I inherited and was wondering if there is anything wrong with my function. I am fairly proficient in standard C++ but I am pretty new to the .NET managed C++. It seems to work fine, but everyone knows that programs with errors can still appear to "work fine" :) I am working with VS .NET...
9
6179
by: pigeonrandle | last post by:
Hi, I'm trying to convert the following line to c# from VB6 If hrRapiInit >= 0 Then 'SUCCEEDED where hrRapiInit is declared as a Long. In c#, hrRapiInit must be declared as an IntPtr to fit in with the dll function i have imported, but obviously, the line
0
7615
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...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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...
0
7979
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...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
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...
1
2115
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
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.