|
If you want to know where it is, you can use Cursor.Position . It is in screen coordinates though, so have to substract the location of the form from it.
If you want to be notified of every move of the mouse on your form, you can implement <a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsimessagefilterclasstopic.asp" rel="nofollow">IMessageFilter</a>[<a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsimessagefilterclasstopic.asp" target = "_blank" rel="nofollow">^</a>] . Then, in PreFilterMessage you can handle the <a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/mouseinputreference/mouseinputmessages/wm_mousemove.asp" rel="nofollow">WM_MOUSEMOVE</a>[<a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/mouseinputreference/mouseinputmessages/wm_mousemove.asp" target = "_blank" rel="nofollow">^</a>] (= 512) message.
Hope this helps!
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
I have an MdiParent form. This form has an MdiChild form. On MdiChild I have a button that opens another New form. But this form opens outside the MdiParent. How do I make the New form an MdiChild.
Please Help
|
|
|
|
|
The same way you made your Child form a child. Create the form object, set it's MdiParent property to the same parent that this child is using, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yo, thanks man, i tried fiddling with it and it worked.
Enjoy.
|
|
|
|
|
there is no events called, nothing.
I know there are qiute a few work arounds, like
calling api or not showing controlbox at all.
what I would like to know is why after closing form from
controlbox X, call to MyForm.Show does not do anything,
not even error.
and also is there a way to trap that click on controlbox
but stay within managed code.
TIA
|
|
|
|
|
Are you refering to the X in the upper right of the titlebar? If so the Closing and Closed events do fire on either side of the forms death. Using Closing you can abort the process by e.Cancel to true.
|
|
|
|
|
Hi,
I should like to write trace lines (using Trace.WriteLine or even Console.WriteLine) to a console window, but this time from a Class module.
The class module does not create a Console (aka command line)window, so Console.WriteLine does not work. Neither could I find an example of specifying a (or creating a) console window for this kind of output.
Anybody Any Idea how to do this?
Tx Aad
Aad Slingerland
Zevenaar
The Netherlands
|
|
|
|
|
Applications for either the console or windows subsystem won't display output for Trace.WriteLine unless you add the following lines of code before calling your first Trace.WriteLine (or Debug.WriteLine ):
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); To display a console window for a Windows Forms applcation compiled for the window subsystem (because a Windows Forms application can be compiled for the console subsystem and work, plus write console data; ildasm.exe is compiled this way) you'd have to P/Invoke CreateConsoleScreenBuffer and write a TextWriter around that for use with the TextWriterTraceListener , or just write your own TraceListener derivative to do that.
The easiest is just compile your Windows Forms application using /t:exe instead of /t:winexe so that you already have a console attached to the process.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello Heath,
I give this a try first thing in the morning. Be back...
Tx Aad
Aad Slingerland
Zevenaar
The Netherlands
|
|
|
|
|
Sound like you might be doing what I was doing. I kept writing Console harness apps to get the output to track what's going on while developing until I found out about System.Diagnostics.Debug.WriteLine() . If you're using .Net Studio, it will display the information in the Output window. I use it in both windows forms or special classes that have no GUI interface. Sure beat the heck out of the test harnesses.
|
|
|
|
|
Working on the subject I found a even simpler way to create a console window from within a class module. It requires two p/invoke functions from kernel32 and than Console.WriteLine () will do! It goes like this...
bool b = AllocConsole ();
Console.WriteLine ("This...");
Console.WriteLine ("...That");
bool b = FreeConsole ();
Aad
Aad Slingerland
Zevenaar
The Netherlands
|
|
|
|
|
Please tell me there's an easier way. Here are a few examples of my recent pain:
It took me a day and a half of searching the Web, MSDN, and 6 books about C# before I found out there was an OpenFilaDialog class for asking the user which file they wanted my app to open.
It took me mere seconds to code a KeyDown event on my RichTextBox, and to figure out that I needed to use KeyEventArgs.Control to see if the control key was pressed, but it took several hours of searching to figure out I needed to compare Keys.L to KeyEventArgs.KeyCode to find out if <ctrl>L was pressed.
It took me hours of searching to find out that "Cursor.Current=Cursors.WaitCursor;" would change the mousepointer to the hourglass while my program retrieved from the database.
I am not stupid, I have been programming for over 25 years, in RPG, COBOL, TOTAL, ADS/O, PowerBuilder, and probably others along the way.
My whole department is going to come to me when they have the question: "In .NET, how do I...?", and I don't want to tell them I'll get back to them in a week.
I bought "C# for Experienced Programmers" by Deitel because it was the only book I could find that told me about the OpenFileDialog class. It did not help me with the other two situations I had.
I just have to beleive there is a better way...
|
|
|
|
|
My recommendation is to skim through the table of contents for the Class Library[^] to see what classes there are. I've seen many times where people are looking for something or end up writing something over when there was a class already for it. You wouldn't necessarily have to read about all the classes (at least the ones in which you're interested or the name is not self-explanitory enough) but just see what there is.
Also being familiar with the major abstract classes like System.Windows.Forms.Control is important. They define much of the functionality of their derivatives and understanding how they work is important. I also recommend that when you get more familiar with classes you see how they work under the covers using ildasm.exe from the .NET Framework SDK or a decompilers like .NET Reflector[^].
It's really just a case of getting to know the classes for such a large class library. Guessing also helps. If you're looking for an open file dialog, type "OpenFileDialog" (case not important) in the index of your Visual Studio Combined Help collection in the Visual Studio program group in yoru start menu. The local index is much easier to search than MSDN since there it's a keyword search, while and index like the combined collection (or the quarterly MSDN Library if you subscribe) is designed to help you be more efficient. When you get used to the class naming conventions of the .NET base class library (BCL) it gets easier to guess what a useful class name is. Type it in the index and read about it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
To quote you: '...If you're looking for an open file dialog, type "OpenFileDialog"..'
Therein lies the crux of the problem. If I had known that it was called "OpenFileDialog" I wouldn't even have needed to search in the first place because autocomplete will tell me all about the methods, attributes, and events for that class. I searched for "openfile", "fileopen", "getfile", getfilename", "getfileopenname" (The function we use in PowerBuilder), "filechoose", "filename", and a hundred other search strings. No reasonable results came back from MSDN online, the WEB in general, or any books except the one I bought.
When I wanted to do the mousepointer thing, the first search string I entered was "cursor", but I got back 100 billion useless VB6, foxpro, and C++ answers for how to use database cursors. So I assumed I was on the wrong track and should search for "mouse", "mousepointer", "mouseicon", "pointer", etc. All to no avail.
Your idea about perusing the class library's table of contents is not a bad idea for a rainy day, but when I have a specific question about something in C#, there doesn't seem to be a resource available to me. IF MSDN online would let me filter my search PROPERLY, it might end up being the answer, but it's totally useless as it sits now.
I was hoping I could find a searchable reference resource (online or book) on C# specifically.
|
|
|
|
|
You need to limit your scope. If you simply search for "cursor" you will find lots of extraneous hits, but "mouse cursor" would've gotten rid of all those SQL database cursor documents and "mouse cursor in .NET" would've gotten you closer.
Using the Visual Studio Combined Collection is the best way, IMO, because - at least in the case of "cursor" typing it in the index (not search) would've given you relatively few - but more appropriate - hits. Indexes are more conceptual where keyword searches are almost always useless unless you get really specific.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I don't have "Visual Studio Combined Help collection in the Visual Studio program group in your start menu".
Maybe that is the real problem here. Is it something I did not install? I have VS 2003 and .Net Framework 1.1.
I was relying too much on web searching, and not on searching specific help files on my own computer. I do have "MSDN Library for Visual Studio .NET 2003" on my start menu, but I had not seen that because it is so well hidden. Maybe all my complaining was for nought.
I searched it for "openfile" and it took me right to the OpenFileDialog class.
I searched for "mouse pointer", "mousepointer" and "mouse cursor", which didn't get me good results, but when I searched for "cursor" it went right to the Cursor and Cursors classes, which may have helped me, though the examples there were stupid.
I couldn't find a good search string for the Keys.L thing, but I think if I was on the KeyEventArgs class, I may have been able to figure out the Keys.L thing.
You may have opened a whole new world for me here.
|
|
|
|
|
You have to install the help collection after installing Visual Studio. What you have would be aggregated - along with third-party components some times - with the Visual Studio Combined Collection (or something similar to that; don't remember off-hand what the exact wording is).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I do as you, but I often look at the functions and members of the class, and then I look at the index, that's really fast, after that I search msnd, that amost never give's me answers. I try to figure it out in another way insted.
I'm also a programmer that always write's my own code, with C#, it's a lot easier, becouse of the framework.
I'll need to learn the skill to use code of others...
The one and only Niklas Ulvinge aka IDK
|
|
|
|
|
Like with all "new" (I mean "new" as in "new to you") API/libraries, it is just a matter of figuring out the style or pattern to the thing (what their methodology for placing what classes where). Once you realize that it is easy to search for things you aren't exactly sure where they exist. I would recommend getting familiar with the namespace layout. Once you realize that all UI elements are under System.Windows.Forms you could easily find the OpenFileDialog class. Lo and behold, SaveFileDialog is there as well! Once you realize the IO is in System.IO you can find all sorts of ways to stream data.
Picking up a new API/library is like learning to ride a bike all over again. It is a little painful but the real way to do it is jump on and go. It might have taken you a bit to find OpenFileDialog but it will get faster the more familiar you get with the object layout.
|
|
|
|
|
I have an HTML file i want to read certain parts of based on the tags round them BUT i dont want to read the tags in to the string im reading the text into after i have located it.
So here is what i have been doing so far:
1) Read in the HTML file to a string.
2) Read through the string char by char placing returns where tags are. So that each tag is shunted onto its own line and so is each peice of untagged text.
3) Read line by line checking the tags.If its the tag i want read the entire line bellow then stop reading and start checking again.
This was easy to code as it was just a matter or adding returns when it read a "<"or ">"
Then reading line by line, ignoring any lines that where not direclty below the tags i wanted..
But I feel like I'm double handling the data, would my program be more efficient if it looked for the lines I wanted while it was scanning for tags during stage 2 where it was previously just adding returns.
SO it would:
1) Read through line by line.
2) See a tag
3) Check the tag
4) If OK read the text to the next "<"
Or are both ways close enough in efficienty to not warrent a rewrite of the code?
|
|
|
|
|
Since HTML is simply a piece of XML code, just use a Xmlreader. There are lots of articles/discussions about that, here in Code Project.
___________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA]
|
|
|
|
|
Actually, that is far from the truth. XHTML is XML using a default namespace defined by a schema similar to HTML, but HTML is not XML for one big reason: HTML is not well-formed. The <br> tag, for example, does not define a closing tag and is not self-closed. You can, but most generators and even web developers don't do this.
HTML is defined by SGML as is XML but HTML is far more lax. In order to parse HTML and tokenize it by its tags like you could an XML document, you have to use a more lax parser. GotDotNet has one available at http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=B90FDDCE-E60D-43F8-A5C4-C3BD760564BC[^] that can parse HTML for you and tokenize it as such.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Your first way will take about twice as long. Wether that's enough of a performance hit to justify a refactoring depends on how large your html files are, and how often you need to parse them.
|
|
|
|
|
I have intalled .Net Framework 1.1 With SP1 on my test PC which is Running on Windows XP Home Edition and Windows 2000 Professional. My app crashes with some unknown Exception. I have tried a simple Windows App with just a few default controls it still doesnt work.
Error Shows
Common Language Runtime Debugging Services
Application Has Generated an exception that could not be handled
ProcessID = 0x128(288) ThreadID= 0x546(???)
What could be wrong with it
I have tried Both debug and release versions
Zishan Haider
|
|
|
|
|
How can I programaticly clear selections in lvA when the user selects something from lvB and vice versa. At the moment I'm using the SelectedIndexChanged event and looping through the other lvs items setting selected to false. The problem is that while clicking on an item in lvB will trigger the clearingof lvAs selections, doing so triggers lvA's SelectedIndexChanged event which clears the just made selection in lvB.
|
|
|
|