|
Take a look at the System::Diagnostics.Process class:
Exit Notification -> Process.EnableRaisingEvents
Enumerating running processes -> Process.GetProcesses
Finding processes - > Process.GetProcessByName
Alive? -> Process.Responding
That should get you started in the right direction.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Hi! I try to create a target bitmap alike the source bitmap ( in size, in pallete). I hope the target bitmap will be created black(or 0) on every pixel. And then program generate the content of target according to the source one, if some pixel isn't be filled it will be still black.
first trial:
dst = (Bitmap)src.Clone();
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
//do some processing on BitmapData
This one work! but it seems clone waste much on copying the content. i wanna it be black, so i have to fill it 0 myself. copy and fill are useless duplicate work.
Second trial:
dst = new Bitmap(src.Width, src.Height, src.PixelFormat);
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
dst will not has the same palette as src. After the process, dst will be a color image even src is a formerly gray one.
Third one:
dst = new Bitmap(src);
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
can't execute! the second LockBits will raise error. anybody know why?
I really puzzled by these methods! any guru can explain what's on earth are these create functions doing? and what's the best way to get my aim?
|
|
|
|
|
novachen wrote:
can't execute! the second LockBits will raise error. anybody know why?
It appears that dst and src might be the same instance, and thus cannot be locked twice. My guess
Unfortunately I cant help you with the others...
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
How to add my componet in to VS.NET (like that Visual Assist)??
Someone can help me, please!!!
Thanks
|
|
|
|
|
hi,
i want to know how to make a function including a parameter with default value?
somethings like this...
public void functionA(int A, int B = NULL)
{
// ...
}
any help?
thanks,
jim
|
|
|
|
|
zecodela wrote:
i want to know how to make a function including a parameter with default value?
As far as I know you can't have default parameters in managed functions.
- monrobot13
|
|
|
|
|
Indeed,
the word I've read everywhere in this regard is that you should use multiple
versions of the member. For ex:
instead of
<br />
public void myFunction(int myInt = 3)<br />
{...}<br />
you should have
<br />
public void myFunction(int myInt)<br />
{<br />
}<br />
AND
<br />
public void myFunction()<br />
{<br />
}<br />
Also, you could have one overload call the other:
<br />
public void myFunction(int myInt)<br />
{<br />
}<br />
AND
<br />
public void myFunction()<br />
{<br />
myFunction(3);<br />
}<br />
HTH,
FOR
|
|
|
|
|
Frank is almost correct. You can have functions/methods with default values in some managed languages, but not in C#. His advice on how to circumvent (what I personally see as a) shortcoming in the C# language is correct: Have overloaded versions of the method as follows:
public void foo (int a); // call third foo with default values
public void foo (int a, int b); // call third foo with default values
public void foo (int a, int b, int c);
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
public void foo (int a); // call third foo with default values
public void foo (int a, int b); // call third foo with default values
public void foo (int a, int b, int c);
OK, this is a bit picky, but shouldnt the 1st function call the second? As one would design constructor overloads?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
You're right....it's picky
Seriously, it depends on your point of view. From a code maintenance standpoint, I would agree with you. But from a performance standpoint it would mean an extra call in the code path.
Personally, I code as you mentioned because I worry more about maintenance than the incredibly small performance hit of an in-proc function-to-function call.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
|
Yep. Me too. That's why I'm slowly navigating back to MC++ for most of my development. I have done some cool C# stuff - even won a Money Magazine technical award a couple of months ago for a C# system I designed and wrote for VeriSign - but for my personal work, I choose MFC/MC++.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
But from a performance standpoint it would mean an extra call in the code path.
Doesn't the compiler take care of it?
Tom Archer wrote:
Personally, I code as you mentioned because I worry more about maintenance than the incredibly small performance hit of an in-proc function-to-function call.
Exactly.
|
|
|
|
|
Nemanja Trifunovic wrote:
Doesn't the compiler take care of it?
How do you mean? It's still a jump with the extra prolog and epilogue instructions to take care of the stack.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Yes, but since foo(a) always calls foo(a,b,c), the compiler can simply inline every call to foo(a). When you call foo (a), it can push additional two parameters on stack and call foo (a,b,c) directly.
|
|
|
|
|
I have a XML file like this:
- <Quiz Id="1" Date="24.07.2003">
- <Question Text="Question Text 1" Choice="a">
<Answer>text a1</Answer>
<Answer>text b2</Answer>
<Answer>text c3</Answer>
<Answer>text d4</Answer>
</Question>
- <Question Text="Question Text 2" Choice="b">
<Answer>text a1</Answer>
<Answer>text b2</Answer>
<Answer>text c3</Answer>
<Answer>text d4</Answer>
</Question>
</Quiz>
I want to serialize and deserialize it into a class and from that class. So my class have should have some XmlElements and XmlAttribute, But I don't know what my class should look like?
I should have XmlElement name Question, but how can I define that some attributes are for Quiz node and some for Question,and don't know about Answer node too.Because It could be for item or 3 or...
Another question is that maybe I have 3 or 4 or only 1 Question node in my XML file so how should I deal with it in my class? When I serialize it what should I concern?
Any comment is appreciated.
<html><b><FONT face="Lucida Handwriting, Cursive">Mazy
No sig. available now.
<FONT></b></html>
|
|
|
|
|
declare the class something like
[ XmlRootAttribute( ElementName = "classname" ) ]
public class classname
and look up the class XmlSerializer
it would probably be best to store the answer in an array.
pseudonym67
Neural Dot Net Articles 1-11 Start Here[^]
|
|
|
|
|
It is possible to put a tooltip on a GDI+ figure? (on mouseOver)
The tooltip1.SetToolTip() method takes in a System.WindowsForms.Control, but there is no overload for a GDI drawing ?
|
|
|
|
|
1). Declare global variables ToolTip tt; and bool installed = true;
2). Initialize tt in constructor of the form: tt = new ToolTip()
3). Override OnMouseMove :
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
if (bounds.Contains(e.X, e.Y))
{
this.Cursor = Cursors.Hand;
if (installed)
{
tt.SetToolTip(this, "Hello, r9 :o)");
installed = false;
}
}
else
{
this.Cursor = Cursors.Default;
if (!installed)
{
tt.RemoveAll();
installed = true;
}
}
base.OnMouseEnter(e);
}
"...hasn't really been well accepted ... as the ratings tell us so far " - Nishant S
|
|
|
|
|
You are genius
With all your help, I am getting better and better at understanding GDI+.
Thanks
|
|
|
|
|
Do you code a control or you just draw shape on the form?
All code examples supposed to work for the shape drawn on the form.
If you want to use examples to code a control, you should make some changes (some lines are not necessary and some things should be coded in other way).
"...hasn't really been well accepted ... as the ratings tell us so far " - Nishant S
|
|
|
|
|
I have a pictureBox on my Form.
Then I use the graphics object from the PictureBox_paint event:
..
graphicsObj = e.Graphics;
..
|
|
|
|
|
how to add myButton into toolbar of VS.NET
Nho'c ti`
|
|
|
|
|
toolbar.Buttons.Add(new ToolBarButton());
toolbar is the name of your class instance.
Hope this helps.
jesse m
The Code Project Is Your Friend...
|
|
|
|
|
Is there any way to create supplemental image encoders/decoders for GDI+? I'm assuming there must be, but I really haven't seen anything on this, not even on MSDN.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|