|
|
Lord Kixdemp wrote: But now in C# they have events, so I can't do that...
Why can't you ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
But I don't see any events being handled here ? A game rendering loop looks like this precisely so that it renders as many FPS as the processor can handle.
You can handle the WndProc in .NET if you want to. You can also set event handlers on your window which store the result for your main rendering loop, or call that loop.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
i have a dataset it includes one table ,i would like to add a computed column in this table to calculate 2 fields
thanks for help
MD_NADA
|
|
|
|
|
Hello
md_nada wrote: i would like to add a computed column in this table
Use DataTable.Columns.Add() method to add columns to your DataTable.
md_nada wrote: to calculate 2 fields
What do you mean by fields? Maybe you mean the values in another two columns of the same row like MyColumn = Column1 + Column2?
Regards
|
|
|
|
|
|
Sounds like the LPARAM contains two values. The way to get the part you want is to use LOWORD and HIWORD.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello
What's the integer value you get in your lParam?
Regards
|
|
|
|
|
Hi,
I am new to C# and trying to develop an app that communicates through the serial port. I found some sample code on the net that seems to work, but when i use the same code in my app it throws an exception. Currently I am developing using .NET version 2.0 on a Windows XP SP2 machine.
Am I doing something wrong? Is there a setting that I have to set or include?
Here is the code I have, which is run when I click on a "Start" button:
using System.IO.Ports;
private static void SendSampleData()
{
SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
port.Open();
port.Write("Hello World");
port.Write(new byte[] {0x0A, 0xE2, 0xFF}, 0, 3);
port.Close();
}
I don't know how much more simple I can get with this.
Here is the exception I get when I try and execute the port.Open():
System.Security.SecurityException was unhandled
Message="Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib"
StackTrace:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.Ports.SerialPort.Open()
at CITDataRecorder.CITDataRecorder.Start_Stop_Button_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CITDataRecorder.Program.Main()
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
thanks in advance!
|
|
|
|
|
Fairly obvious from your exception, you don't have permissions on your computer to open the port. Are you a normal (i.e. non-admin) user by any chance?
Just Google it.
Failing that try phoning
|
|
|
|
|
that is what I thought the problem was.....BUT I did run other sample code which I found at http://msmvps.com/blogs/coad/archive/2005/03/23/39466.aspx (the SerialPortTerminal.zip) and it opens up the COM port fine. Its just when i put this code in my sln that it returns that exception.
Did I now include some dll or project property that has me throw this exception in my sln only?
|
|
|
|
|
OK, I solved the problem although I do not understand why. The problem was that I was working under a network drive. As soon as I made the project reside on my local hard drive it worked fine.
So now my new question is, how do I make it so that my project can reside on the networked drive and still execute correctly?
|
|
|
|
|
Hmm, all I can suggest is look through your code carefully to see where it differs (in operation) from the sample code.
Another possibility is are you running your code off a mapped drive? If so you'll have to setup the permissions to trust that mapped drive. Even if it's mapped to a drive on your computer.
Just Google it.
Failing that try phoning
|
|
|
|
|
Greetz!
Can anyone tell me how to save objects in a file?
e.g. combobox is filled with objects form a class (name, which is displayed and value which includes IPEndPoints)
I want to save all Items of the combobox in a file, and load it later again.
All information is stored in the combobox.Text and combobox.Tag.
Other examle given: name is the name of a specific mode, and three string values define the parameters of the modes. This should be saved in a file as well.
Thx in advance,
Ezazazel
|
|
|
|
|
Since you havn't made it very clear how your data is represented / stored on the form, might I suggest you look into Serialization in the System.Serialization namespace?
Alternatively you can create your own file format and read and write data using the stream classes (System.IO namespace)
Or if you want to save it as Xml then take a look at the XmlTextReader, XmlTextWriter and XmlDocument classes in the System.Xml namespace.
Just Google it.
Failing that try phoning
|
|
|
|
|
You can use binary serialization and also you can use xml serialization for it.
For eg,
using System.Runtime;
using System.Runtime.Serialization.Formatters;
//Serilization//
Object s=new Object(textBox1.Text,textBox2.Text,textBox3.Text);
System.Runtime.Serialization.IFormatter f;
f=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.FileStream outf=new System.IO.FileStrea(@"d:\s.bin",System.IO.FileMode.Create,System.IO.FileAccess.Write);
f.Serialize(outf,s);
//Deserializeation//
System.Runtime.Serialization.IFormatter f;
f=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.FileStream fin=new System.IO.FileStream(@"d:\s.bin",System.IO.FileMode.Open,System.IO.FileAccess.Read);
Object s=(Object)f.Deserialize(fin);
Enjoy!!!!
<marquee>nishu
|
|
|
|
|
Wasn't that meant to be in reply to ezazazel?
Just Google it.
Failing that try phoning
|
|
|
|
|
Anyway, got it!
Thx for your help!
|
|
|
|
|
Thx for your help - am going to try it tomorrow.
|
|
|
|
|
This is my first post on this forum, and I am also new to C#.
I am trying to adapt my GDImage Win32.dll to managed code,
so far I have already translated my first graphic demo ZoomPlus,
and I am translating another one named AeroGlass.
AeroGlass, allows the user to move transparent alphablended sprites, with either the mouse or keyboard.
The mouse works just fine, however I have troubles with the keyboard focus using arrow keys.
It looks like the last button of my .NET form keeps the focus on itself,
even if my Win32.dll control uses SetFocus to gain the keyboard focus.
Do you have any suggestion on how to solve this problem ?
and remember I am new to C#, thus still learning...
Patrice Terrier
www.zapsolution.com
|
|
|
|
|
Hello
What I understood from your question is that you want to use an extended way to move your form using the keyboard but you are facing a problem that one of the form's controls -say a button- is having the input focues?
There is an event called Form.KeyPreview which is present in .Net 2.0 framework. You can use it to catch keyboard events in your form before theyu are sent to the controls and move your form according to the key pressed, but first there is a property named Form.KeyPreview also that you must set to true.
I hope that was what you are looking for.
Regards
|
|
|
|
|
Nader--
Thank you for your answer, what I want to do is not to move my form
or any control inside of it.
What I want to do is to move sprites like in game, using the arrow keys.
Thus when I put the focus on the graphic control it must keep it,
even if I am using the direction keys.
If I hold down CTRL+arrow + (up, down, left, rigth)
then I can move the sprites, and also when holding down SHIFT+CTRL.
But holding down a direction key, with or without SHIFT, doesn't work.
This is related to the fact that the form also uses the arrow keys
to navigate between the .NET child controls of the form.
In Win32 it is often the result of using a call to IsDialogMessage
in the WinMain message pump.
Being new to C# I have no idea of what .NET realy does under the hood
in its message pump that would cause this havoc.
|
|
|
|
|
zapsolution wrote: Thus when I put the focus on the graphic control it must keep it
Actually to make your control able to recieve focus -supposing it's inherited from the Control class-, you must call SetStyle(ControlStyles.Selectable, true) first. Otherwise it won't even recieve focus no matter how many Focus() calls or any other calls you make.
zapsolution wrote: This is related to the fact that the form also uses the arrow keys
to navigate between the .NET child controls of the form.
If you want to make the direction keys move the spirit even if the buttons have the focus, you can implement the solution I provided in my previous post, yet note that if the user presses Enter or Spacebar the button which has the focus will be pressed.
zapsolution wrote: Being new to C# I have no idea of what .NET realy does under the hood
in its message pump that would cause this havoc.
I don't see much of a havoc here. The message pump in .Net forms is very much similar to Win32, in fact you can send Win32 messages to .Net forms normally!! Also you can implement IMessageFilter interface to filter messages of your form before being processed, but I don't think that would do you much help. What you really need is to set the focus to the graphics control. Try the SetStyle() method in your control's constructor as it's a protected method.
Regards
|
|
|
|