473,779 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1804
Is it a WinForms application? I have done this before:

void MyControl::OnPa int(PaintEventA rgs^ e)
{
HDC dc = static_cast<HDC >(static_cast<v oid*>(e->Graphics->GetHdc()));
try
{
unmanaged_funct ion(dc);
}
finally
{
e->Graphics->ReleaseHdc(sta tic_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(Sys tem::Object * sender,
System::Windows ::Forms::PaintE ventArgs * e)
{
HDC dc=(HDC)e->Graphics->GetHdc().ToPoi nter();
HDC dc1 = static_cast<HDC >(static_cast<v oid*>(e->Graphics->GetHdc()));
}
G.Girish

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

void MyControl::OnPa int(PaintEventA rgs^ e)
{
HDC dc = static_cast<HDC >(static_cast<v oid*>(e->Graphics->GetHdc()));
try
{
unmanaged_funct ion(dc);
}
finally
{
e->Graphics->ReleaseHdc(sta tic_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::OnPain t
(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****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.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(Sys tem::Object * sender,
System::Windows ::Forms::PaintE ventArgs * e)
{
HDC dc=(HDC)e->Graphics->GetHdc().ToPoi nter();
HDC dc1 = static_cast<HDC >(static_cast<v oid*>(e->Graphics->GetHdc()));
}
G.Girish

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

void MyControl::OnPa int(PaintEventA rgs^ e)
{
HDC dc = static_cast<HDC >(static_cast<v oid*>(e->Graphics->GetHdc()));
try
{
unmanaged_funct ion(dc);
}
finally
{
e->Graphics->ReleaseHdc(sta tic_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
3088
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 across "null" string. I know that I will get an "undefined" when I try to retrieve something from the DOM which doesn't exist. I have used null myself to initialize or reset variables. But in which
8
1819
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
1752
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 undefined behaviour in the first place. Does the subexpression (y1=(y+y1)/2) cause UB because /y/ is both modified and used without an intervening sequence point attached to the larger expression or is it ok because the value of the assignment is...
1
3115
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 like this value = myHashtable; then, is the value of "myKey" key is null, then the result is the same, as
5
3407
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 currently <undefined value> as shown in the watch list of the Debugger. Hence the program branches into the if statement although it should skip it obviously. Why? Replacing the if statement above by
49
14529
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 http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
17
3351
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
4861
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 "new Array() vs " question or to the array performance, I dared to move it to a new thread. Gecko takes undefined value strictly as per Book 4, Chapter 3, Song 9 of Books of ECMA :-)
13
36901
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
2026
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 value that type would have with all bits inverted, rather than the mathematical result of inverting all bits in the binary representation. For example, on a machine with 32-bit
0
9636
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
10138
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...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
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
5373
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...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
3
2869
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.