473,507 Members | 2,472 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 5369
How the hell do i convert System::IntPtr to HDC?


Call IntPtr::ToPointer() 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.org> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
How the hell do i convert System::IntPtr to HDC?


Call IntPtr::ToPointer() 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.ToPointer();
HDC hdc = GetDC(hwnd);
IntPtr dc = hdc;
HDC hdc_ = (HDC)dc.ToPointer();
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*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
See below:

HWND hwnd = (HWND)textBox1->Handle.ToPointer();
HDC hdc = GetDC(hwnd);
IntPtr dc = hdc;
HDC hdc_ = (HDC)dc.ToPointer();
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
7545
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...
2
1506
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...
10
4612
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...
2
6859
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...
6
1547
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...
6
22432
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
17436
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...
9
6177
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...
0
7114
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...
0
7321
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,...
0
7377
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...
0
7488
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...
0
5623
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,...
1
5045
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...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
412
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...

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.