473,320 Members | 2,112 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.

HDC undefined value

Hi ,
I am migrating from VC 6.0 to VC 7.0 with ( windows Control Lib
option in vc dot net ) where I want to draw an image using StretchDIBits. I
am not able to get the HDC of the Window.
I tried using get_handel() which gives undefined value.
Any help regarding this will be great.

Thanx in Advance,
G.Girish

Nov 17 '05 #1
3 1771
Is it a WinForms application? I have done this before:

void MyControl::OnPaint(PaintEventArgs^ e)
{
HDC dc = static_cast<HDC>(static_cast<void*>(e->Graphics->GetHdc()));
try
{
unmanaged_function(dc);
}
finally
{
e->Graphics->ReleaseHdc(static_cast<IntPtr>(dc));
}
Panel::OnPaint(e);
}

Tom

Girish wrote:
Hi ,
I am migrating from VC 6.0 to VC 7.0 with ( windows Control Lib
option in vc dot net ) where I want to draw an image using StretchDIBits. I
am not able to get the HDC of the Window.
I tried using get_handel() which gives undefined value.
Any help regarding this will be great.

Thanx in Advance,
G.Girish

Nov 17 '05 #2
Hi Tamas,
Thank you for your reply,
I tried as you said but still I am getting that HDC is undefined.The
Graphics object (e->Graphics) also does not contains any value .Please look
in to my code .

private: System::Void Form1_Paint(System::Object * sender,
System::Windows::Forms::PaintEventArgs * e)
{
HDC dc=(HDC)e->Graphics->GetHdc().ToPointer();
HDC dc1 = static_cast<HDC>(static_cast<void*>(e->Graphics->GetHdc()));
}
G.Girish

"Tamas Demjen" wrote:
Is it a WinForms application? I have done this before:

void MyControl::OnPaint(PaintEventArgs^ e)
{
HDC dc = static_cast<HDC>(static_cast<void*>(e->Graphics->GetHdc()));
try
{
unmanaged_function(dc);
}
finally
{
e->Graphics->ReleaseHdc(static_cast<IntPtr>(dc));
}
Panel::OnPaint(e);
}

Tom

Girish wrote:
Hi ,
I am migrating from VC 6.0 to VC 7.0 with ( windows Control Lib
option in vc dot net ) where I want to draw an image using StretchDIBits. I
am not able to get the HDC of the Window.
I tried using get_handel() which gives undefined value.
Any help regarding this will be great.

Thanx in Advance,
G.Girish

Nov 17 '05 #3
The only differences I see is that Tamas is overriding Control::OnPaint
(which is recommended if you inherrit) while Girish is handling the Form's
paint event.

I have written a similar code in C++CLI and it works - for controls and
forms; for events and overrides.

Can you send a callstack when your Form1_Paint method is called?

Marcus

"Girish" <Gi****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
Hi Tamas,
Thank you for your reply,
I tried as you said but still I am getting that HDC is undefined.The
Graphics object (e->Graphics) also does not contains any value .Please
look
in to my code .

private: System::Void Form1_Paint(System::Object * sender,
System::Windows::Forms::PaintEventArgs * e)
{
HDC dc=(HDC)e->Graphics->GetHdc().ToPointer();
HDC dc1 = static_cast<HDC>(static_cast<void*>(e->Graphics->GetHdc()));
}
G.Girish

"Tamas Demjen" wrote:
Is it a WinForms application? I have done this before:

void MyControl::OnPaint(PaintEventArgs^ e)
{
HDC dc = static_cast<HDC>(static_cast<void*>(e->Graphics->GetHdc()));
try
{
unmanaged_function(dc);
}
finally
{
e->Graphics->ReleaseHdc(static_cast<IntPtr>(dc));
}
Panel::OnPaint(e);
}

Tom

Girish wrote:
> Hi ,
> I am migrating from VC 6.0 to VC 7.0 with ( windows Control
> Lib
> option in vc dot net ) where I want to draw an image using
> StretchDIBits. I
> am not able to get the HDC of the Window.
> I tried using get_handel() which gives undefined value.
> Any help regarding this will be great.
>
> Thanx in Advance,
> G.Girish
>

Nov 17 '05 #4

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

Similar topics

13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
8
by: Joona I Palaste | last post by:
We all know that this: void *p; if (p=malloc(1)) { free(p); p; } causes undefined behaviour if malloc() succeeds. But what about this?
14
by: ozbear | last post by:
Someone was asking in another forum how to translate: if (x && (y1=(y+y1)/2)) /* all integers with defined values */ to another language. I am at odds with myself as to whether this causes...
1
by: Pavils Jurjans | last post by:
Hello, I am building custom hashtable class, and thinking about value retrieval issues. The thing is, that sometimes the hashtable value may contain value null. If someone is reading this value...
5
by: Steven Prasil | last post by:
I have a C# program with an if statement similar to if (obj.myvar != Undefined.Value) { ...... } When I test it in the CSharp CLR debugger this debugger does not recoginze that the value is...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
17
by: yb | last post by:
Hi, Looking for clarification of undefined variables vs. error in JavaScript code. e.g. <script> alert( z ); // this will be an error, i.e. an exception </script>
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
13
by: -Lost | last post by:
You can test for an undefined value in two ways: function blah(x) { if (x == undefined) { x = 'default value'; } } That could also have been written: function blah(x)
22
by: blargg | last post by:
Does ~0 yield undefined behavior? C++03 section 5 paragraph 5 seems to suggest so: The description of unary ~ (C++03 section 5.3.1 paragraph 8): But perhaps "one's complement" means the...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.