|
I would like to display each line as the console app is running, the ReadLine method seems to work, but I recieved only one line, the ReadToEnd method waits until the console app ended to display its results.
Any suggestion?
|
|
|
|
|
Description
I'm trying to process a KeyPressed event on a form
sent to my user control. After the processing of
the event, I want to send the keystock to a textbox
on the form.
I can ,of course, access the text property of the
text box but I wanted to know how can I do it in
another way.
Question
How can I access the text box and give it the keystrock
as if it has the focus and I only pressed a key on the form.
I understand that when a form get a key, it looks for
the control with the focus and send him the key, or event.
How can I emulate that, so I can send a key after I processed
it, to other control or controls?
|
|
|
|
|
You'll need to use PInvoke and use SendMessage[^] to send the TextBox a WM_CHAR[^] message
[DllImport("User32.dll")]<br />
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);<br />
<br />
public void SendTextBoxKeyPress()<br />
{<br />
SendMessage(textbox.Handle, 0x0102 , (int) Keys.Enter, 0);<br />
}
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
is it a fantasy?
If it is not possible how about getting the Width or X,Y coordinates of the notification area (systray) ?
|
|
|
|
|
You don't need to P/Invoke win32 APIs to get this to work. The NotifyIcon component provides a MouseDown and MouseUp event which you could handle, and that provides your X and Y coordinates through the MouseEventHandler . You could, in one example, cache the X and Y coordinates when the mouse is clicked down on the systray icon and when the Click event fires you can retrieve that. An example is shown below. You could also coordinate your own client event handler, but this requires extra code that would not be necessary.
notifyIcon1.MouseDown += new MouseEventHandler(notifyIcon1_MouseDown);
notifyIcon1.Click += new EventHandler(notifyIcon1_Click);
Point p;
private void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
{
p = new Point(e.X, e.Y);
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
MessageBox.Show(string.Format("The user clicked at {0} within the icon.", p));
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath, that is nice. But what if the user does not click on the notifyicon? I need to know the location even if the icon is not clicked. Can I emulate/simulate a click?
I am also interested in finding a way to get the width and location of the entire systray (aka notification tray) area. I am trying to emulate the behavior of Windows Messenger when it is closed. You will see how it "animates" the close, thus showing the user that the window is actually being minimized to the systray.
Thanks again, Tom.
|
|
|
|
|
You'll need to register a hook into the Windows system message loop. Your application - without using a hook or some sort of inter-process communication (IPC) - will only receive events that occur within the main application or child windows (including controls, which are child windows).
See Global System Hooks in .NET[^] for a good article that describes how to register hooks and that includes sample code.
If you want to find articles on Messenger-style notification windows, search for "messenger[^]", for example, on this site. You'll find several good articles and sample code.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Use the hook to simulate a mouse click on the systray icon?
Or use a hook to get the width of the entire systray?. I read the article and cannot turn up how to do either of these tasks. Please advise. Thanks for your help so far.
|
|
|
|
|
From your previous post:But what if the user does not click on the notifyicon? I need to know the location even if the icon is not clicked. Can I emulate/simulate a click? The first two sentances do not agree with the concept of the third. The hook is to register yourself to receive notification when a user clicks outside of your client area. If you want to simulate a click, the easiest way is to simply call your Click event handler, or the method that contains the code you want done when a user clicks your icon.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm a binger,I has three question.
1.How to do a abnormity form,I know draw it in region,but the performance is poor,there are better method?
2.In richtextbox control,how to display highlight keywords and linenumber?
thanks.
|
|
|
|
|
I hate repeating myself. From your first post:
1) I have no idea what you mean by an "abnormity form"...
You might want to explain what you mean by this.
3) Look at the SelectionStart , SelectionLength , and SelectionColor properties.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am working on a C# project that looks for words in a text file.
The current design is that my RegEx will need to be called 3 times to search for 3 different patterns:
\bWord1\b then \bWord2\b followed by \bWord3\b
Is there any OR operator that will allow me to specify all 3 words in a single RegEx pattern?
|
|
|
|
|
|
I recommend that you read about Regular Expressions[^] in the .NET Framework SDK.
You really don't need to search 3 times, if I understand your logic correctly. You just need to find Word1, Word2, and Word3 one after another:
Regex re = new Regex(@"\bWord1\b.*\bWord2\b.*\bWord3\b");
Match m = re.Match("This is a sentence with Word1, then Word2, and followed by Word3.");
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I would like to exercise the article "Your first C# Web Service", By Chris Maunder.
I am using XP and I have IIS turned on. When I try to create a Web Service via the Microsoft Visual Studio .Net 2003 I get the error.
‘Visual Studio cannot create or open the application because the Web server on this computer is not running. Start the Web Server before proceeding.’
The directions under the help button direct me to
‘On the Web server computer, open Control Panel and then choose Internet Services Manager.’
I do not have an option labeled ‘Internet Services Manager’. I have downloaded the Microsoft .NET Framework 1.1 plus its patches.
Does creating a Web Service require me to run Windows 2003 Server or something like that?
Thanks
|
|
|
|
|
Look under Administrative Tools in Control Panel, or just open a command prompt and type:
net start w3svc
Good luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank you.
This command results in a system error 1717.
I did attempt all the suggestions in the MSDN Help. I think I am missing a Windows Component, but I am not sure what or how to get it.
thanks
|
|
|
|
|
If this ain't too late.. goto add remove components in control panel and install IIS.. then ul find it in Admin tools in control panel
|
|
|
|
|
|
Try this one.
Response.Write("" +
"'www.codeproject.com','','toolbar=no,location=no,directories=no'); " +
"<" + "/" + "script" + ">" );
Dabuskol
|
|
|
|
|
You should really consider using Page.RegisterClientScriptBlock or Page.RegisterStartupScript to write to the beginning or end of the document (the page <form> , actually), respectively. This allows you to specify a key so that the script is not written more than once (which, depending on what you do, can lead to script errors). This is especially handy when designing controls that need to generate script in their containing page and you can't be sure just how many a user might add to their page.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you. I tried to use the Page.RegisterClientScriptBlock or Page.RegisterStartupScript and it works the same. I changed my codes already.
/Dabuskol
|
|
|
|
|
It doesn't actually work the same in that you can key a particular script block so that it only gets written once. If you simply use Response.Write (or something similar) than you'll have trouble knowing programmatically if you already wrote it, especially when your controls are contained within a page.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi folks,
Do u guys know how to write a piece of code to check if a user has full access to a shared directory?
Thanks a bunch,
|
|
|
|
|
The simplest way is to just try to write to the directory. Checking the actual access control list (ACL) isn't necessary and does add complexity to your code. And until .NET 2.0 adds easy object-oriented support for ACLs, either you have to rely on what few (rather bad, IMO) implementations exist for .NET 1.0 or 1.1 or write your own.
A simple example follows:
try
{
using (FileStream file = File.Create("\\computer\share\test.dat"))
{
test.WriteByte((byte)1);
}
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("You do not have the necessary access.", "Access Denied");
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|