|
The only problem I see is your approach, if one of the 2 handlers is null, no event is fired. But that may be the intended behavior. If this is the case, that may confuse other parts of the application expecting to be notified of one event, but are not because nobody subscribed to the other one.
If this is the intended behavior, simply make one event: OnQResponseAndDataRecvd.
if ((segType == "Y") && (OnQResponseAndDataRecvd != null))
{
OnQResponseAndDataRecvd(this, EventArgs.Empty);
}
If you need 2 separate events:
if (segType == "Y")
{
if (OnQResponse != null) OnQResponse(this, EventArgs.Empty);
if (OnDataRecvd != null) OnDataRecvd(this, EventArgs.Empty);
}
You may also notice the use of EventArgs.Empty instead of new EventArgs() . Basically, EventArgs is a class that contains no information, and this way you avoid creating unnecessary new objects.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 13:23 Wednesday 25th January, 2006
|
|
|
|
|
If you mean that the code handling the two events should execute at the same time, then no.
An event is basically a list of method pointers. When you call the event, it will just call the methods in the list one after the other. That means that when you call OnQResponse, it will not return until all event handlers in it has been executed.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks,
I saw that. I guess there is no way to create a delegate that will fire two at the same time?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
If you want the delegates to run asynchronously (the closest to firing them at the same time), look for the BeginInvoke[^] method.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello everybody.
Does anybody knows a way of changing the color of some words (reserved words) of a code editor using a VS 2003 add-in?
So for some kinds of files, I would like to highlight some words and symbols, check syntax, etc.
I know how to access the TextDocument object that represents the editor, but I don' know which one of its properties should be used to change the color of a portion of text. Any pointers to information on this will be warmly welcome.
Thanks
Omar
|
|
|
|
|
How can I update selected row from gridview.
|
|
|
|
|
Do you think it is possible to give you anything like a decent answer to your question when you have provided so little information on what you want?
The best I can personally do is provide a link to the RowUpdatingEventArgs object[^]
-- modified at 10:52 Wednesday 25th January, 2006
|
|
|
|
|
I have one gridview in my webform and i added Command field which includ (edit,select,update,cancel, events) when i click edit commandfield then i do some changes in selected row and trying to update that changes from gridview.
all what i need is how can i update changes in gridview1_RowUpdating Event
I hope i was little bit more clear in my question
|
|
|
|
|
I need to send message from my computer to another with NetMessageBufferSend function. Everything works fine when i'm sending to a computer on the same domain as mine. The problem is that i need to send a message to computer in another domain. Does anyone have experience with this? Any help will be appreciated.
|
|
|
|
|
Not supported. This is the function that the command line utility "NET SEND" uses, and therefore, has the same restrictions. You'll either have to change your domain configuration so the target domain trusts the senders domain (not likely to happen), convert your domain environment to Active Directory (also not likely to happen), or use a different messenging system that isn't dependent on Windows Security to work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to find some ebooks for .net 2005, i haven't master card, credit card, so i can't buy these ebooks on network, if you have, you can help me.
I need ebooks: "Microsoft sql server 2005 step by step" and "Programming microsoft visual c# 2005 core reference".
you can buy it help me or can you give me.
Thank you very much
|
|
|
|
|
These books don't come in an E-Book format and they are NOT free! It's absolutely ridiculous that your asking for them without paying anything.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Your profile says you're a student, so I'm guessing with such specific book titles, you need them for a class, but don't want to pony up the cash for buying them, and want to get them for free. Why else would you want a specific title when there are many resources for both C# and SQL Server 2005 available for free online? Anywho, code project and a myriad of other sites should have the information you need for free, but if your teacher requires that you have those specific books, your school's library probably has a couple copies that you can view/borrow.
Good luck
|
|
|
|
|
I want to create a C# console app that can change the current directory then exit. When I use System.IO.Directory.SetCurrentDirectory(@"c:\temp");, after the application closes it returns to the original subdirectory before execution. I want it to stay on the new set directory. Any ideas?
|
|
|
|
|
|
The other reply is correct. SetCurrentDirectory only affects the current directory of the process, not the command prompt that launched it. If this is all you want to do, then it's really easy without using any code:
C:> COPY CON C:\WINDOWS\GOTOTEMP.CMD
@ECHO OFF
C:
CD C:\TEMP
^Z
Now all you need to type at a command prompt is GOTOTEMP .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 10:20 Wednesday 25th January, 2006
|
|
|
|
|
My example is a simplification of what I need. The acutal C# project will have more logic to deterine correct path.
Thanks anyway.
|
|
|
|
|
probably wont help you any. But I suppose you could always have the c# code kick off another process using the cmd command. cmd /kcd c:\temp - when typed at a prompt it will create a new console cd to c:\temp. I don't know any way to change directories in the same console though and have it remain that way on termination. Of course I am still very new to C#.
Sean
|
|
|
|
|
Did you ever figure this one out?
|
|
|
|
|
Hey,
All I wanna know is how to know when the user is scrolling thats all.
Like if his mouse pointer is over my form, i wanna know when he is scrolling so that I can resize and change things.
Thanks,
|
|
|
|
|
Did you want to know when the user is rotating the mouse wheel?
Here's the solution. If your window has focus, this will work even if the mouse isn't over the window.
private const int WM_MOUSEWHEEL = 0x020A;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_MOUSEWHEEL)
{
if (m.WParam.ToInt32() > 0)
{
}
else
{
}
}
base.WndProc(ref m);
}
|
|
|
|
|
Hey Ethan,
Thanks that worked, but now I have a another question, I hope you don't mind.
I have a Panel on my form and in run time I load it with an EMF image. Now I want to zoom in and out of this panel, so I use this code:
private const int WM_MOUSEWHEEL = 0x020A;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_MOUSEWHEEL)
{
if (m.WParam.ToInt32() > 0)
{ //Mouse wheel rotated forward (away from user)
viewerPanel.Width += 10;
viewerPanel.Height += 10;
}
else
{ //Mouse wheel rotated backward (towards user)
viewerPanel.Width = viewerPanel.Width - 10;
viewerPanel.Height = viewerPanel.Height - 10;
}
}
base.WndProc(ref m);
}
How do I Zoom in/out around a specific area of the Panel, like if my cursor is over one part of the image, it must enlarge that area, not simply the whole Panel.
Many Thanks
|
|
|
|
|
If you're working with images, the ImageBox control is the best choice. However, it lacks some crucial functionality. To implement scrolling and panning, you might be interested in this article:
http://www.codeproject.com/cs/miscctrl/zoompancontrol.asp
You could start with the your own version of the scrolling picturebox control, and add the code above to it. When the mouse wheel is rolled, check the cursor position over the control. Center the image at the cursor position (using AutoScrollPosition and the related fields), and then do the zoom-in.
|
|
|
|
|
Hey Ethan,
I am using the EMF image type, and ImageList control does not support it. Got any other ideas of how to have the zoom functionality of windows picture and fax viewer in my windows forms app?
|
|
|
|
|
You could either convert the EMF image to another type, or you could use the panel to render it.
What code are you using to draw the EMF to the panel?
You could write a custom control, with two panels. One would contain the image, and the other (the parent) would provide the scrolling.
In the child-panel, paint the image depending on a 'Zoom' property.
ex.
zoom is 100%, resize the panel to the size of the image (redraw panel)
zoom is 200%, panel is twice the size of the image (redraw panel)
Then set AutoScroll to true on the parent panel. Also set AutoScrollMinSize to the size of the child panel (every time the zoom level is changed).
This article provides a good example, just substitue the PictueBox for a panel. Pay close attention to the function CenterImage .
|
|
|
|