|
Hi,
I am trying to write an windows application which needs to capture the text selected from other applications as well.
I would like to know how we can capture a text that gets selected when we double click on the mouse. When any text is selected in any of the applications (not only the application that i use to capture the Text value), i need to capture the text. For example when we select a text in the notepad, and double click the mouse on the application that i have created, then the text selected in the Notepad should be captured and displayed in my application. Is there a way to do this ...
Thanks in advance
CSharpbeginer
|
|
|
|
|
There's a windows API called WindowFromPoint. If you p/invoke that, you can call GetWindowText ( another p/invoke ) to get the text of the window your mouse is under. How far that will get you, I don't know.
It's odd to me, I know of no commercial software that does this, but it gets asked for so often.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Everyone,
I have some problem with override of background in an TextBox.
The text don't merge with background, lock at code below.
Many thanks in advance.
/Gywox
<br />
using System;<br />
using System.Drawing;<br />
using System.Drawing.Drawing2D;<br />
using System.Globalization;<br />
<br />
namespace System.Windows.Forms<br />
{<br />
public class TextBoxDate : TextBox<br />
{<br />
private DateTime date;<br />
private CultureInfo culture = CultureInfo.CurrentCulture;<br />
private bool validDate = false;<br />
private Brush backgroundBrush = new SolidBrush(SystemColors.Control);<br />
<br />
public TextBoxDate()<br />
{<br />
this.SetStyle(ControlStyles.UserPaint, true);<br />
this.backgroundBrush = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(255, 128, 128), this.BackColor);<br />
}<br />
<br />
public CultureInfo Culture<br />
{<br />
get<br />
{<br />
return this.culture;<br />
}<br />
set<br />
{<br />
this.culture = value;<br />
}<br />
}<br />
<br />
public DateTime DateTime<br />
{<br />
get<br />
{<br />
return new DateTime(this.date.Year, this.date.Month, this.date.Day, this.culture.Calendar);<br />
}<br />
}<br />
<br />
protected override void OnTextChanged(EventArgs e)<br />
{<br />
base.OnTextChanged(e);<br />
Parse();<br />
}<br />
<br />
protected override void OnLeave(EventArgs e)<br />
{<br />
base.OnLeave(e);<br />
if (this.Text != string.Empty && this.validDate)<br />
{<br />
this.Text = this.DateTime.ToString(this.culture.DateTimeFormat.ShortDatePattern, this.culture);<br />
}<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground(pevent);<br />
if (this.Text != string.Empty)<br />
{<br />
if (!this.validDate)<br />
{<br />
pevent.Graphics.FillRectangle(this.backgroundBrush, this.ClientRectangle);<br />
}<br />
}<br />
}<br />
<br />
private void Parse()<br />
{<br />
DateTime resultDate;<br />
<br />
this.validDate = false;<br />
if (DateTime.TryParse(this.Text, this.culture, DateTimeStyles.AllowWhiteSpaces, out resultDate))<br />
{<br />
this.date = resultDate;<br />
this.validDate = true;<br />
}<br />
this.Invalidate();<br />
}<br />
}<br />
}
|
|
|
|
|
A textbox is a very nasty control. It draws itself outside it's paint message, so it's very hard to change how it looks.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i want to list all Computer Name, and Ip Address for the Domin "WLINKTECH". i use the following code but get an error like this, so plz help me about the problem.
--------------------
using System;
using System.DirectoryServices;
namespace IPAddressof_RemoteComputer
{
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public void getIpCName()
{
DirectoryEntry entry = new DirectoryEntry("LDAP://wlinktech");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=computer)");
Console.WriteLine("Listing of computers in the Active Directory");
Console.WriteLine("============================================");
foreach(SearchResult resEnt in mySearcher.FindAll())
{
Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString()); }
Console.WriteLine("=========== End of Listing =============");
}
}
}
---------------
Error like this
------------------
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.directoryservices.dll
Additional information: The server is not operational
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
Hi Sanjit.rajbanshi,
I have tested your code in Window Application (C#) after changing my AD name (sync.net). It's working fine. I have no problem with it. maybe. you are getting this error cuz you dont have the permission or you might put wrong AD name.
If your application is web application then you need to impersonate ur account.
|
|
|
|
|
I am using Client-server Architeture for my c#.net Window base Application.
For that I am using TCP Remoting.
How can I preserve Connection object?
means Only once Connection will establish while log in.and it will available
me through life time of application.
Hallo
|
|
|
|
|
Singleton Pattern?
Been a while since I learned about it, but as I remember, it does the trick
|
|
|
|
|
Hello,
May be you can try to store that object using binary serialization and use it any time you want.
This is just one idea I want to share with you.
nishu
|
|
|
|
|
It's dangerous to assume that the connection will always be there throughout the life of your application. What happens if the machine at the other end is restarted? Your connection is no longer valid, and operations on it will fail.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all
I am working in c#.net
in my project i need create report using dynamic sql (i.e. parameter is passed at run time )
e.g
select * from employee where m_month = "runtimepara1" and m_year= "runtimepara2"
can anyone help me
thanks for your time
|
|
|
|
|
Build your query like this:
string sql = "SELECT * FROM Employee WHERE m_month = @month AND m_year = @year";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.Parameters.Add("@month", theMonth);
cmd.Parameters.Add("@year", theYear);
Also, SELECT * is inefficient. You should specify the columns that you want to return.
|
|
|
|
|
But I think it's used in Crystal ReportGeneration
i USED Reportviewer control in C#.net(InBuild not Crystal report)
Is their are solution to pass parameter dynamically or same Solu is also used
plz reply me
Thank's
|
|
|
|
|
The example you were given, shows you how to pass parameters dynamically. Or, do you mean, pass which parameters to select, dynamically ? In that case, if you're building SQL, you just need to conditionally add the columns you want.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all!
I want to change the height of a combobox in flat style, but I can't, Visual Studio 2005 resets the value back on a value depending on the used font size.
On a TextBox I can change the height (when property Multiline is false)
Has anybody an idea how I can afford this problem easily?
Thanks a lot
Jörg
|
|
|
|
|
Why you want a higher combobox?
You can create a new custom control... You have to put inside a Panel (with black borders), and inside the panel a combobox(properly aligned), and set no borders in the combo... Obviously, the background color of the panel and the combo has to be same. If you don't wanna to write a lot of properties, directly put only one property of type combobox(the combo) to access it from the form.
|
|
|
|
|
I want to reduce the height of the combobox, so that they are in the same style as my other controls.
I solved it with a user control. I put a textbox with a button on the right side over a hidden combobox. When I click on the button, the item list of the combobox is shown and I can choos an Item. When the Item is selected, the value is written in the textbox and the itemlist is hidden.
But I was looking for a way to avoid a user control, and use the system controls.
|
|
|
|
|
Hy guys,
I am trying to develop a lighting control application. I know that there are a lot out there but I like programming and I like lighting equipment.
But I want to put my command controlling to my controller in a second app to get the load off my UI. Does anyone know how to do something like this. The command controller app needs to expose events and data.
I hope someone can give me a hint or something.
-- modified at 6:53 Tuesday 13th February, 2007
|
|
|
|
|
I'd use some preferences file or registry to store some arguments for another app.
Use first one to process.start(app2);
Or even create a service that will handle it, while managing preferences file/registry with gui app1.
|
|
|
|
|
How can you create a service and how does is work. Do you know a good article about it or something? Or example?
|
|
|
|
|
This is a nice msdn walkthrough of creating and running windows services:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjwlkWalkthroughCreatingWindowsServiceApplicationInComponentDesignerWithVisualJ.asp
As for controling another process:
Process[] proc = Process.GetProcessesByName("explorer");
foreach (Process pr in proc)
{ pr.Kill();}
this code would stop all explorer instances... and so on
This one would start your app2:
Process.Start("C:\\Path_to_your_app2\\app2.exe");
and eventually kill it:
Process[] proc = Process.GetProcessesByName("app2");
foreach (Process pr in proc)
{ pr.Kill();}
good luck and have fun.
P.S. forgot to mention you nedd System.Diagnostics for this to work
|
|
|
|
|
Thanks for the input. I will look at it.
|
|
|
|
|
What you really want to do, is get a thread doing all your hardcore work, apart from your main thread, which will handle the UI
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You totaly get it. Like a working thread. But I thought it would be better to put it in a seperate app. Maybe I can just start a thread and invoke my events from that and do it that way.
The worker thread send tcp messages almost 20 times a second to the dmx controller. At least that is the rate the controller updates. I have to get his state back and I get his state by requesting it.
Maybe I have to do it a different way.
|
|
|
|
|
If you're worried about the load on your UI, you should really remove the actual implementation into a separate worker thread. In windows forms, it's best practice to use the UI for what it is, and have the actual event handlers validate the data before sending the actual processing to another thread.
Remoting would be a good way to move your load off to another application, but if you need "events", you're in for a seriously rough learning curve.
Kay Lee
-Just your average coder
|
|
|
|