|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Still don't know why this happens but it doesn't matter. I found that setting my control
to DoubleBuffered = true, the display time goes to 0.
Sorry for the post.
Can some tell me why displaying the transparent pixel takes so much time?
See bottom of sample for time comparison.
public class CellColor
{
public Rectangle Rect;
public Color Color;
public CellColor(Rectangle rect, Color clr)
{
Rect = rect;
Color = clr;
}
}
// At form load time, this array is loaded with pixel data from a 32 x 32 Icon.
// About half of the pixels in the sample icon are transparent (A=0,R=255,G=255,B=255).
private CellColor[,]? _CellBounds;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawCells(e.Graphics);
}
private void DrawCells(Graphics gr)
{
int iWd = this._CellBounds!.GetUpperBound(0) + 1;
int iHt = this._CellBounds.GetUpperBound(1) + 1;
Stopwatch sw = new();
sw.Start();
for (int iRow = 0; iRow < iHt; iRow++)
{
for (int iCol = 0; iCol < iWd; iCol++)
{
CellColor cc = this._CellBounds[iRow, iCol];
using(SolidBrush br = new(cc.Color))
{
gr.FillRectangle(br, cc.Rect);
}
}
}
sw.Stop();
// Displaying the data without pixel modification takes about 60 milliseconds.
// When loading _CellBounds, if I replace the transparent pixel with a real color like Color.White,
// this loop takes 4 milliseconds.
DebugClass.WriteLine(string.Format("{0}", sw.ElapsedMilliseconds));
}
-- modified 3hrs 20mins ago.
|
|
|
|
|
I'm programming using WinForms in C# .NET 2.0 and sometimes I want to disable the entire GUI so that the user can't e.g. press any buttons or change any comboboxes. I found this through googling Disable form Controls Without Being Gray!!![^] and I thought it was working great, until today. Whenever USB-cables are connected/disconnected on my PC, I get an event and then I disable the GUI, using the code I linked to above, and re-enumerate my virtual COM-ports and then I enable the GUI again. I discovered that executing this.Controls.Add(alphapanel); takes almost 2 seconds and executing alphapanel.BringToFront(); takes another second! Is there anything I can do to speed this up?
|
|
|
|
|
You should monitor the individual connections so you don't have to drop and reconnect "everything". You wouldn't drop things in a mission critical app and you should treat all apps as if they were (IMO).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I don't disconnect anything, I just ask the Device Manager what Com ports are present and then I compare that with what was present before and take appropriate actions (e.g. remove or add Com port from a combobox). But this is not what's taking so long, it's the AlphaPanel handling that takes time.
|
|
|
|
|
If the GUI is slow, it means you should be doing this "AlphaPanel handling" in the background.
BackgroundWorker Class (System.ComponentModel) | Microsoft Learn
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
{
Can anyone help with c# source code or directive on how to achieve the subject?
}
|
|
|
|
|
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Normally, when I am looking to write a task or application, I start off by listing the high level requirements and objectives that I need to satisfy to create it. You say you want to create an appraisal system, so what does that involve? Are you looking to appraise people? Is it antiques appraisal? What criteria are you going to use to perform the appraisals? Work out what your requirements are, and keep refining them. Doing this should leave you able to create your application.
|
|
|
|
|
I'll help you; you don't need a coat. Out.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
{
a performance appraisal application
}
|
|
|
|
|
Since you haven't asked a question, I can only assume this is a demand for a complete app you can hand in as your own.
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Can I use the same background process for all forms in visual studio c#?
If it possible, how is it done?
|
|
|
|
|
What does that even mean?
|
|
|
|
|
Using concurrent collections.
Thread-Safe Collections | Microsoft Learn
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 14055879 wrote: same background process for all forms
Just guessing and a question that is not specific enough...
No.
A windows "background process" is one that does not have a UI and thus would not have "forms"
(Also wondering if this same question was asked a long time ago on this site?)
|
|
|
|
|
Look Ma: field name duplication: no new, no overrides, no crash ...
public class stuff1
{
public const int somenumber = 42;
}
public class stuff2 : stuff1
{
public int getconst()
{
return somenumber;
}
public const int somenumber = 45;
}
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
I get a warning:
'stuff2.somenumber' hides inherited member 'stuff1.somenumber'. Use the new keyword if hiding was intended. And since I always run with "Treat warnings as errors" enabled, my code wouldn't compile without that being dealt with.
Check your Error pane settings - you may have warnings hidden.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Interesting, thanks; I'm using VS Version 17.4.4; I'm not seeing amy warnings/messages in Error window at either build time or run-time.
I eyeball the myriad 'Options for VS/Debugging, and it looks like everything is enabled that would catch any error, etc.
Ahhh ... one Googling later ... I did not have the 'Build + Intellisense' filter option set in the Error Window, but, I still build and run with no exception thrown.
Yes, I do see CS108 which mentions using 'new.
I have checked all the options the Break On Errors TreeView.
p.s. note that without the 'new modifier the call in 'stuff2 is accessing the const vale defined in'dtuff2: #45
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
You should at least see a squiggly underline unless you have them turned off. They're annoying, but I leave them on as they are handy...
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
I see demons, but, not squiggles My impaired eyes are giving out for today, but, I note the apparent absence of 'show squiggles' in Tools/Options/C#/Advanced ... while /...C/C+ still has it.
Will look again, tomorrow.
thanks, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Yes, that's what the warning is there for: to make sure you are doing what you intended, not accidentally hiding the original.
You don't get any exception because it is legal: it's a compile time problem only (and because it's a warning, it assumes the new for you).
Try going to your project properties, "Build" tab, and selecting "Treat warnings as error" to "All" - that should cause a compiler problem with that code.
My default new project includes that setting!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Try going to your project properties, "Build" tab, and selecting "Treat warnings as error" to "All"
::::::::: :::::::: :::::::: :::: :::: :::
:+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ :+:
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+
+#++:++#+ +#+ +:+ +#+ +:+ +#+ +:+ +#+ +#+
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+#
######### ######## ######## ### ### ###
😂🎉
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|