|
granthnk wrote:
1.there a way to compile the Dll's with the executable so that the program is self-contained?
Yes. Use the AxImporter.GenerateFromFile class (where the file is the Flash ActiveX object). Before you can use AxImporter, you need to import the System.Design.dll namespace.
granthnk wrote:
2. : I am compiling on 2000 pro. Will users on other platforms be able to run this?
Not Win95.
Provided you don't use ADO.NET, ASP.NET, users will be able to run your app with the sole .NET run-time installed. ( In addition, be sure to compile against .NET 1.0, otherwise you have to provide a .config file. )
granthnk wrote:
3. is .NET framework required on other machines in order for the app to run?
Yes, the .NET run-time is required. That's a major show stopper for small apps these days.
|
|
|
|
|
How do you get a control reference from it's handle under .Net?
|
|
|
|
|
From MSDN:
Control.FromHandle Method
See Also
Control Class | Control Members | System.Windows.Forms Namespace | Handle | Parent
.NET Framework Security:
UIPermission for all windows to call this method. Associated enumeration: UIPermissionWindow.AllWindows
Returns the control that is currently associated with the specified handle.
public static Control FromHandle(
IntPtr handle
);
Parameters
handle
The window handle (HWND) to search for.
Return Value
A Control that represents the control associated with the specified handle; returns a null reference (Nothing in Visual Basic) if no control with the specified handle is found.
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Hi folks,
I'm just beginning with C#. I am doing an RPN calculator and it seems to work pretty well.
However I have a problem. I have a class that manages the stack, and a class that manages the displaying of numbers on the display, that actually is a TextBox, tbDisplay.
Since the TextBox in on the main form, the one that gets created automatically when you use the form designer, I have to access it from the display class. How do I do it?
What I did is declaring the TextBox public static. After from the display class I access it using Form1.tbDisplay. It works!
The problem is that everytime I add a control, or do "something", something being I don't know exactly what, the TextBox disappears. It seems that VisualStudio removes the lines of code. What VS does is not removing the declarations of the control, public static etc..., but it removes the lines in the initialization. It removes the line from the this.Controls.AddRange.
It also removes these lines:
Calc.tbDisplay = new System.Windows.Forms.TextBox();
// tbDisplay
//
Calc.tbDisplay.Location = new System.Drawing.Point(136, 56);
Calc.tbDisplay.Name = "tbDisplay";
Calc.tbDisplay.Size = new System.Drawing.Size(208, 20);
Calc.tbDisplay.TabIndex = 18;
Calc.tbDisplay.Text = "0";
Calc.tbDisplay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
This happens all the times. It's the tenth time I add the lines back by hand, it's a mess.
What's the problem here? I suspect that my approach of declaring it static.. etc it's not the right solution? How should it work???
How do I, from inside Z class, control an istance of a X class that is declared into Y class?
Thanks for any help.
I hope to finish my calc so maybe I can post my first arcticle on CodeProject. It uses a nice stack class. And it behaves exactly like the calculator I am emulating, the HP 12C.
Edward
|
|
|
|
|
I don't think declaring a control as static is valid!
The code you show is generated by (and deleted by) the form designer. If it doesn't like your declaration it will probably strip the control on code generation.
i.e. the code that the form designer creates.
Calc.tbDisplay = new System.Windows.Forms.TextBox();<br />
<br />
Calc.tbDisplay.Location = new System.Drawing.Point(136, 56);<br />
Calc.tbDisplay.Name = "tbDisplay";<br />
Calc.tbDisplay.Size = new System.Drawing.Size(208, 20);<br />
Calc.tbDisplay.TabIndex = 18;<br />
Calc.tbDisplay.Text = "0";<br />
Calc.tbDisplay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
|
|
|
|
Thanks for the hint, I was pretty sure that there was something wron, even if it actually worked!
But it seems that now I have a problem that I don't know how to solve.
I have a class Display that I use to perform all the stuff related to the display, that actually is my control box. For example I need this class because it keeps track whether when the user pushed a button he's beginning a new number or adding a digit to the number currently onscreen. Things like that.
The problem is that I don't know how to access the control that is on the form. You know they are in two different classes. Of course I cannot inside class Display write tbDisplay.Text = "whatever"; nor Form1.tbDisplay; etc.
How this is supposed to work?
Thanky you a lot!
Edward
|
|
|
|
|
Hi everybody!
Whenever I try to instanciate an XmlSerializer I get an FileNotFoundException thrown at me (from mscorlib.dll) with the following information:
File or assembly name hflbt5w2.dll, or one of its dependencies, was not found.
Funny thing is, that each time I run the code the dll-name is a different one!
Can anybody please advise?
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
|
Hi Leppie,
thanks for your reply. I'm trying just a very simple class. Something like this:
class Test {
// ctors omitted for brevity
public Size _Size;
public Point _Point;
public string _String;
}
I instanciate and set some values, after that I try to serialize the class, but it simply won't work...
thanks again!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
|
Hi Leppie,
not, the class is not public, in fact it is a (private) nested class. The serialization stuff is in it's parent class, which is public. And yes, the class has a default ctor.
While I'm writing this I'm trying to write another simple sample. I'll post it here if it doesn't work but let you know otherwise.
Thanks again!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
Hi Leppie,
so, here we go... As mentioned in my last post, the class which I want to serialize is nested and private in it's containing class. Thats the problem. As soon as it's been made public, no problem there. It just ruined my design...
a lot of wind for a small boat...
Anyway thanks for your help!!!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
leppie wrote:
Sounds like those files ASP.NET makes.
The XML serializer works by creating an Assembly at runtime that handles the serialization of the types to/from XML. Because it generates an Assembly, you wind up with the weird naming scheme.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
|
I need to stop/preview the messages that child controls generate. Does anybody know if this can be achieved through subclassing?
For example, I have a textbox on a form, but I don't want the user to be able to set focus to it (So they can't edit and the caret doesn't appear). I want to absorb the msgs if possible or stop controls reacting to them.
Is this possible? or am I
|
|
|
|
|
OOOooh that horrid VB word again
Anyways the answer is yes. Just override the PreProcessMessage() in a derived (subclassed in VB) control. EG:
public class MyTextBox : TextBox {
public override bool PreProcessMessage(ref Message msg)
{
}
}
From MSDN:
All messages are sent to the WndProc method after getting filtered through the PreProcessMessage method.
The WndProc method corresponds to exactly to the Windows WindowProc function. For more information about processing Windows messages, see the WindowProc function documentation in the Windows Platform SDK reference located in the MSDN Library.
Notes to Inheritors: Inheriting controls should call the base class's WndProc method to process any messages that they don't handle.
Cheers
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Why is everyone taking the mick out of VB! I have 10 years experience of 'Application' development in VB. I'd love to move over to c# but unless I've got someone to hold my hand it's never gonna happen and I can't afford classes
I'm perfectly prepared to try and code under c# in a project with help, but there will be a lot of silly questions and I need to get my work done
|
|
|
|
|
LeeDaviesVBSource wrote:
lot of silly questions and I need to get my work done
Ask away! We may not always know what's going on...but somebody will (read: James T. Johnson).
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
I have this code snipet in my c# classs that generates a string containg xml data.
//build xml data
StringWriter xmlStringWriter = null;
XmlTextWriter xmlWriter = null;
string xmlString = "";
StringBuilder xmlStringBuilder = new StringBuilder();
try
{
xmlStringWriter = new StringWriter(xmlStringBuilder);
xmlWriter = new XmlTextWriter((xmlStringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(); //start document
//populate xml
However, the generated xml string contains the header as:
Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
|
|
|
|
|
|
Thanks leppie.
I tried this solution. I am however getting the error "Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only".
Regards,
Andy
|
|
|
|
|
|
|
Hi leppie.
Unfortunately, this did not work either. I got two errors this time:
1. No overload for method 'UTF8StringWriter' takes '1' arguments
2. Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only.
Thanks,
Andy
|
|
|
|
|
First of all, there is nothing wrong in getting an UTF-16 encoding (aka Unicode) since you are explicitely outputting a string content whose encoding is, by design, stored as Unicode (all string content in .NET is stored as unicode, like Java by the way).
Next to that, you have a System.Xml.TextWriter(string filename, Encoding enc) constructor ready to help you. Why don't you use it ? UTF-8 is the default encoding if you don't provide one. Then simply use your string content through WriteRaw(string) calls.
Just in case you don't want to tweak your current code, you can achieve what you need (again, that's bad use of the classes) by deriving the Xml.XmlTextWriter class and provide this constructor :
public XmlTextWriter_(TextWriter w, Encoding enc) {
this = new XmlTextWriter_();
this.textWriter = w;
this.encoding = enc;
this.xmlEncoder = new XmlTextEncoder(w, this.encoding);
this.xmlEncoder.QuoteChar = this.quoteChar;
}
PS : train[^] yourself with these free training courses.
|
|
|
|