|
Hmm. Well, being a noob with GDI (or anything more complicated than FillRectangle)...I really shouldn't argue a point, but...
If I keep it;
I get to use it during the search method which scans a text source for a result and then draws a message to the screen.
I get to update the image at will, without needing to re-get the Graphics object.
I mean, it's based on the same Image which is updated on the resize event, but the Graphics object is recreated just after that for the new Image.
Like I said, I have typically, 1GB of RAM spare on my dev machine and almost 600MB, I think, on the target machine. A few Graphics objects won't kill the system. OK, if the core part of Windows runs out of memory then, oops, but I haven't hit that eventuality yet.
As for slowing down, my dev machine, 2.6GHz Core2Duo Intel with a Radeon 2600 Pro, draws a typical screen (measured inaccurately using Environment.TickCount) in 31 or 46 "Ticks". Slow code, eh.
My 2GHz AMD Athlon which is about 4 years old, has DDR and not DDR2 RAM, and a Radeon 9200 using AGP and not PCI-E...can draw exactly the same screen completing in either 0 or 15 "ticks".
Pretty new system, compared with 4 year old technology that sits in a cold room for weeks at a time. The only thing I can think of is the old machine has very little more than XP, .NET 2, and DirectX. The new machine has a fair bit more on it but not enough for a 3x slowdown.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I have this code that is showing a least 24 pictures, i just posted the code for 6, however i would like to know how to add an event for each one instead of one for all of them.
I considered doing:
P.Click += new EventHandler(cantPictures); which will have me to code a least 24 different events, but i don't know if that would be wise to do or if there is a more effiecient way to do it.
void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
int totalPics = loading.cant();
while (cantPictures < totalPics)
{
PictureBox P = new PictureBox();
Bitmap imag;
if(cantPictures <= 5)
{
if (cantPictures == 0)
{
imag = new Bitmap(images[cantPictures]);
P.Image = imag;
P.Click += new EventHandler(P_Click);
P.Size = new Size(150,150);
P.SizeMode = PictureBoxSizeMode.StretchImage;
P.Location = new Point(35, 10);
constante = 35 + P.Size.Width+10;
this.Controls.Add(P);
}
else
{
imag = new Bitmap(images[cantPictures]);
P.Image = imag;
P.Click += new EventHandler(P_Click);
P.Size = new Size(150, 150);
P.SizeMode = PictureBoxSizeMode.StretchImage;
P.Location = new Point( constante, 10);
constante += 10 + P.Size.Width;
this.Controls.Add(P);
}
}
Sorry, i just reply part of this message to one person in the forum but i thought i hit email instead...
Best regards...
Luis E Tineo S
|
|
|
|
|
Hi,
most, if not all, event handlers get as a first argument "object sender" which will
hold the Control that fired, so if all your P_Click delegates are connected to PictureBoxes,
just cast sender to PictureBox and you know which one got clicked...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Uhmm... But how can i tell which image fired up the event? I am using the same picture box to draw the images in the form... would be comparing the image from the picture box with the array of images i have???
If not would you mind writting a simple example of how to do it please?
Thanks!
Luis E Tineo S
|
|
|
|
|
kingletas wrote: I am using the same picture box to draw the images in the form
I do not agree. You have a while loop in which you do P=new PictureBox() ,
so yes the variable P is used over and over, but it is a new PictureBox on every iteration
of the loop.
object sender can be cast to PictureBox, it will point to the one PictureBox that you clicked,
and if you get it's Image property, you have a reference to the Image you clicked.
So you don't need a separate collection to get this working properly.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: kingletas wrote:
I am using the same picture box to draw the images in the form
You are completely right about this, i just said it wrong. I meant it how could id the picturebox if i was using the same variable all the time...
I think i do know now how to do it .... thanks a lot... I wouldn't have done it without you!
Luis E Tineo S
|
|
|
|
|
Hello,
I am using C#.net to create a win app. I need to import extreamly large files into a SQL server database? I was wondering what is the best way to go about it. I have used SqlBulkCopy althought it is fast it times out before the import is complete due to the size of the file. I am also in the process of trying a split import with SqlBulkCopy (If I have a file that is 10 records I would import the first 5 and then import the next 5). Am I on the right track?
Any suggestions would be great.
Thanks
j
|
|
|
|
|
Thanks I am going to check it out!
|
|
|
|
|
I have sql query in C#
SELECT Last_Date
FROM MYTABLE
WHERE Last_Date > CONVERT(DATETIME, '13.11.2007 22:43:50', 103)
Note: Last_Date column data type is datetime
Example; If my Last_Date column like this
13.11.2007 22:43:49
13.11.2007 22:43:50
13.11.2007 22:43:51
So this query return this values
13.11.2007 22:43:50
13.11.2007 22:43:51
If I change ">" operator to ">=" operator, result is same. How can I eleminate "13.11.2007 22:43:50" value? I want to get greater than (">") values.
Thanks..
|
|
|
|
|
There is a micro second component, I believe. Try 22:43:50.999
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes, its true. I know but how can I solve my problem. I think this is related about style code "103". But I don't know which style code is correct my problem. I search but I can't find.
|
|
|
|
|
First of all what u need to do AFAIK is to split the datetime into three parts lik date,time and am/pm. then put the checking.this will fetch u the xact result.
Cheers
Bino
www.codepal.co.nr
|
|
|
|
|
Hello,
How can I make a button's backgroundimage enabled when I clicked the button.
Normally, I wrote, button1.bacgroundimage=null; There is button's background image, firstly, I want not to show, after clicking I want to show this background image.
|
|
|
|
|
Thanks for quick reply,
but, in design page, I gave one image as button's background image in properties after that when i clicking to button, i want to see this backgroundimage.(i am beginner in programming)
|
|
|
|
|
Thanks so much for your answers.
I can make now.
|
|
|
|
|
I need to do the following automatically.
1. Detect when or if a pocket PC is connected via USB
2. If connected, search for a specific xml file on the pocket PC
3. Copy the file to the desktop hard drive
4. Delete the file from the pocket PC
Any help or pointers to get me started would be great!
|
|
|
|
|
|
Many thanks! Seems to be just what I need to get started.
|
|
|
|
|
Hi,
In a dataGridView, I can Load data from single table of DB and save back the changes to DB using SqlDataAdapter,DataTable,SqlCommandBuilder (for auto generate of Insert,Update,Delete statements).
Now this don't work on View (Join and nested query), that data gets from multi Tables.
How can I do this to this operation done on Multi Tables?
Best wishes
|
|
|
|
|
Wouldn't a neat and cool stored procedure that handles the Insert/Update/Deletes be more cool, elegant and robust, since you particularly mentioned about multi tables?
|
|
|
|
|
Hi All
I have a problem. I have a field that holds a country code and a combobox that has a list of of all countries. I would like to search for the country code from the combo box list of countries, get its index and display it in the combo box as the default item.
Any suggestions will be greatly appreciated.
Thanks
|
|
|
|
|
Does this help?
int nIndex = combo.FindString (field.Text);
if (nIndex != -1) {
combo.SelectedIndex = nIndex;
combo.Text = combo.SelectedItem.ToString();
} /ravi
|
|
|
|
|
Thanks Ravi it worked
Below is the final code:
private void pnlDriverAddress_Enter(object sender, EventArgs e)
{
if (Mode == eMode.Add || Mode == eMode.Edit)
{
if (cmbDACountry.SelectedIndex == -1)
{
int nIndex = cmbDACountry.FindString(MDI.Country.ToString());
if (nIndex != -1)
{
cmbDACountry.SelectedIndex = nIndex;
cmbDACountry.Text = cmbDACountry.SelectedItem.ToString();
}
}
}
}
|
|
|
|
|
Hello everyone,
I have a WebBrowser control in my Windows Application. If I am not mistaken the WebBrowser control is just the parsing engine of the browser.
I would like to transform the WebBrowser control into a full-fledged browser like Microsoft® Internet Explorer, and like to add a custom tool bar with new feateures (buttons) for the custom built tool bar. If I am not mistaken that sould be done using Browser Helper Objects (BHO).
I was wondering if anyone canbe kind enough to point me to the right direction for this project.
Thank you very much and have a great day.
Khoramdin
|
|
|
|