|
I have multiple projects in a solution and I am trying to create dependencied, but when i was trying to add a project reference i got the following message:
A reference to NDMUI could not be added. An assembly must have a "dll" extension in order to be referenced.
I do not not how to resolve it......may someone please help!
Tryin' my best
|
|
|
|
|
VS.NET doesn't let you reference a .exe. It is possible, but you'll have to use the command line compiler (csc.exe) or a build tool like NAnt[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I figure that to draw my little windows style borders, i need to actualy have a valid handle to the grahics device for the control.
Now, I have this section of code i have included in my component constructor that causes a problem:
Graphics clientDC = this.CreateGraphics(); <br />
IntPtr hdc = clientDC.GetHdc(); <br />
pDC = ThemeAPI.CreateCompatibleDC(hdc);<br />
clientDC.Dispose();
That throws the following error on run time:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.drawing.dll
Additional information: The object is currently in use elsewhere.
Now, i know it's caused by the existence of the ClientDC, but i'm not sure how to go about solving this one.
I need to get the creatgraphics for the component in question, but I guess, as i'm creating three duplicate components at initialisation, it's running three seperate threads at once, and it's not liking the use of the Device Context. If i don't dispose of it, the program runs for a while before crashing.
Should I construct a graphics handle in the parent form?
Cata
|
|
|
|
|
Call clientDC.ReleaseHdc(pDC) when you're done with the HDC , then dispose your Graphics object.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Okey dokey, works now.
I was trying to use P/Invoke DeleteDC(pDC). It clearly wasn't happy with that.
But i've still got nothing drawn on my background. I think i have the object values right, and i've tried a number of values for iState. So i'm not entirely sure why nothing is appearing. Here is the code
<br />
pTHEME = ThemeAPI.OpenThemeData(this.Handle,"Window");<br />
<br />
Graphics clientDC = this.CreateGraphics(); <br />
IntPtr hdc = clientDC.GetHdc(); <br />
pDC = ThemeAPI.CreateCompatibleDC(hdc);<br />
<br />
ThemeAPI.Rect rect = new ThemeAPI.Rect();<br />
rect.left = this.Location.X;<br />
rect.top = this.Location.Y;<br />
rect.right = this.Location.X + this.Size.Width;<br />
rect.bottom = this.Location.Y + this.Size.Height;<br />
<br />
int result;<br />
result = ThemeAPI.DrawThemeBackground(pTHEME,pDC,5,1,ref rect,IntPtr.Zero);<br />
result = ThemeAPI.DrawThemeBackground(pTHEME,pDC,7,1,ref rect,IntPtr.Zero);<br />
result = ThemeAPI.DrawThemeBackground(pTHEME,pDC,8,1,ref rect,IntPtr.Zero);<br />
result = ThemeAPI.DrawThemeBackground(pTHEME,pDC,9,1,ref rect,IntPtr.Zero);<br />
<br />
clientDC.ReleaseHdc(pDC);<br />
clientDC.Dispose();
What do you make of it?
|
|
|
|
|
Deleting the HDC that way is fine if you don't use Graphics.GetHdc to get it. The reason is that the unmanaged pointer that the Graphics references needs to be freed, otherwise the Graphics object will complain about having an invalid handle when the Graphics.Dispose method tried to delete it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You get that error when the application is not loaded into an STA (single-threaded apartment). Make sure you use the STAThreadAttribute on your entry point and that any controls in your library used in an application are created in the main thread.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Too late m8!
Got to that one on my own
|
|
|
|
|
there are lots of examples on how to set up child form from the MainMDI but i cant find anything on how to open a form from another child form and setting the MDIParent so as it becomes child form, where am i going wrong???
|
|
|
|
|
So long as you're not talking about an MDI child form within another MDI child form (which isn't supported in the .NET FCL), you can simply get the parent MDI form of the first child and add the new child as an MDI child of the parent:
MDIChildForm child = new MDIChildForm();
if (MdiParent != null)
MdiParent.AddOwnedForm(child);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
fantastic response and worked first time.
|
|
|
|
|
How can i make a panel that can receive a focus
I used the GotFocus and LostFocus events to turn the panel blue when focussed. But how can i set the CanReceiveFocus Property true so that you can use your keyboard (Tab and arrows) to give that control the focus. (That panel also conatains a picturebox and a label).
Thanks
Jonathan Slenders
|
|
|
|
|
Extend the control and in your constructor call SetStyle(ControlStyles.Selectable, true) .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hello,
May I know how I can create a 2 dimension textbox array? I know how to create a 1 dimension textbox array, but I am having trouble trying the 2D. Thank you!!
|
|
|
|
|
It depends what kind of multi-dimensional array. There are multi-dimensional arrays and jagged arrays. The former is declared like this:
TextBox[,] boxes = new TextBox[,] {{textBox1, textBox1},
{textBox1, textBox2}, {textBox2, textBox2}}; These types of arrays have fixed dimensions and sizes.
Jaggaed arrays' elements are arrays themselves, like this:
TextBox[][] boxes = new TextBox[] {
new TextBox[] {textBox1, textBox1},
new TextBox[] {textBox1, textBox2},
new TextBox[] {textBox2, textBox2},
new TextBox[] {textBox1},
new TextBox[] {textBox2}}; As you can see, these can have different dimensions and sizes.
You can find more information by reading about Arrays[^] in the Visual C# language documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you
|
|
|
|
|
I've created a component Library, and i've built the P/Invoce commands into it to build a windows style component. However, when i try and run the following lines internaly from the component, or Externaly from the parent window, i get the "DragDrop registration failed."
<br />
pTHEME = ThemeAPI.OpenThemeData(this.Handle,"Window");<br />
<br />
IntPtr pDC = ThemeAPI.CreateCompatibleDC(IntPtr.Zero);<br />
I put a break point after these two lines, and they process ok for each window, producing pointers and executing successfuly. However, the program then skips to the end of the Main method, and throws the error.
Why is it doing this? I've read that it's a problem with Web Deployed Apps in .NET v1.0. But i have V1.1 and it's not a web app.
What can i do to solve it?
Cheers
Cata
Note: I have enabled windows styles as well, so that's not the problem.
|
|
|
|
|
The Catalyst wrote:
IntPtr pDC = ThemeAPI.CreateCompatibleDC(IntPtr.Zero);
I dont know much of themes, but why are you passing a "NULL" pointer? Shouldnt you pass this.Handle instead?
top secret
|
|
|
|
|
I figured my origional problem.
But you do still have a good point. Might explain why it's not drawing anything now.
|
|
|
|
|
Hi
I am planning to start a research on Data Mining techniques for Intrusion Detection. It would be very helpful for me if any one of you cna help me in getting the code for some basic algorithms like Apriori, K-Means hierachical clustering, Decision Tree in C# or C++. Please let me know if any body else is in the same field.
my email id is sreelakshmibobba@hotmail.com
Thanks
srilakshmi
|
|
|
|
|
This book is great, and the code is free to download:
Weka.
It's in Java, but it's easy to migrate it to C# (at least, easier than write ) or to compile it in J#.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
Dear
this is a very important topic and am trying to work on this system for 1 year but i face alot of problem.
the big problem was the Lack of sources
and i depended on C# and SQL 2005 server
i found the same system built in java and oracl
but its very difficult
if you find anything please could you share that with us
thanks brother
|
|
|
|
|
This is the problem/scenario (I hope it makes sense):
I am trying to pass some values from page1.aspx to page2.aspx, NOT with a querystring.
Page1.aspx is code only: no buttons or textboxes. The user will never see page1.aspx.
The values have to be retrieved on page2.aspx, using Request.Form["name"].
So on page1.aspx, I have to ‘submit’ the values to page2.aspx.
There must be some simple way to submit these values from page1.aspx to page2.aspx using C#, but I just don’t see it.
Any help is appreciated!
Thanks.
|
|
|
|
|
You mean you want to submit a form without clicking a button? You can call the __doPostBack client-side function (Javascript) or just use theForm.submit() , although the former is preferred. This is what button clicks, index changes, etc. do on the client-side to post changes back to the server.
Also, if you have questions specific to ASP.NET, you should ask in the ASP.NET forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|