|
hello forum
can anybody tell me how can i export and import text from rich text box to word file (.doc) in c# window application
regards
rahul
|
|
|
|
|
Hello,
I have a piece of code that should be subject to conditional compilation. I'm trying to compare the use of a conditional directive vs. using an if-condition over a const variable. The second approach looks safer from compilation perspective, but the first one has its advantages (e.g. save memory by not declaring unused variables).
I'd appreciate your help on best practices regarding this issue...
Many thanks to all helpful guys here in CP!
I really appreciate your help.
Know me better
|
|
|
|
|
Another alternative is to make it configurable.
It depends on just what it is you're trying to do.
|
|
|
|
|
Yes, but I don't need that level at the moment.
Additionally, making it configurable doesn't allow the compiler to do certain optimizations. For example, checking a const variable which is statically known to be either true or false gives the compiler an opportunity to optimize the check away, and keep only the relevant code (with unreachable code detected warning).
Many thanks to all helpful guys here in CP!
I really appreciate your help.
Know me better
|
|
|
|
|
Then use conditional compilation.
|
|
|
|
|
Hi there,
I am developing a C# program to record voice simultaneously from some microphones.
I need to save(record) audio inputs on some separate memory streams.
I use Visual studio 2005, a Delta 1010-LT soundcard which has 8inputs.
My problem is in two points, let's suppose that we have just two inputs to record from,
then 1st when I try to save two audio input streams on two separate files, just one of them
saves audio & at the same time two audio inputs get mixed together on just one file while the other one
is saved empty! I want to save them separately not mixed!
The 2nd problem is voice that been recorded; While it is mixed of two audio inputs, it has some gaps just
because of switching job of CPU during recording. I believe if the 1st prob get solved then the 2nd one
will be solved automatically.
How should I do that? Is there any Mixer API that can help me?Confused
Thanks in advance Smile
|
|
|
|
|
I'd work on getting one channel to record properly before
worrying about multiple channels.
If you have gaps you're doing something wrong.
How are you getting audio from the sound card?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hello forum
i need to change the font of text in hindi on runtime.For that i need to installs new fonts of hindi langauage to visual studio.
Do i need that??
How can i do that??
Regards
Rahul Adya
modified on Sunday, September 21, 2008 9:37 AM
|
|
|
|
|
Fonts are installed in the OS. Control panel|fonts
|
|
|
|
|
Hi guys
I want to know how to display a picture stored in an attachment field in an Access 2007 database in a Visual C# picture box or more generally exporting a file from an attachment field in access 2007, I searched a lot but couldn't find, Please help.
Thanks.
©2008 NukeWare
|
|
|
|
|
|
hey guys
Im working on a project that connect users to a recording server.
so i have one ocx file that need to be dragged to a from(win froms),
then im using his fucntions (connnecting to the server and so...)
i would like to work with that ocx file on asp .net ...
is there a way to do it ?
|
|
|
|
|
Hello.
I have been creating a simple irc client that connects to a server and sends some simple commands to it
I have also figured out how to retrive data from the server by using streams
The problem is I have to run a never-ending while to keep retriving all the data from the server
I do it like this:
while ((inputLine = reader.ReadLine()) == null)
{
listBox1.Items.Add(reader.ReadLine());
}
The problem is that my form doesent respond (I cant use buttons, and such) since the while is never-ending
Is there any way of adding a event that triggers when there is new data from the server?
Here is my project:
dumpen.dk/include/files/IrcBot.rar
And a bonus question: When connecting to Quakenet and joining a channel it says: 451 Register first
Why is that?
|
|
|
|
|
Casper Hansen wrote: while ((inputLine = reader.ReadLine()) == null)
{
listBox1.Items.Add(reader.ReadLine());
}
Are you sure that logic is correct? You have essentially written this: While the reader is exhausted add the next line to the list box.
This will go into an infinite loop and effectively block your program for eternity, or until you externally kill the process, or until the memory of all those empty items in the list box is exhausted.
|
|
|
|
|
Well no :P
Thats why I ask here since I cant seem to come up with a solution
|
|
|
|
|
Actually, your question was about whether a specific feature was available in a framework. You did not question the logic.
|
|
|
|
|
I would like help with the logic as well or just some other soloution for my problem
|
|
|
|
|
Is this the correct way of using thread?
using System;
using System.Windows.Forms;
namespace mutlithread
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void FakeUIUpdater(string textboxText)
{
UIUpdaterDelegate updateUI = new UIUpdaterDelegate(UpdateUI);
this.Invoke(updateUI, new object[] { textboxText });
}
delegate void UIUpdaterDelegate(string textboxText);
protected void UpdateUI(string textboxText)
{
textBox1.Text = textboxText;
}
private void button1_Click(object sender, EventArgs e)
{
FakeUIUpdater("test");
}
}
}
|
|
|
|
|
I have a form 'frmProgressBar', which is shown as popup using obj.showDialog(). This form has a backgroundworker thread running, which keeps running till the processing in other forms is not compleated. I want to hide this form whenever the main form is minimised and this form is getting hidden also. But the problem is, when the main form is maximized, I want to show the popup form again. I checked !IsDestroyed which returns false, so the backgroundworker thread is still running, but the form on it is not displayed in the foreground. I tried Show(), BringToFront(), TopLayer = True, but nothing seems to work. Any hellp please.It is very urgent.
Thank You,
Prashant
|
|
|
|
|
bool bContinue = true;
public frmProgressBar(string Message)
{
InitializeComponent();
this.ShowInTaskbar = false;
lblMessage.Text = Message ;
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
}
//This is called when my main window is resized
private void setWindowStateAccordingToMainForm(FormWindowState State)
{
if (this.InvokeRequired)
{
setWindowState d = new setWindowState(setWindowStateAccordingToMainForm);
this.Invoke(d, new object[] { State });
}
else
{
if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal))
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Show();
}
}
else if (State == FormWindowState.Minimized)
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Hide();
}
}
}
}
void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Close();
this.Dispose();
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (bContinue)
{
}
}
|
|
|
|
|
First, use codeblock formatting for code pieces this large. It helps reading.
If I read this correctly, you seem to set WindowState to Minimized in all cases
if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal))
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Show();
}
}
else if (State == FormWindowState.Minimized)
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Hide();
}
}
Also if you want the progress-form to follow main form's windowstate, could you simplify the logic and use mainform's events to minimize, normalize etc. the progress-form. For example in main form:
private void MainForm_SizeChanged(object sender, EventArgs e) {
if (this.WindowState == FormWindowState.Normal) {
this.frmProgressBar.WindowState = FormWindowState.Normal;
this.frmProgressBar.BringToFront();
} else if ...
}
Hope this helps,
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Hi Mika,
Thank you for your reply.
I typed it 'Minimized' in first if. It was my typing mistake.It should have been 'Maximized' instead.
I can't set the frmProgressBar's windowState from frmMain, because frmProgressBar is not a control in form frmMain, but a separate form whose methods (Hide and Show) are exposed through AggGlobals class (class which stores all application level variables and exposes common functionality). So I can't access it through frmMain.
But thank God, at last I got the solution. I set the 'Owner' property of frmProgressBar to frmMain (for that I had to store an instance of frmMain in AppGlobals) and set CheckForIllegalCrossThreadCalls = false in frmProgressBar constructor, and it worked !!! In vs 2003 it used to work without this setting but in vs 2005 MS has added a check for this. If you run it using ctrl + F5 the application run's perfectly fine, but while debugging i.e. F5 it is an issue.
Storing an object of frmMain in AppGlobals is a temporary solution and I think I will have to do this using reflection.
Cheers,
Prashant.
|
|
|
|
|
Glad you got it solved.
I understood that these are two separate forms. However form is just a class whereas other classes so if you want, you can store a reference to another form in main form using a variable that is type of frmProgressBar. This way you could fully control the frmProgressBar from the main form.
For example when showing progressbar, you could have a methods like following in the main form
private frmProgressBar barForm; <-- at form level
private void ShowProgress() {
barForm = new frmProgressBar();
barForm.Show();
...
}
private void UpdateProgress(int percentage) {
barForm.ProgressControl.Value = percentage;
OR PREFERRABLY
barForm.UpdatePercentage(percentage); <--- this method would update any necessary controls in frmProgressBar
...
}
private void EndProgress() {
barForm.Hide();
barForm = null;
...
}
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Hi all, I have added a bit more description to yesterdays post.Yesterday Mika had given me a solution, but for some reasons I can't do it that way because of some design constraints, and I have to do it this way only.
I have a form 'frmProgressBar', which is shown as popup using objfrmProgressBar.showDialog() from a class AppGlobals (AppGlobals.prpgressbar.show() method). frmProgressBar has a backgroundworker thread running, which keeps running till the processing in other forms is not compleated. I want to hide popup whenever the main form, on which other controls are loaded, is minimised and the popup is getting hidden also. But the problem is, when the main form is maximized, I want to show the popup form again. I checked !IsDestroyed for frmProgressBar which returns false, so the backgroundworker thread is still running, but the popup is not displayed in the foreground, only main form is shown. I tried Show(), BringToFront(), TopLayer = True, but nothing seems to work. Any help please.It is very urgent.
Following is my code :
bool bContinue = true;
public frmProgressBar(string Message)
{
InitializeComponent();
this.ShowInTaskbar = false;
lblMessage.Text = Message ;
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler (backgroundWorker_RunWorkerCompleted);
}
//This is called when my main window is resized event us fired
private void setWindowStateAccordingToMainForm(FormWindowState State)
{
if (this.InvokeRequired)
{
setWindowState d = new setWindowState(setWindowStateAccordingToMainForm);
this.Invoke(d, new object[] { State });
}
else
{
if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal))
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Maximized;
BringToFront();
Activate();
}
}
else if (State == FormWindowState.Minimized)
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Hide();
}
}
}
}
void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Close();
this.Dispose();
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (bContinue)
{
}
}
|
|
|
|
|
Few issues to point out:
1. The logic I suggested won't work if you use ShowDialog . This is because the code on the main form will wait until the dialog is closed. So if you want to use that approach, the main form must be in control all the time and frmProgressBar is only showing the current situation.
2. Of course the logic can be turned upside down so that the frmProgressBar is in control.
3. Another thing is owner. Do you specify any owner in Show or ShowDialog ? If not, try adding ShowDialog(this) (or replace this with instance of the mainform if needed.
And again, try to use:
codeblock formatting. It helps reading several lines of code.
Mika
The need to optimize rises from a bad design
|
|
|
|