|
thanks for the reply, but what has that got to do with my mouse wheel question?
|
|
|
|
|
Good day
I get a JIT error when i try to run my application from a network share. It throws a SecurityException. Try to catch this exception through code has been fruitless.
Is there a way to catch or guard against this error? Or is there a way around it?
Thanks
Kulile --- RSA
|
|
|
|
|
|
thanks a lot
Kulile --- RSA
|
|
|
|
|
i'm tring to scroll a picture box using the drag-drop functionality, i have a small panel and a big picturebox in it and i want the panel to scroll the piscturebox when i drag and drop it (exactly like in Acrobat reader). What code am i supose to write to meve the picture box??
and another question:
say i want to center the panell view on o specific point on the picturebox, how do i do that??
-- modified at 9:16 Monday 6th November, 2006
rzvme
|
|
|
|
|
I need to know if i can implement the edges and borders of a button or a panel or any other control. Or if there is any other library that i can download or reference to, that have special buttons (labels, panels, textfields, ...) that have special appearance but ofcourse with the same functionality of the standard controls in the VS2005.
Best Regards.
Jamil Abou Khalil
|
|
|
|
|
|
hi,
i couldn't find anything helpfull in any of these links that u provided for me.
hope if you can provide me with some souce code or sample or something like that. i will be verry greatfull to u.
Thank you
jamil abou khalil
|
|
|
|
|
If you download that Krypton Toolkit you can use the controls in that library and set their colours, borders to what you want, there are lots of samples as well.
|
|
|
|
|
hi
i want to load any avi into memoryStream by loop cycle and play it until memoryStream finish loading.
can anybody help to me how to do ?
|
|
|
|
|
hi,
i´ve got a problem with capturing a image from a webcam.
i can only capture a picture with a resolution of 640x480, but i need a resolution of 1280x1024.
the webcam support the resolution of 1280x1024.
stephan
|
|
|
|
|
Ok im trying to create a barcode program that will make barcodes using Code128A. Firstly i downloaded a free program that can already make these barcodes, just so that i can compare my codes to for checking purposes.
To cut along story short, when i generate CODE128A barcode i have to do a checksum. The checksum is done by looking up certain values of the encoded data and dividing it by 103. The checksum is the remainder of that.
So for example my value = 1265. I have to do 1265/103 and the remainder of that equals the checksum. That checksum is then encoded in the barcode. Here is my problem. When i do 1265%103 in c#, i get an answer of 29. But the program i downloaded says its 28! My barcode scanner also says its 28 as it dosen't read my code but does read the one generate by this program. What i did was make a function that allowed me to change the way it rounded the remainder. Now i can get 28.
I then made another barcode. This time i was working with the value of 1215, so its 1215/103. My program gave me a remainder of 79. Even doing 1215%103 gives me that but this barcode program says its 82!!!
How the hell did it get that?
At this point i was getting mad and confused. Then i thought i would do it on paper the old fashon way and i got this.
0011 rm82
103)1215
So i changed my function to work it out as above. My problem now is that my orginal question 1265/103 gives me 29 again. Does anyone know what i can do to fix this problem?
-- modified at 6:29 Monday 6th November, 2006
|
|
|
|
|
You have to find out how the checksum really is supposed to be calculated, as the reminder of 1265/103 is 29, not 28. There is no rounding, so there is never any doubt what the result should be.
---
b { font-weight: normal; }
|
|
|
|
|
|
can anyone please enlighten us on what relay can we use supplied by the 5DCV parallel port that can switch on an ordinary 110/220 switch, say to turn the rooms lights on without any risk?? i've been to Radio Shack yesterday and all i was able to find were relays to deal with batteries. please help.
kind regards,
muammar
|
|
|
|
|
Hi,
I think you are in wrong forum. Try hardware forums. (dont mind but here you wont get much help)
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
thanx
|
|
|
|
|
|
thanx
|
|
|
|
|
Please don't cross post. Especially not in totally unreladed forums.
---
b { font-weight: normal; }
|
|
|
|
|
Can anybody tell me how to include the Style Builder dialog box
that is include in VS2005 in my own C# source code?
I wish to make my own Cascading Style sheets with
that nice Style Builder.
Thanks
Gywox
|
|
|
|
|
Hi,
A few weeks back i was trying to implement backgroundworker. I got a good code sample but i still didn't managed to get it to work.
I messed up my whole code. Nothing was working anymore. So i had to work on my backupped project. Now i got it back as how it was again.
I was kinda hoping if someone could help me again with it. Some comments would be really appreciated (in plain English).
This is my whole class:
public partial class FrmWordDisplayer : Form
{
public FrmWordDisplayer()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(FrmWordDisplayer_FormClosing);
}
private void FrmWordDisplayer_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result = MessageBox.Show("wanna close?", "Conformation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
e.Cancel = false;
this.Dispose();
}
else if (result == DialogResult.No)
{
e.Cancel = true;
}
}
public void DisplayWord()
{
Show();
FileStream smallWords = File.Open(@"smallwords.txt", FileMode.Open, FileAccess.Read);
StreamReader rdr = new StreamReader(smallWords);
Random rnd = new Random();
string sDocument = rdr.ReadToEnd();
rdr.Close();
smallWords.Close();
string[] words = sDocument.Replace('\r', ' ').Replace('\n', ' ').Split(';');
while(true)
{
int numberChosen = rnd.Next(0, words.Length - 1);
this.lblDisplayWord.Text = words[numberChosen].ToString();
this.lblDisplayWord.Update();
Application.DoEvents();
Thread.Sleep(1000);
}
}
}
This is a second Form in my project. On my fist Form i got a few buttons. One of them, represents this Form. When this button is pressed, it execute this method: public void DisplayWord() and keeps displaying words until the user closes the Form.
But the Form still hangs. Thats why i want to implement the backgroundworker. It makes it possible the be in control of the Form the whole time.
Its this peace of code that makes the Form running slow and hang:
while(true)
{
int numberChosen = rnd.Next(0, words.Length - 1);
this.lblDisplayWord.Text = words[numberChosen].ToString();
this.lblDisplayWord.Update();
Application.DoEvents();
Thread.Sleep(1000);
}
Thanks in advance!
|
|
|
|
|
The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.
To execute a time-consuming operation in the background, create a BackgroundWorker and listen for events that report the progress of your operation and signal when your operation is finished. You can create the BackgroundWorker programmatically or you can drag it onto your form from the Components tab of the Toolbox. If you create the BackgroundWorker in the Windows Forms Designer, it will appear in the Component Tray, and its properties will be displayed in the Properties window.
To set up for a background operation, add an event handler for the DoWork event. Call your time-consuming operation in this event handler. To start the operation, call RunWorkerAsync. To receive notifications of progress updates, handle the ProgressChanged event. To receive a notification when the operation is completed, handle the RunWorkerCompleted event.
I can not see BackroundWorker.RunAsync() method in your code, you must trigger your background worker with this method. In MSDN there are useful examples.
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Threading;<br />
using System.Windows.Forms;<br />
<br />
namespace BackgroundWorkerExample<br />
{ <br />
public class FibonacciForm : System.Windows.Forms.Form<br />
{ <br />
private int numberToCompute = 0;<br />
private int highestPercentageReached = 0;<br />
<br />
private System.Windows.Forms.NumericUpDown numericUpDown1;<br />
private System.Windows.Forms.Button startAsyncButton;<br />
private System.Windows.Forms.Button cancelAsyncButton;<br />
private System.Windows.Forms.ProgressBar progressBar1;<br />
private System.Windows.Forms.Label resultLabel;<br />
private System.ComponentModel.BackgroundWorker backgroundWorker1;<br />
<br />
public FibonacciForm()<br />
{ <br />
InitializeComponent();<br />
<br />
InitializeBackgoundWorker();<br />
}<br />
<br />
private void InitializeBackgoundWorker()<br />
{<br />
backgroundWorker1.DoWork += <br />
new DoWorkEventHandler(backgroundWorker1_DoWork);<br />
backgroundWorker1.RunWorkerCompleted += <br />
new RunWorkerCompletedEventHandler(<br />
backgroundWorker1_RunWorkerCompleted);<br />
backgroundWorker1.ProgressChanged += <br />
new ProgressChangedEventHandler(<br />
backgroundWorker1_ProgressChanged);<br />
}<br />
<br />
private void startAsyncButton_Click(System.Object sender, <br />
System.EventArgs e)<br />
{<br />
resultLabel.Text = String.Empty;<br />
<br />
this.numericUpDown1.Enabled = false;<br />
<br />
this.startAsyncButton.Enabled = false;<br />
<br />
this.cancelAsyncButton.Enabled = true;<br />
<br />
numberToCompute = (int)numericUpDown1.Value;<br />
<br />
highestPercentageReached = 0;<br />
<br />
backgroundWorker1.RunWorkerAsync(numberToCompute);<br />
}<br />
<br />
private void cancelAsyncButton_Click(System.Object sender, <br />
System.EventArgs e)<br />
{ <br />
this.backgroundWorker1.CancelAsync();<br />
<br />
cancelAsyncButton.Enabled = false;<br />
}<br />
<br />
private void backgroundWorker1_DoWork(object sender, <br />
DoWorkEventArgs e)<br />
{ <br />
BackgroundWorker worker = sender as BackgroundWorker;<br />
<br />
e.Result = ComputeFibonacci((int)e.Argument, worker, e);<br />
}<br />
<br />
private void backgroundWorker1_RunWorkerCompleted(<br />
object sender, RunWorkerCompletedEventArgs e)<br />
{<br />
if (e.Error != null)<br />
{<br />
MessageBox.Show(e.Error.Message);<br />
}<br />
else if (e.Cancelled)<br />
{<br />
resultLabel.Text = "Canceled";<br />
}<br />
else<br />
{<br />
resultLabel.Text = e.Result.ToString();<br />
}<br />
<br />
this.numericUpDown1.Enabled = true;<br />
<br />
startAsyncButton.Enabled = true;<br />
<br />
cancelAsyncButton.Enabled = false;<br />
}<br />
<br />
private void backgroundWorker1_ProgressChanged(object sender,<br />
ProgressChangedEventArgs e)<br />
{<br />
this.progressBar1.Value = e.ProgressPercentage;<br />
}<br />
<br />
long ComputeFibonacci(int n, BackgroundWorker worker, DoWorkEventArgs e)<br />
{<br />
if ((n < 0) || (n > 91))<br />
{<br />
throw new ArgumentException(<br />
"value must be >= 0 and <= 91", "n");<br />
}<br />
<br />
long result = 0;<br />
<br />
<br />
if (worker.CancellationPending)<br />
{ <br />
e.Cancel = true;<br />
}<br />
else<br />
{ <br />
if (n < 2)<br />
{ <br />
result = 1;<br />
}<br />
else<br />
{ <br />
result = ComputeFibonacci(n - 1, worker, e) + <br />
ComputeFibonacci(n - 2, worker, e);<br />
}<br />
<br />
int percentComplete = <br />
(int)((float)n / (float)numberToCompute * 100);<br />
if (percentComplete > highestPercentageReached)<br />
{<br />
highestPercentageReached = percentComplete;<br />
worker.ReportProgress(percentComplete);<br />
}<br />
}<br />
<br />
return result;<br />
}<br />
<br />
<br />
#region Windows Form Designer generated code<br />
<br />
private void InitializeComponent()<br />
{<br />
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();<br />
this.startAsyncButton = new System.Windows.Forms.Button();<br />
this.cancelAsyncButton = new System.Windows.Forms.Button();<br />
this.resultLabel = new System.Windows.Forms.Label();<br />
this.progressBar1 = new System.Windows.Forms.ProgressBar();<br />
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();<br />
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();<br />
this.SuspendLayout();<br />
this.numericUpDown1.Location = new System.Drawing.Point(16, 16);<br />
this.numericUpDown1.Maximum = new System.Decimal(new int[] {<br />
91,<br />
0,<br />
0,<br />
0});<br />
this.numericUpDown1.Minimum = new System.Decimal(new int[] {<br />
1,<br />
0,<br />
0,<br />
0});<br />
this.numericUpDown1.Name = "numericUpDown1";<br />
this.numericUpDown1.Size = new System.Drawing.Size(80, 20);<br />
this.numericUpDown1.TabIndex = 0;<br />
this.numericUpDown1.Value = new System.Decimal(new int[] {<br />
1,<br />
0,<br />
0,<br />
0});<br />
this.startAsyncButton.Location = new System.Drawing.Point(16, 72);<br />
this.startAsyncButton.Name = "startAsyncButton";<br />
this.startAsyncButton.Size = new System.Drawing.Size(120, 23);<br />
this.startAsyncButton.TabIndex = 1;<br />
this.startAsyncButton.Text = "Start Async";<br />
this.startAsyncButton.Click += new System.EventHandler(this.startAsyncButton_Click);<br />
this.cancelAsyncButton.Enabled = false;<br />
this.cancelAsyncButton.Location = new System.Drawing.Point(153, 72);<br />
this.cancelAsyncButton.Name = "cancelAsyncButton";<br />
this.cancelAsyncButton.Size = new System.Drawing.Size(119, 23);<br />
this.cancelAsyncButton.TabIndex = 2;<br />
this.cancelAsyncButton.Text = "Cancel Async";<br />
this.cancelAsyncButton.Click += new System.EventHandler(this.cancelAsyncButton_Click);<br />
this.resultLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;<br />
this.resultLabel.Location = new System.Drawing.Point(112, 16);<br />
this.resultLabel.Name = "resultLabel";<br />
this.resultLabel.Size = new System.Drawing.Size(160, 23);<br />
this.resultLabel.TabIndex = 3;<br />
this.resultLabel.Text = "(no result)";<br />
this.resultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;<br />
this.progressBar1.Location = new System.Drawing.Point(18, 48);<br />
this.progressBar1.Name = "progressBar1";<br />
this.progressBar1.Size = new System.Drawing.Size(256, 8);<br />
this.progressBar1.Step = 2;<br />
this.progressBar1.TabIndex = 4;<br />
this.backgroundWorker1.WorkerReportsProgress = true;<br />
this.backgroundWorker1.WorkerSupportsCancellation = true;<br />
this.ClientSize = new System.Drawing.Size(292, 118);<br />
this.Controls.Add(this.progressBar1);<br />
this.Controls.Add(this.resultLabel);<br />
this.Controls.Add(this.cancelAsyncButton);<br />
this.Controls.Add(this.startAsyncButton);<br />
this.Controls.Add(this.numericUpDown1);<br />
this.Name = "FibonacciForm";<br />
this.Text = "Fibonacci Calculator";<br />
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.Run(new FibonacciForm());<br />
}<br />
}<br />
}
|
|
|
|
|
Hi mertkan65,
Thank you for your reply!
I've read those examples many times. Its too complicated.
I was hoping if someone could help me implement it in my code.
I tried many things with no success...
|
|
|
|
|
It looks to me like you would be better off just using a timer. But, maybe you are doing an exercise in multithreading. In which case, it doesn't look like you've created a separate thread anywhere.
Something like this might be closer to what you are trying to do:
public partial class frmWordDisplayer : Form
{
private Thread tMyThread;
delegate void SetlabelCallback(string cCaption);
public frmWordDisplayer()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(FrmWordDisplayer_FormClosing);
}
private void FrmWordDisplayer_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result = MessageBox.Show("wanna close?","Conformation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
e.Cancel = false;
tMyThread.Abort();
this.Dispose();
}
else if (result == DialogResult.No)
{
e.Cancel = true;
}
}
public void DisplayWord()
{
Show();
tMyThread = new Thread(new ThreadStart(DisplayWordThread));
tMyThread.Start();
}
private void DisplayWordThread()
{
FileStream smallWords = File.Open(@"smallwords.txt", FileMode.Open, FileAccess.Read);
StreamReader rdr = new StreamReader(smallWords);
Random rnd = new Random();
string sDocument = rdr.ReadToEnd();
rdr.Close();
smallWords.Close();
string[] words = sDocument.Replace('\r', ' ').Replace('\n', ' ').Split(';');
while(true)
{
int numberChosen = rnd.Next(0, words.Length - 1);
SetLabelCaption(words[numberChosen].ToString());
Thread.Sleep(1000);
}
}
private void SetLabelCaption(String cCaption)
{
if (this.lblDisplayWord.InvokeRequired)
{
SetlabelCallback d = new SetlabelCallback(SetLabelCaption);
this.Invoke(d, new object[] { cCaption });
}
else
{
this.lblDisplayWord.Text = cCaption;
this.lblDisplayWord.Update();
}
}
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|