|
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"
|
|
|
|
|
Hi
I have some problem while getting common data from two tables.
I have one dataset which contains tow datatables, one datatable contains 100 rows and second datatable contains 10 rows, both having one common field (example: currentdate), now i want matching rows from both table in one single table. how can i do it. please give me some example also.
Thank you
|
|
|
|
|
create a relation between the two tables?
|
|
|
|
|
hi...
i have used datarelation but i am not sure how to get that common data into one single table...can you give me some code for that.
Thank You.
|
|
|
|
|
I guess the straight forward way would be to loop through one table and for each row copy its data and all the related rows into the new table.
|
|
|
|
|
I get http://www.postimage.org/image.php?v=Pq1N1qmr[^] <- this error on one of the computers.
Dont know why.
this is the code:
try
{
label12.ForeColor = Color.Black;
string dbConnComm = "INSERT INTO Vnosi ([Dostava],[Skatla],[Barkoda],[Oznaka],[Skener],[Operater],[Datum],[PosnetkiV3],[PosnetkiM3],[Opombe]) VALUES ("
+ cmbDostava.Text + ", "
+ cmbSkatla.Text + ", '"
+ cmbBarkoda.Text + "', '"
+ cmbEnota.Text + "', '"
+ cmbSkener.Text + "', '"
+ cmbOperater.Text + "', '"
+ cmbDatum.Text + "', "
+ txtVA3.Text + ", "
+ txtMA3.Text + ", '"
+ txtOpombe.Text + "')";
SqlConnection dbConn = new SqlConnection(sqlConnection);
dbConn.Open();
SqlCommand dbComm = new SqlCommand(dbConnComm, dbConn);
dbComm.ExecuteNonQuery();
dbConn.Close();
label12.Text = "Uspešno vnešeno";
}
catch(Exception ex)
{
label12.ForeColor = Color.Red;
label12.Text = "Napaka pri vnosu";
MessageBox.Show("Napaka: " + ex.ToString());
}
PC has framework 2.0 and 1.1
|
|
|
|
|
A few quick question to help try find the answer.
Have you tried the insert into the database directly and dose it work?
What is the connection string you are using as it appears to be a connection issue?
Can you connect to the database from that machine?
Why are you using an insert? you should look at using a stored procedure as direct sql asks for an injection attack.
|
|
|
|
|
|
Yes Giorgi, thank you for your information on security about SQL injections.
I just needed an anwser which was more than funny. The SQL Connection string was wrong.
And its my bad that i forgot to mention that this error occurs only on computers which have low-access accounts in our domain. Now i've fixed this and it works.
HopingToCode was right. I should check the connection string. Which i did today.
Thank you both for your time.
Regards,
Matjaž
|
|
|
|
|
I am not able to attach Application.Idle event with the event handler. what will be the reasons??
thanks
|
|
|
|
|
saksp wrote: what will be the reasons
Maybe you're doing it wrong?
This works for me.
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Application.Idle += new EventHandler(Application_Idle);
}
void Application_Idle(object sender, EventArgs e)
{
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
saksp wrote: I am not able to attach Application.Idle event with the event handler. what will be the reasons??
You're doing it wrong.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all,
On VS2005, I've add a background image on a form, fine. But when I added a label cannot see the image through it. How can I see the image through the label?
Thanks a lot.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Make the background color of the label transparent ? The other way is to draw the text on the form yourself.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
CodingLover wrote: How can I see the image through the label?
set the Backcolor for the label to: Transparent
label.Backcolor = Transparent
|
|
|
|
|
You set the label to transparent, However be aware that there is no true transparency in .net which means that transparent shows the background image and not the image underneathe.
|
|
|
|
|
I am using AxWebBrowser control on windows form. I want to handle the shortcut paste(ctrl + V) event so that i can excute my own customised function to perform this operation.
I tried this as following:
private void editorWebBrowser_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyData == (Keys)Shortcut.CtrlV)
{
MyTextPasteFunction();
}
base.OnPreviewKeyDown(e);
}
But it is not stopping executing it's default paste event. So Ctrl + V is pasting the contents twice.
What should i do to stop the default paste event execution?
Thanks in Advance.
|
|
|
|
|
You could always inject an onpaste handler in the webpage immediately after it has been loaded.
"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
|
|
|
|
|
To elaborate further ,i am working on Content management system and I have embedded the AxWebBrowserControl on Windows form.
|
|
|
|