|
Christian Graus wrote:
*grin* I'm not touching this.....
Good boy! Because of you, there's just no that much free space in the forums anymore!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
Because of you, there's just no that much free space in the forums anymore!
*grin* Well, there are times I think the same about you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Rahul.P.Menon wrote:
since the drawbacks of vb
Im interested to know what you think can only be done in C# that cant be done in VB.NET - they are essentially the same language with a different syntax.
|
|
|
|
|
Really? VB.NET doesn't support "unsafe" or pointers. But, when there's will, there's a way...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Wrong - C# has pointers, overloaded operators, etc. On the other hand, VB.NET apparently has optional parameters.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How these two function saperate and run for voice. Which of these functions parameter use for voice.
The two functions are:
1: int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen )
2: int ISampleGrabberCB.SampleCB( double SampleTime, IMediaSample pSample )
|
|
|
|
|
What are you trying to do exactly ? What SDK did these API calls come from ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How In this function voice run "int ISampleGrabberCB.SampleCB( double SampleTime, IMediaSample pSample )" .
And how it can be saperated for voice.
|
|
|
|
|
Hey everybody I get this error on my program only when I put a picture on it. Can anyone tell me why this is happening? The second I put one picture on it crashes.
//
An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: DragDrop registration failed.
//
|
|
|
|
|
Hi!
What do you mean by "I put a picture on it"?
In a designer? Drop an image on your application? Anything else?
What else can you "put on" your program to make it not crash?
mav
|
|
|
|
|
I can put just about anything on it. Only when I try to put a picture as a background image or insert a picture box and stick a picture in it does it come up with the error message. I even tried using a label and putting the picture in there but got the error message. I have tried many different pictures also to see if it makes a difference but still no luck. As long as I don't insert a picture the program works.
|
|
|
|
|
Try stripping down the program to the absolute minimum to find out when the exception doesn't occurr any more.
Or create a new project and re-create the parts of your app likely to cause the trouble.
I've created a Form, enabled Drag&Drap for it and placed a picturebox and several other controls on the form, but couldn't experience the behaviour you get.
Perhaps such a minimal project will help...
Regards,
mav
|
|
|
|
|
hi to all,
i have made a console app to test the new functionality of the SerialPort in the new .NET, it works fine when run as a console application, so i converted it to a service, but it doenst launch the MASTER_PROCESS that is defined.
The idea is that the service is always running, and it sends data from the serail port to the application that is the database frontend, but if the user closes the front end (for somereason) the service reopens it when the serial port receives any data.
This works as console app, but the app (notepad) wont open when running as service.
any idea pls?
<code>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO.Ports;
using System.Threading;
namespace SerialPortListener
{
partial class PortListener : ServiceBase
{
#region Private Members
/// <summary>
/// The serial port object to read the data from
/// </summary>
private SerialPort port = null;
/// <summary>
/// the thread that will run, and monitor the port for activity
/// </summary>
private Thread monitorThread = null;
/// <summary>
/// The thread state, alive or dead, alive = true.
/// </summary>
private bool alive = false;
/// <summary>
/// The proccess executable that is the master program that requires
/// the input from this port monitor
/// </summary>
private const string MASTER_PROCESS = "notepad.exe";
#endregion
#region Constructors
/// <summary>
/// Default Constructor
/// Instantiates the serial port using the default values
/// </summary>
public PortListener()
{
InitializeComponent();
this.port = new SerialPort();
this.monitorThread = new Thread(new ThreadStart(MonitorPort));
}
#endregion
#region Thread Members
/// <summary>
/// Starts the thread to listen to the serial port
/// </summary>
protected override void OnStart(string[] args)
{
// start the thread
this.monitorThread.Start();
}
/// <summary>
/// Stops the thread that is listening to the serial port, using Thread.Abort()
/// </summary>
protected override void OnStop()
{
if (this.monitorThread.IsAlive)
{
this.alive = false;
this.monitorThread.Abort();
}
}
/// <summary>
/// Thread method that will monitor the port and handle the data from the port
/// </summary>
private void MonitorPort()
{
this.alive = true;
// loop while the bool is set true, if set false the thread will terminate
while (this.alive)
{
try
{
Thread.Sleep(100);
this.port.Open();
// check if master program is running
if (!IsRunningProcess(MASTER_PROCESS))
{
this.StartMasterProcess();
}
String data = this.port.ReadLine();
this.port.Close();
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION: " + e.Message);
}
}
try
{
// kill the thread
this.monitorThread.Abort();
}
catch (Exception e)
{ }
}
#endregion
#region Private Helpers
/// <summary>
///
/// </summary>
/// <param name="processName"></param>
/// <returns></returns>
private bool IsRunningProcess(String processName)
{
Process[] p = Process.GetProcessesByName(processName);
if (p.Length == 0)
{
return false;
}
return true;
}
private void StartMasterProcess()
{
Process p = new Process();
p.StartInfo.FileName = MASTER_PROCESS;
p.Start();
}
#endregion
}
}
</code>
Kind regards,
g00fy
|
|
|
|
|
forgot to mention that the Service is installed and being able to start stop wuthout problems
sorry for lengthy post, will link to text file next time
regards,
g00fy
|
|
|
|
|
OK
notepad.exe is starting (by checking taskmgr) but it is not being displayed as a window anywhere only as a process, is there a way to do this from a service, like it worked when run from cmd line ?
also everytime i swipe a card, it is spawning another notepad.exe process, this also did not happen when run from cmd line.
NB, notepad is only for testing, eventually this will be the database frontend.
how do you debug services from VS.NET IDE ? cause when i try to it says service is already running, but if you stop it, the IDE says that you cant start service from debugging session
regards,
g00fy
|
|
|
|
|
Services run on their on desktop by default, not the visible one. Go into the Services control panel, find your service and get Properties on it. Click on the LogOn tab and make sure the "Allow service to interact with desktop" checkbox is checked.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you for the reply,
but i had that checked already
it is opening multiple instances of the program and they are not appearing anywhere that is usuable the only place i find them is in taskmanager.
i have googled a bit and realised that my check for the process already running will not give an accurate result so i need to change that to stop the multiple instances problem.
regards,
g00fy
|
|
|
|
|
ok i must have missed something cause i cleaned & rebuilt my project and its ok now so i just have to stop the multiple instance problem.
thank you for your help
regards,
g00fy
|
|
|
|
|
I bind datagrid with a dataset ...and then I use bindingManagerBase.position to move next and pre ,that's normal but when I press the button AddNew(using BindingManagerBase.AddNew()) .It make a new row in datagrid but the cursor don't move to the new row ( It should move when I use the same code in another window form ,it run so well...) and then I can't move Last(after I add a new row in datagrid)...
I don't know why the same code but it takes various result....Could you please to help me?...I must complete this project soon...Thanks first....
The man with nothing to lose
|
|
|
|
|
My application is a commandline app. I spin off a dialog-box GUI in a separate thread. The GUI is refreshed every second based on the computing result of the main thread. But every now and then the GUI is not refreshed when I first start the application. I have to manually minimize and then restore it to make it begin running. Is there a way I can guarantee the GUI is refreshed in the beginning of the application?
|
|
|
|
|
Are your sure you're updating the GUI from the correct thread?
You'll have to use BeginInvoke or Invoke to update GUI elements if these updates are coming from a different thread.
Usually that's the reason for strange behaviour of your GUI.
Regards,
mav
|
|
|
|
|
Are you sure you are updating it using BeginInvoke and EndInvoke ?
One common reason for partial UI updates is updating it from the wrong thread. This[^] article explains why you cannot update the UI from another thread.How are you refreshing the GUI every second, what timer are you using?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello all,
I am trying to develop a text editor that highlights syntax for a statistical software package. I have created an xml file from which all of the keywords are loaded into five separate ArrayLists that each contain one type of syntax that will be highlighted in a rich text box on the main form. Here is the regular expression code that I am using for each of these ArrayLists to color the text when an existing document is opened in the rich text box:
foreach (object keyword in commandAL)<br />
{<br />
string kw = (string)keyword;<br />
string searchstring = @"(?<=\s+)" + kw + @"(?=\s+)";<br />
Regex re = new Regex(searchstring, RegexOptions.IgnoreCase | RegexOptions.Multiline|RegexOptions.Compiled);<br />
MatchCollection mc = re.Matches(richTextBoxDo.Text, 0);<br />
<br />
foreach (Match foundmatch in mc)<br />
{<br />
int startposition = foundmatch.Index;<br />
int length = foundmatch.Length;<br />
richTextBoxDo.Select(startposition, length);<br />
richTextBoxDo.SelectionColor = settings.SyntaxColorCommand;
}<br />
<br />
}
The solution that I've come up with is to use five separate foreach loops, setting the selectioncolor property for any keywords that are found within the loop. Problem is that it is really slow when it opens a new document (over 600 keywords in the xml file). Any advice on how to improve this code would be much appreciated.
Thanks for your help,
Chris Simpkins
|
|
|
|
|
Main advice: Don't use a RichTextBox for syntax highlighting.
For each SelectionColor = ... call, the whole content of the RTB is streamed out to RTF, modified and then streamed back in => enormous overhead.
Recently there have been 2 articles here on syntax highlighting (try the search function). I think you should read them and the readers' comments. I'm quite sure that'll help you.
Regards,
mav
|
|
|
|
|
Thanks for your help!
-CS
mav.northwind wrote:
Main advice: Don't use a RichTextBox for syntax highlighting.
For each SelectionColor = ... call, the whole content of the RTB is streamed out to RTF, modified and then streamed back in => enormous overhead.
Recently there have been 2 articles here on syntax highlighting (try the search function). I think you should read them and the readers' comments. I'm quite sure that'll help you.
Regards,
mav
|
|
|
|