|
Woopsie
Thanks.
|
|
|
|
|
Here's how I'd do it using drawString (it may not be the prettiest solution in the world, but never the less):
Keep a collection (an array, a list, whatever) of the strings that are being displayed, as well as the coordinates that they're kept at.
Then, in the onPaint method (I assume that's where you've been drawing the strings), make it run through that list every time drawing the strings at their repective coordinates.
Then I'd use the mouse event handlers for the picture, take the coordinates of the mouse pointer and find what string is underneath the pointer. (This might take a bit to get right - you'll have to find some way of determining the length of a string in pixels). Then just update the string's coordinates in the collection.
P.S. Sorry if I mis-understood the problem, or if my solution sucked.
|
|
|
|
|
hi,
i want to know if the "ENTER" key is pressed or the "Escape" key, to make some acion. This should take place when the cursor is inside a text box.
Best regards.
***LET THE BEST MAN WINS***
|
|
|
|
|
Take a look at the TextBox.KeyDown , TextBox.KeyPress and TextBox.KeyUp events
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I tried using those events button i didn't know how to write a condition to know if the "ENTER" or "ESCAPE" buttons are pressed.
Best regards
|
|
|
|
|
You have to evaluate the xxEventArgs object that is passed into the event handler.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Use TextBox.KeyDown event where you will get KeyeventArgs.
You can compare e.key ot keys enumeration.
|
|
|
|
|
I also tried this but it is not working
it is making me go mad.
thanks
|
|
|
|
|
In key down event
if (e.KeyCode == Keys.Enter)
MessageBox.Show("KeyDown : Enter Pressed");
In key press event
if (e.KeyCode == (char)Keys.Enter)
MessageBox.Show("KeyPress : Enter Pressed");
This should perfectly work.
If not at ur end, pls show ur code..
|
|
|
|
|
this is the same code that i tried and it did't work
it is ok.
i will see what i can do.
Can it be not working because i set the AcceptAction property of the frame to a certaing button?
this could be it.
i will try it.
thanks
|
|
|
|
|
ok i found it.
The problem was the one i described in the earlier post.
it is that i set the acceptButton property to a certain button of the frame
that disabled the keyDown event to know when the Enter is pressed
thanks for your replies
best regards
|
|
|
|
|
Hi,
I need to write an application that logs when a user opens/runs or activates an application in C#. Any Windows API that can handle that?
Thanks
Eka
|
|
|
|
|
I'm not sure how you would check when an applications gets focus or whatever, but you can create an array and store in it each process that is running, then check it against currently running process in a few seconds and update it, and repeat.
That would give you a log of what processes are being run. You can also probably get the window title as well.
|
|
|
|
|
Yes there is. In windows system there is something called WinEvents . Pretty much like C# events. These are system messages sent to whomever is interested in receiving them. You declare yourself interested in receiving a certain message by registering a hook to that message -aka WinEvent-.
Anyway. Here is the sum up:
Event to hook: EVENT_SYSTEM_FOREGROUND . Click here for more events[^].
Hook function: SetWinEventHook()
Click here for an example[^]
Regards
|
|
|
|
|
Having solved the original problem I have now run into more threading problems. When i fire an event in my bindable list i get the dreaded "cross-threaded operation..." error. No problem i thought, i'll cast the target to control and invoke against that, that'll work. I then discover that the target is of type CurrencyManager and does not have an invoke method.
How can i raise an event back to the currency manager on the thread that the control it is managing was created on?
Thanks Russell.
My early morning sleepy post is below
------------------------------------------------------------------------------------------------
Hi guys,
I've got a datagridview in my application which is bound to an IBindableList which i have built to implement sorting filtering etc. I've mad some changes to the events within my app to make sure that the background threads execute in the right order and now i only have blank rows in my grid. When i select a filter criteria the right number of lines are displayed in the grid but they are all empty. I've inspected the underlying collection and the data are all correct. The grid i requesting the objects from the collection when i would expect it to. I've placed breakpoints in the property get code and it seems that the grid is not requesting any data.
I would greatly appreciate any help you can give.
Thanks
Russell
-- modified at 8:50 Monday 4th December, 2006
|
|
|
|
|
Managed to answer my own question as i closed the browser.
I had moved the line of code from the form constructor into an eventhandler. I've now made it invoke the code that sets the datasource and it's looking good.
Russ
|
|
|
|
|
Hi,
I have written a Windows form that I can manually Hide or Show either using a NotifyIcon or from other methods in my code.
However whatb I cannot yet do is Hide the application window when the application is first loaded.
It always displays on the screen and has to be manually hidden by the user clicking a button. After that point it, so far, can be hidden or shown as required.
I have tried setting WindowState to minimized in the FormDesigner code however it then does not always become visible when I want.
Can anyone advise what I am doing wrong?
Thanks Andrew
|
|
|
|
|
In your form's constructor:
this.Visible = false;
Then hide/show it as you like.
Regards
|
|
|
|
|
Hi Coders;)!
I wanna use somthing for adding item to the shortcut menus in the windows explorer. but I do not find true way yet for doing this stuff.
I think IshellExtInt & IContextMenu Interfaces are usefull for this. who khow how it works?
|
|
|
|
|
Hello, I am currently trying to program conway's game of life, but I am completely clueless!!!! Can someone help please?
|
|
|
|
|
|
Thanks for the link, it's great, I already understand what it's supposed to do, but I don't know how to go about implementing it.
|
|
|
|
|
Hi all,
I am using Visual Studio 2005 to develop a form based application in C#. I have a Tree Ctrl in my form and i want that all classes should know about the current seletion in tree ctrl.
Is it possible in C# to share a variable across the classes as we do in MFC through application class. We just need to refer to Application class (theApp) and we access the variable.
How it can be done in C#.
Thanks in advance.
Gajesh Mangal
Pune(India)
|
|
|
|
|
It's possible, but you should ask yourself if you want this. It's pretty clear this is going to break your MVC design, if you're using it.
class Application<br />
{<br />
private static TreeNode selectedTreeNode;<br />
<br />
public static TreeNode SelectedTreeNode<br />
{<br />
get { return selectedTreeNode; }<br />
set { selectedTreeNode = value; }<br />
}<br />
}
Assign the node from the GUI and use it from any other class.
WM.
What about weapons of mass-construction?
"You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
|
|
|
|
|
The most common equivelant to the application class in MFC would be to create a class full of public, static properties. As there's only one application class in MFC, so too, static variables can be seen from anywhere.
A better approach is to consider when the second class needs to see inside the first one, and set up delegates to provide this communication.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|