|
led mike wrote: I will not become open source
Too late - I've already downloaded and modified a version of you under the Creative Commons license.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
thankfully I had just swallowed my coffee before that email loaded.
|
|
|
|
|
Could you explain open source basically?
|
|
|
|
|
There you go[^]. Float your boat.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
How interesting . I didn't know it so far
|
|
|
|
|
Hi
I've written a little app that uses FileSystemWatcher to wait for a new *.jpg file to be written to a folder, then loads the image into the picture box.
It works perfectly for the first file, but subsequent files fail with a message about "invalid parameter".
Oddly, this consistantly fails like this EXCEPT when debugging and stepping through the code where it works for about 5 files before it blows up.
This is the relevant code:-
pictureBox1.WaitOnLoad = true;
Bitmap bmp = new Bitmap(e.FullPath);
pictureBox1.Image = bmp;
Any ideas? I've tried putting .dispose() statements all over the place but that makes no difference. I've run out of ideas now.
It does seem strange to me that you have to tell it the file is a bitmap when it's actually a jpg file, but I don't know of any other way to "attach" to image file to the control. Could this be what's causing the error?
btw I'm fairly new to C# although I'm a long-term VB6 mug, so this could well be me getting hold of the wrong end of the stick
Cheers
Sam
|
|
|
|
|
It could be caused by the file still being written to the disk. The FSW fires it's event when the file is created, not when the app writing the file is done writing it. So, try to open the file DenyShareAll, and if it fails, Sleep for a second, then try again. If the file opens, then you can safely create a Bitmap object from the filestream, close the file, then assign the bitmap to the PictureBox's Image property.
|
|
|
|
|
Ahh, of course. Now you've said that, it's obvious why it worked when when stepping through the code as opposed to running... I was slow enough to allow the file write to complete before going onto the next step.
Not sure how to create a bitmap from the filesteam as you've suggested but I'll think around that. In the meantime I worked around it by looping-and-sleeping until the filestream opened, then closed the filestream and created the bitmap directly from the file (if you know what I mean).
Anyway thanks for the prompt.
Sam
|
|
|
|
|
Hello everyone
Hope you all well. So I am a newbie to the world of programming and I am loving it of course - who wouldnt!
I wonder if anyone out there can help me with app that i would like to write for myself in C#. I work with a lot of emails, and I need to respons to the clients via emails and projects that need be completed. (I know there stuff you could buy for this but hey why be a programmer and buy??)
Anyway I just need some advice and a push in the rigt drection how to do it, so here goes:
Basic start up app, gives me completed tasks for the week, and those that I should try to get to today. Those I didnt finish of I can click a button and send a 'sorry' email to the client. I would like the app to pop up on starting up - no excuses of oops forgot to open my outlook. I tend to do that... :/
Anyway love the site and hope to be as brilliant as all of you in the near future!
Live Brave!
|
|
|
|
|
geoNeo_ wrote: So I am a newbie to the world of programming
How much so? because you may want to start somewhere more basic. But you will want to look at some of the following
Databases
DataGridView or simliar control
Event Handlers
Notification Icons
Timers
And some sort of email API or you can talk to outlook yourself
etc...
geoNeo_ wrote: Those I didnt finish of I can click a button and send a 'sorry' email to the client
I assume you dont rely on recommendations or repeat business to keep your job going then
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hey
Well newish - all the components I understand and more less how to use them, what I sort of dont really know is what commands to use or how actually go about it.
I mean for example wat units to use, how the I/O is utlised or joined onto the local machines email program stuff like that.
Thanks for your prompt reply, is just something I really like to take on as my firts full fledged app.
Your help is greatly appreciated
|
|
|
|
|
Hi All,
I'm trying to chenge the color of my ProgressBar without building a new component from scratch.
I tried inheriting from System.Windows.Forms.ProgressBar and use the code below (which I found in several forums), but it's not working (if relevant, I'm working on vista 64).
Any ideas?
class MyProgressBar : ProgressBar
{
[DllImport("User32.Dll")]
public static extern int SendMessage(int hwnd, int wMsg, int wParam, int lParam);
public const int PBM_SETBKCOLOR = 0x2001;
public const int PBM_SETBARCOLOR = 0x409;
public void SetProgressBackColor(Color c)
{ int a = Convert.ToInt32(c.R.ToString());
int b = Convert.ToInt32(c.G.ToString());
int d = Convert.ToInt32(c.B.ToString());
int tot = Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a, b, d)).ToString());
int j = this.Handle.ToInt32();
SendMessage(j, PBM_SETBKCOLOR, 0, tot);
}
public void SetProgressForeColor(Color c)
{ int a = Convert.ToInt32(c.R.ToString());
int b = Convert.ToInt32(c.G.ToString());
int d = Convert.ToInt32(c.B.ToString());
int tot = Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a, b, d)).ToString());
int j = this.Handle.ToInt32();
SendMessage(j, PBM_SETBARCOLOR, 0, tot);
}
}
Thanks!
|
|
|
|
|
eyalbi007 wrote: int a = Convert.ToInt32(c.R.ToString());
Seriously, why would you do that? Its effect is equivalent to that of int a = c.R; , but a lot slower.
Oh and your SendMessage signature is incorrect.
Use:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
|
I think this would be the best option...
int a = (int)Double.Parse(Convert.ToInt32(c.R.ToString())).ToString();
... Actually that mind need a little work still (wheres the 'ive wet myself with laughter' smiley???)
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Give me a break, it's just a code I copied fom the web...
|
|
|
|
|
Well, change it..
It needs to be changed anyhow, because of the required IntPtr's. They are actually required here because you trying to run it in 64 bit mode which is expecting 64 bit arguments and you're passing 32 bit ones.
I wouldn't trust such badly written code at all
|
|
|
|
|
Well, still not working...
|
|
|
|
|
Well, show us the codez.. and tell us what it's doing (if anything)
|
|
|
|
|
Here's the code (that indeed does nothing).
What I was hopint it'll do is paint the prorgesss bar in different color than green (the Windows default color), by pressing button2. button1 simply advances the bar.
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const Int32 PBM_SETBKCOLOR = 0x2001;
public const Int32 PBM_SETBARCOLOR = 0x0409;
public void SetProgressBackColor(Color c)
{ int a = c.R;
int b = c.G;
int d = c.B;
int tot = ColorTranslator.ToOle(Color.FromArgb(a, b, d));
IntPtr j = this.progressBar1.Handle;
SendMessage(j, PBM_SETBKCOLOR, 0, tot);
}
public void SetProgressForeColor(Color c)
{ int a = c.R;
int b = c.G;
int d = c.B;
int tot = ColorTranslator.ToOle(Color.FromArgb(a, b, d));
IntPtr j = this.progressBar1.Handle;
SendMessage(j, PBM_SETBKCOLOR, 0, tot);
}
private void button1_Click(object sender, EventArgs e)
{
this.progressBar1.Minimum = 1;
this.progressBar1.Maximum = 10000;
this.progressBar1.Step = 1;
this.progressBar1.Value = 1;
for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++)
{
progressBar1.PerformStep();
}
}
private void button2_Click(object sender, EventArgs e)
{
SetProgressBackColor(System.Drawing.Color.BlueViolet);
SetProgressForeColor(System.Drawing.Color.Red);
}
|
|
|
|
|
Well for one thing, the SendMessage signature still isn't correct. You absolutely have to use those annoying IntPtr's otherwise it won't work.
But then there's something else, I once heard (not sure how true it is) that progress bars in Vista may only be green yellow or red and that they have a special (different) message to change it. May be worth investigating.
|
|
|
|
|
Just make your own control, you can prob do in less code then you using to change it lol
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
eyalbi007 wrote: int j = this.Handle.ToInt32();
wrong
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello,
I am working on window application and i want to assign multicolor to text through programming,
I am filling data in Rich Text box and i want to assign different color to text like. word "Hello" in red word "Welcome" in blue etc.
I am working on C# kindly tell me what should i do and how this problem can be solve easily.
Thanks
|
|
|
|
|
Create one string array and in that array set all words,and give color to each item of array and finally convert all array items in single line string.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
U need to use the selectedText and selectionColor properties of the Richtextbox.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|