|
|
Thanks Dennis and Robert,
Will Visual Studio 2003.NET standard edition 'do' for me?
The 2005 beta edition does not have MFC in its templates window if I want to create a new project!
Thanks,
Mike
|
|
|
|
|
McSam wrote:
Will Visual Studio 2003.NET standard edition 'do' for me?
In terms of C/C++? I don't know. I primarily use C# and sometimes VB. Maybe you should ask that question on the Managed C++ board[^] (or the Visual C++ board[^] for that matter).
McSam wrote:
The 2005 beta edition does not have MFC in its templates window if I want to create a new project!
Please, don't get me wrong, but I'm a little bit confused why you insist on creating MFC applications with VS 2005. This product is mostly about .NET and you also haven't explained why you still have to create MFC applications. Maybe you should really give .NET a try and see if it works for you.
Best regards
Dennis
|
|
|
|
|
I am using VC++ V5.0, it is time to upgrade. .NET seems the only way to go? My projects so far do not involve the web or networks.
Regards,
Mike
|
|
|
|
|
McSam wrote:
I am using VC++ V5.0, it is time to upgrade. .NET seems the only way to go? My projects so far do not involve the web or networks.
No offense, but I think you're still missing the point what .NET is about. It has nothing to do with the web or networks in general. It's a technology which is in parts comparable to Java. Please have a look at MSDN .NET Framework Developer Center: Getting Started[^]. To further clarify it: MFC is a legacy technology from the .NET point of view.
Best regards
Dennis
|
|
|
|
|
rockmate wrote:
So I down loaded Visual Studio 2005 beta version to find out a bit about c#. I was surprised that there is no windows.h file.
I agree with Robert. C# is primarily about RAD with the .NET Framework and not about Win32 as long as there is a managed way to do it. There are no header files in C# anyway. I sometimes use the header files if I use P/Invokes and need some defines. Just download the Platform SDK[^] and remember that the Common Language Runtime (CLR)[^] defines its own data types (see Platform Invoke Data Types[^]).
Best regards
Dennis
|
|
|
|
|
Hi
I wish you a Joyful and Happy New Year.
I am new to c# , so I dont know how to do.
ie,
My requirement exactly is :
Now My program reads a schema file( with field names name(string), salary(decimal)).
They are read and the values are inserted to the fields automatically.Like
(john1,john2,john3,..etc. for name)(2000, 2001,2002 , ..etc for salary).They are written into a xml file(say for instance salaryemp.xml).
this is what happens to my program.
Now what I have to do , I should be able to read another xml file( say for instance corporate.xml) which also has this name field with many original datas( like james, george, munna,..etc. ). So my program should read these values and fed(insert) into salary.xml file(only the name field should get altered with the values of corporate.xml). the salary field should remain the same.
pls help me to do that .
Just give me a coding help.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Schema;
namespace testdatagenerator
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtSchema;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txtXml;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Data.DataSet dataSet1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.txtSchema = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.txtXml = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet1 = new System.Data.DataSet();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
this.SuspendLayout();
//
// txtSchema
//
this.txtSchema.Location = new System.Drawing.Point(232, 24);
this.txtSchema.Name = "txtSchema";
this.txtSchema.Size = new System.Drawing.Size(368, 20);
this.txtSchema.TabIndex = 0;
this.txtSchema.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(616, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Browse";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtXml
//
this.txtXml.Location = new System.Drawing.Point(232, 64);
this.txtXml.Name = "txtXml";
this.txtXml.Size = new System.Drawing.Size(368, 20);
this.txtXml.TabIndex = 2;
this.txtXml.Text = "";
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button2.Location = new System.Drawing.Point(616, 64);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 3;
this.button2.Text = "Load";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button3.Location = new System.Drawing.Point(696, 64);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(64, 23);
this.button3.TabIndex = 4;
this.button3.Text = "Save";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet1;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 120);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(776, 320);
this.dataGrid1.TabIndex = 5;
//
// dataSet1
//
this.dataSet1.DataSetName = "NewDataSet";
this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US");
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(32, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(184, 23);
this.label1.TabIndex = 6;
this.label1.Text = "Enter the Xml Schema";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(32, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(192, 23);
this.label2.TabIndex = 7;
this.label2.Text = "Enter the Xml file";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(808, 454);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.txtXml);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtSchema);
this.Name = "Form1";
this.Text = "TestDatagenerator";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "select schema file" ;
fdlg.InitialDirectory = @"c:\CDEV\testdatagenerator" ;
fdlg.Filter = "schema files(*.xsd) |*.xsd| all files(*.*) | *.*";
fdlg.FilterIndex = 2 ;
fdlg.RestoreDirectory = true ;
if(fdlg.ShowDialog() == DialogResult.OK)
{
txtSchema.Text = fdlg.FileName ;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
dataSet1.ReadXmlSchema(txtSchema.Text);
foreach (DataTable dTbl in dataSet1.Tables)
{
for(int j = 0; j <= 200; j++)
{
object[] oValues = new object[dTbl.Columns.Count];
int i = 0 ;
foreach (DataColumn dColmn in dTbl.Columns)
{
switch(dColmn.DataType.ToString())
{
case "System.String":
oValues[i] = (string) "Castle Hampers" + j;
break;
case "System.Int32":
oValues[i] = (int) 100 + j;
break;
case "System.DateTime":
oValues[i] = new DateTime(2004,01,30).AddDays(j * 1);
break;
case "System.Decimal":
oValues[i] = new Decimal(10000900.99) + j;
break;
case "System.Int16":
oValues[i] = (short) 32767 - j;
break;
case "System.Int64":
oValues[i] = (long) 400 - j;
break;
case "System.Double":
oValues[i] = (double) 888888 - j;
break;
case "System.Single":
oValues[i] = (float) 4.5f + j;
break;
}
i = i+1;
}
dTbl.Rows.Add(oValues);
}
}
}
private void button3_Click(object sender, System.EventArgs e)
{
dataSet1.WriteXml(txtXml.Text,XmlWriteMode.WriteSchema );
MessageBox.Show("Saved");
}
}
}
santhosh
|
|
|
|
|
I have .jpeg image with dimension(2000 * 1500), scanned with 200 DPI....When I check pixel color of some (x,y) in Photoshop and retrieve same pixel in GDI+ using bitmap.GetPixel(), I found the difference of 25+ in each color(R,G,B). And When I use some third party Image library (which is wrapper on .NET) gives approximately same color components as Photoshop.
so, Whats up!!!!
Any help regarding this would greatly be appriciated.
Regards.
MaulikCE
Life's a game, full of surprises!!
|
|
|
|
|
You probably have ICC profiles configured in Photoshop. ICC profiles are used to match colors on different devices. With GDI+ (namely, the System.Drawing members in the .NET BCL) you must explicitly state to use ICC profiles. You can do this, for one example, by passing true for the icm parameter of various Bitmap constructor overloads.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
while i just read int this forum abt statement related "using".
Its sumthing like using { graphis g = e.Graphics }
while i want to ask is there any keyword like using for replacing :
try
{
}
catch
{
}
finally
{
}
just like using replaces try{}finally{}
Regards
|
|
|
|
|
Using doesn't replace try/finally. Using ensures that the object you "use" is disposed (ie, IDisposable.Dispose() is called) as soon as the using block is exited. It also ensures that Dispose() is called properly when an exception is thrown that isn't handled within the using block.
Using only works on objects that implement IDisposable, IE:
<br />
using (Font myFont = new Font("Arial", 10.0f))<br />
{<br />
}
In answer to your question though: there is no shorthand syntax for try/catch/finally.
This space for rent!
My Blog
|
|
|
|
|
You might want to look at the IL for code using the using statement. When you compile the using construct is expanded to a try/finally (not a try/catch/finally, though):
using (Graphics g = Graphics.FromImage(img))
g.Clear(Color.White); Becomes
Graphics g = Graphics.FromImage(img);
try
{
g.Clear(Color.White);
}
finally
{
g.Dispose();
} Using ildasm.exe that ships with the .NET Framework SDK is handy for examing build outputs.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Yeah, you're right. I knew that was the case, and I was thinking of adding that to my post before you mentioned it and never got around to it (sidetracked). I got confused when he said it replaces try/finally and didn't mention the Dispose() part of it. Though I guess with a little logical leap I could've worked it out
I've heard a lot of people talk about ildasm, but I've never used it before. Perhaps this is as good a time as any to start.
Thanks Heath.
This space for rent!
My Blog
|
|
|
|
|
You'll need to learn IL, but ildasm.exe is good for that, too. There's also decompilers like .NET Reflector[^] but you won't learn as much as if you know IL.
IMO, it's also more 37337, if you get my drift.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You generally do not dispose objects you didn't create. This includes the PaintEventArgs.Graphics property. Whether you override OnPaint (best for owner drawing when extending a control, including Form s) or handle the Paint event on another control, the default Control implementation will create a Graphics object from the HDC (handle to a device context, which is what Windows uses to paint to various devices like your monitor, a printer, etc.). When OnPaint returns and any event handlers are finished, the object will be disposed.
You should, for example, dispose a Graphics object when you've created one from a Bitmap or other Image using Graphics.FromImage . You should also dispose the Graphics object returned from Control.CreateGraphics .
If you dispose of the Graphics too early you may find that the control isn't painted properly or that an exception is thrown, most likely from a native AV (access violation) exception being thrown.
So, again, as a general rule don't dispose what you didn't create.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I use ShellExecute to open standard email program und create an email with predefined content and allow user to change it before he send it out. As following, the code compiles, but any email program is opened and no email is created. Why, what may I do?
[DllImport("shell32.dll")]
public static extern IntPtr ShellExecute(...)
private void cmdEmail_Click(object sender, System.EventArgs e){
string sEmail = "mailto:le.nhan@freenet.de?"
+ "subject=Error notification"
+ "&body=%0D%0A%0D%0A%0D%0A" + "Description : ";
ShellExecute((System.IntPtr)0, "open", sEmail, null, null, 1);
}
Thanks
TNL
|
|
|
|
|
Why not just use Process.Start ? You P/Invoked what has already been encapsualted for you.
Simply:
Process.Start("mailto:le.nhan@freenet.de?subject=Error notification"); Many email clients do not support the body parameter, which may be the source of your error.
If you tell us what email program you're using, that may help as well. Not giving us any details is like giving a small chunk of code and simply stating that "it doesn't work". Please be specific.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks,
but it doesn't work too, I don't know why. The errormessage:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll.
I call simply so:
System.Diagnostics.Process.Start("mailto:le.nhan@freenet.de?subject=Error");
I use Outlook 2000
I don't know, which Email program will the users use, therefore I used shellexecute in VB, VC, now I want to use it again.
I saw in this site, there are many email solutions, but I can not decide, which suits my aim, simply send a text to a receiver, the user can change the text, but he don't need to login...
Thanks
TNL
|
|
|
|
|
Process.Start uses ShellExecute . If you use an IL disassembler like ildasm.exe or a decompiler like .NET Reflector[^] you can see that. Of course, the ProcessStartInfo.UseShellExecute property should be a pretty good indication, too.
This does work and many, many people use it. Something else with your setup is wrong. What were the details of the Win32Exception ? Just telling me the exception type doesn't typically help much, especially for the Win32Exception . I need to know the error code and any exception text that was returned to you. Only then do you have some chance of figuring out what is wrong.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
is there a class made for dealing with bit stuff like setting bits removing bits and pre defined bit values?
|
|
|
|
|
Read about the BitVector32 structure in the .NET Framework SDK. You can also use the BitArray , but the former structure is more efficient.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I created a Windows Form. The form contains a button called "Line". When I click the button I want a line do be drawn on the Form. I also want the button to disappear.
While I appreciate any help/advice things like "just call DrawLine" or "create a Graphics object" are beyond obvious as general concepts. I would like specifics or even the code fragment.
thanks very much-
|
|
|
|
|
Hi
Here's the code you'll need. If comments aren't enough, just reply:
bool bPaintLine = false;
Pen p = new Pen(Color.Blue);
private void btnLine_Click(object sender, System.EventArgs e)
{
bPaintLine = true;
this.Invalidate();
btnLine.Visible = false;
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if(bPaintLine)
{
using(Graphics g = e.Graphics)
{
Point pStart = new Point(10,10);
Point pEnd = new Point(500,500);
g.DrawLine(p,pStart,pEnd);
}
}
}
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "Most of us are programmers, but a few use VB", Christian Graus
|
|
|
|
|
SimonS wrote:
using(Graphics g = e.Graphics)
That's bad. Do NOT dispose the Graphics given to you in the PaintEventArgs . It will do this itself and may require the HDC that's attacked to it that you've disposed. The OnPaint event handler that fires the Paint event may need it before, after, or both in relation to when the event is fired.
Besides, when extending a class in which you want to paint it is far more efficient to override the event handler instead of handling the event in the very same class. For example:
public class Form1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
} This requires less overhead and gives you more control. There may be times - like when overriding WndProc - that you don't want to call the base implementation. So don't. With an event you can't do that. With events you also can't control when the base implementation is called, while you can with an override.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Simon,
Thanks very much for you help. If you have a second I have two questions:
1. Why is "this" in "this.Invalidate();" the Form and not the button?
2. I've never seen the "using(Graphics g = e.Graphics)" syntax. Don't you have to create a new Graphics(); ?
thanks again...
|
|
|
|
|