473,387 Members | 1,516 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,387 software developers and data experts.

System.Argument.Exception: hdc

Hi NG,

i encountered a problem during developing some activex control with c#.
I read an article that it is possible to expose windows forms as
activex controls. So I tried it and it worked really great!
Here is the link to the article:
http://www.codeproject.com/cs/miscct...etcontrols.asp

Testing the newly created control with the Testcontainer for ActiveX
Controls showed no problems.

Now I inserted my activex control into Authorware 7.0 everything is
fine the control works, but if I click at the "pause"-Button I get an
exception:

System.ArgumentException: hdc
at
System.Windows.Forms.DibGraphicsBufferManager.Crea teCompatibleDIB(IntPtr
hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
at System.Windows.Forms.DibGraphicsBufferManager.Crea teBuffer(IntPtr
src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
at
System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetBounds)
at System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(IntPtr
target, Rectangle targetBounds)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Unfortunately I dont understand this exception. I dont now what the
"hdc" argument is and why this exception occurs.

Maybe anyone can help or give some suggestions?

Thanks in advance.

kind regards

Andreas Heinecke

Nov 17 '05 #1
3 3400
Hi Andres,

HDC is a handle to a device context. It is a GDI concept - you need an HDC
before you can draw anything.
Now that you receive this error, the host application appears to pass an
invalid HDC to your control when in the "pause" mode.
Judging by the stack trace, you can try to override the Label's OnWndProc
method, watch out for WM_PAINT messages and if the passed PAINTSTRUCT
contains an invalid HDC, just pretend you've handled the message.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Andreas" <he******@blue-cable.de> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi NG,

i encountered a problem during developing some activex control with c#.
I read an article that it is possible to expose windows forms as
activex controls. So I tried it and it worked really great!
Here is the link to the article:
http://www.codeproject.com/cs/miscct...etcontrols.asp

Testing the newly created control with the Testcontainer for ActiveX
Controls showed no problems.

Now I inserted my activex control into Authorware 7.0 everything is
fine the control works, but if I click at the "pause"-Button I get an
exception:

System.ArgumentException: hdc
at
System.Windows.Forms.DibGraphicsBufferManager.Crea teCompatibleDIB(IntPtr
hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
at System.Windows.Forms.DibGraphicsBufferManager.Crea teBuffer(IntPtr
src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
at
System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetBounds)
at System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(IntPtr
target, Rectangle targetBounds)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Unfortunately I dont understand this exception. I dont now what the
"hdc" argument is and why this exception occurs.

Maybe anyone can help or give some suggestions?

Thanks in advance.

kind regards

Andreas Heinecke


Nov 17 '05 #2
Hi Dmytro,

first of all thanks for your answer. But the problem still remains. So
here is what I've done. You said I should try to override OnWndProc but
I cann't find this method I've only found a method namend WndProc, but
I think this method does the same like OnWndProc. So I have overridden
this WndProc-Method an put a try-catch around the invokation of the
base.WndProc(ref m);
The problem is that my catch block never caught the exception, but the
exception is thrown and the program still breaks. I ran out of ideas
how to solve this.

I don't know how to get this exception caught.

Does anyone got some ideas? This problem should'nt be as big as it
seems to be.

Any help is much appreciated!

regards

Andreas Heinecke

Nov 17 '05 #3
Andreas,

Instead of using try...catch, just check the message before calling
base.WndProc and if the message is WM_PAINT and the HDC in the passed
PAINTSTRUCT (refer to MSDN how to extract it from WParam and LParam) is 0 or
null, just don't call the base class but pretend you have processed the
message.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Andreas" <an*****@objectinc.de> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi Dmytro,

first of all thanks for your answer. But the problem still remains. So
here is what I've done. You said I should try to override OnWndProc but
I cann't find this method I've only found a method namend WndProc, but
I think this method does the same like OnWndProc. So I have overridden
this WndProc-Method an put a try-catch around the invokation of the
base.WndProc(ref m);
The problem is that my catch block never caught the exception, but the
exception is thrown and the program still breaks. I ran out of ideas
how to solve this.

I don't know how to get this exception caught.

Does anyone got some ideas? This problem should'nt be as big as it
seems to be.

Any help is much appreciated!

regards

Andreas Heinecke


Nov 17 '05 #4

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

Similar topics

1
by: Can Balioglu | last post by:
Hi, I don't know if it's already known but I found a bug in System.Timers.Timer class. The 'Interval' property accepts a double which specifies the interval between two 'Elapsed' events. The...
0
by: Gemma M | last post by:
Hi, I have a C# program (code fragment below), which runs forever, processing incoming jobs. Part of this program launches a COM object. However, after a while I get : ...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
2
by: loga123 | last post by:
Hi All, I am using Link Button for DELETE on the gridview. When I click on DELETE link, I get the ArgumentOutOfRangeException. But...it deletes the record from table in the database. On...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
6
by: =?Utf-8?B?QkJN?= | last post by:
Hi, I have an app that is crashing due to a System.ArgumentException. At this point it's just a simple app to test some basic object values. The main app is a Windows App that looks like...
0
by: Mike | last post by:
Hi, I have a collection object bound to a data grid, after I remove an item from the collection, the minute I click on the datagrid I get an error saying the specified argument was out of the...
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
30
by: Yorian | last post by:
Hey, Although I've been using classes and object for quite a while now I've never actually programmed proper OO code yet. It ofcourse depends on what you call proper OO code. I have been...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.