|
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely.
Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected.
But for that I'd need to have the form's mouse events take precedence over all control mouse events.
Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or?
I need to fire the form's mouse event at all times and ignore the control's events instead.
What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked?
Thank you!
|
|
|
|
|
The problem is the WM_MOUSEMOVE message (0x200) only gets passed to the control the mouse is over. Even overriding WndProc won't solve that.
What is it that you're wanting to achieve exactly?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
You too haven't been paying attention the last three months?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I only visit a couple of dozen times throughout the day and evening. Note to self - must spend more time on CP! My Mrs will love that, and so will my boss
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
I don't exactly remember what it is you wanted to achieve three months ago, and I sure can't tell from today's message.
I have several suggestions for you:
1.
create a new app, as simple as possible, that poses the problem you have, and experiment with it, not with the real app which by now must be too large and convoluted to understand anyhow. If you then still don't succeed, clearly explain that simple app, what it does, and how that differs from what you want.
2.
In a wild guess you want all controls to be non-functional as far as mouse operations go, have you tried myForm.Capture=true; ?
3.
In an equally wild guess, if you were to want to know the position of the mouse at all times, say for displaying it (I have an editor that does that), then you could use a timer that periodically (say 10Hz) gets Control.MousePosition, that is the mouse position in screen coordinates, which can be easily transformed using myForm.PointToClient().
4.
read my sig.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
It's not very clear what you tried to achieve....
In both WinForm and WPF you can capture mouse event with
(in a control) Capture()
then you 'll get mouse event until, mmh... I'm not sure.. usually I always release the mouse on Mouse Up event...
Other than that you can try to write a mouse hook
http://support.microsoft.com/kb/318804[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thanks.
But now that I think of it, I probably don't need it anymore.
What I'm trying to do for about 3 months now is implementing an Excel like selection for a collection of PictureBoxes that are arranged in a grid, similar to cells in Excel.
I don't want to select independent boxes with ctrl, just selecting a region while the mouse button is held down.
I asked about this many times here and on msdn, but I either got ignored or code that didn't work at all.
The latest code I got from msdn also doesn't work, but gave me an idea.
I'm trying to use a half transparent form to draw the selection rectangle and use the MouseEnter and MouseLeave events of PictureBoxes to fire the Form's events (passing the MouseArgs) to change the selection form's size and location and store the coordinates of the PictureBoxes in a collection (which will be used after selection is finished).
It looks like this:
http://i28.tinypic.com/einihz.jpg[^]
The cursor is above box 16 and the selection form is in the upper left corner outside the form.
I searched, but couldn't find a working way to get the mouse coordinates not for the whole screen, but only for the form, so that the selection form will displayed correctly.
I use this code for the Main Form's MouseDown event:
private void OnFormMouseDown(object sender, MouseEventArgs e)
{
select = true;
selectform = new F_selection();
selectform.Size = new Size(4, 4);
selectform.Location = new Point(e.X, e.Y);
selectstart = new Point(e.X, e.Y);
selectform.Show();
}
And this code for the MouseMove event
private void OnFormMouseMove(object sender, MouseEventArgs e)
{
int width = 0;
int height = 0;
if (select)
{
width = selectstart.X - e.Location.X;
if (width < 0)
{
width *= -1;
}
height = selectstart.Y - e.Location.Y;
if (height < 0)
{
height *= -1;
}
selectform.Location = new Point(e.X, e.Y);
selectform.Size = new Size(width, height);
}
}
Is there a better way to retrieve a number's value, independent from its algebraic sign thn checking if it's < 0 and multiplying with -1? I think in mathematics it was | x | . (damn smileys)
And would you know how to make it look like the mouse cursor is always at the far edge of the selection form, i.e. if you select something below and left of the current box, it's at the lower left corner and when you select something right and above of the current box, it's also at the upper right corner of the selection form.
Or will that happen automatically once the mouse coordinates are relative to the client area?
Again, thanks a lot in advance.
modified on Friday, July 17, 2009 1:44 PM
|
|
|
|
|
I'm fairly new to C# and client-side programming in general, so sorry if this is a lame question.
In VS08 (specifically a C#/WPF application, if that makes a difference), I'm wondering how to specify different settings that depend on whether the project build is classified as development/debug or production. There are three specific things I would like to use this for at this time, though I'm sure I will come up with more as I go along. Firstly, the production application will need to access a different database server with different credentials than what us developers will use. Secondly, I would like our login screen (username and password) to be pre-populated with test account credentials during development, but blank in production. And thirdly, our final branding hasn't been decided yet so we need to give the project a codename, but then automatically change all the window titles and everything else once we do have final branding.
Surely Microsoft didn't just do a "Replace in Files" command to change "Windows Longhorn" to "Windows Vista," right? I don't want to have to change all of that manually every time before we do Build > Publish, then change it all back immediately after the Publish is finished so we can continue developing. I'm sure there's something really simple and stupid that makes this possible, but I just don't know the right terminology to search for to find it.
Thank you in advance.
|
|
|
|
|
jaminblount wrote: Secondly, I would like our login screen (username and password) to be pre-populated with test account credentials during development
A simple enough method is to populate a bound item with these credentials in a section like this:
private LoginInfo _info = null;
private void InitialiseData()
{
if (_info == null)
{
_info = new LoginInfo();
}
#if DEBUG
_info.UserName = "Admin";
_info.Password = "4dm1n94550rd";
#endif
} The #if DEBUG section will not make it into the final release because you will (as is good practice) do a release build instead of a debug build.
jaminblount wrote: Firstly, the production application will need to access a different database server with different credentials than what us developers will use.
This is a fairly standard requirement - all you need do is store the connection information in the ConnectionStrings section of your config file. This will be changed in the live environment (you'll possibly implement some form of configuration manager to do this).
jaminblount wrote: And thirdly, our final branding hasn't been decided yet so we need to give the project a codename, but then automatically change all the window titles and everything else once we do have final branding.
Again, all you need do is use binding to support this. Your XAML might look something like this:
<Window ... Title="{Binding Path=ApplicationName}" ...
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello
I've a puzzle for List<t>; IBindingList and Datagridview guru's
I get an unexpected "Specified argument was out of the range" Error
Here we are :
I have a List of T class
I've setted a minimal IBindingList interface
So at least : AddNew
The List is binded on a DGV
The List is EMPTY
Path to get the error:
1- Click on the unique and empty first row of the dgv : it trigger an AddNew(no new row in DGV)
2- Edit a cell in that row : it will create an empty new row in the DGV
3- Click on an empty cell in that empty row : it trigger a new AddNew (no new row in DGV)
4- Click on Row 0 again
5- Now if I click back on the second row Row it trigger a third AddNew (no new row in DGV)
6- The click back again on Row 0 : BINGO it crashed !
I cant figure out what really happen ?? But it is clear that at this time the List contains 3 Items and the DGV 2 rows
Thanks for any help
Error :
{"Specified argument was out of the range of valid values.\r\nParameter name: rowIndex"}
|
|
|
|
|
Hello
One more precision
It seems that the problem is coming from a wrong on canceledit event handling
When I click on a new row on the DGV, it trigger the addnew event but if I leave that row without editing I think it is necessary to remove the new element created ?
How can I do that ?
Thank you for any help
|
|
|
|
|
Hi guys,
I have added a checkbox column to the datagrid, so now therez a check box for every row in the datagrid.
Can any1 suggest me how I can display checked rows in a new form.
ie. I select a row/rows by checking into the Check boxs.
Thanks,
|
|
|
|
|
Hi,
I have an application that uses different types of connections such as Oledb and Odbc for various types of databases. Now I am porting it to 64 bit OS (Vista) and everything is fine except that I can not make any connections to any of the databases. I get an exception that the engine is not installed. On vista 64 bit with sp1 wdac is installed. Any suggestions ?
Natza Mitzi
|
|
|
|
|
Are you using MS Access? I know that one isn't supported in 64-bit.
|
|
|
|
|
I am using ms access, sql 2000, sql 2005, excel, csv and oracle
Any solution for any of these will be a great help.
I think this is a coding horror...
Natza Mitzi
|
|
|
|
|
I have used Microsoft Visual C# 2008 Step by Step book to learn C# be sides from the writer adding in text to make it longer, like instead of saying Chapter 12. He writes a 50-word title and so on. However, this is not the problem. The problem is they write the tutorial programs to the console, which I cannot see, work because the console just blinks on and off and you cannot see what you did. Is there a way to make the console stop for 10 seconds or stop at the end of the program so I can see it?
Console.WriteLine("default constructor called:");
Console.Write("Press ENTER to finish.");
Console.Read();
This works to stop the console sometime for one line, but there must be a better way. If someone know if would be good to post it. I cannot find an easy way to do this.
|
|
|
|
|
rodbiser wrote: Console.Read();
That's the way if you are running using F5 . You don't have to wait for a key press if you run the executable directly (Ctrl + F5 ).
|
|
|
|
|
use:
Console.ReadLine()
or thread.sleep
Natza Mitzi
|
|
|
|
|
Yes, use Console.ReadLine();
It works wonders. The screen will stay up until you hit the Enter key.
|
|
|
|
|
... or run from a "Command Prompt" (aka "DOS window"). Doing so you don't need to modify your code at all.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I want to ask you if how can I use the dos window? I tried the properties and put it in the start but that did not work. Do you know how to make the compliler open the console you want? I know this is something that is not importion but I just want to know for my self. thanks for your answers
|
|
|
|
|
Hi,
Console.Read is good but if you want to wait on any key, not just Enter, then use ReadKey. A loop to empty the keyboard buffer will consume stored up keystrokes and ensure that a wait does occur.
Alan.
while (Console.KeyAvailable) {
Console.ReadKey(true);
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey(true);
|
|
|
|
|
I'm creating a user control. It's possible to overwrite the Controls collection and
raise an event in the Add when the user does
MyCustomUserControl.Controls.Add(new textbox());
Is it possible to tell when the user drops a control onto my user control in design mode?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Have you tried ControlAdded[^] event? Not sure it works on design mode though.
|
|
|
|
|
I need to complete a project called "Computer Vision based Human blood Recognition and counting"
I used some tools of AForge.NET for cell count (as object count) but it gives incorrect result. How i can count cell from microcopic picture.
I badly need a solution.
I used connected component labelling method from AForge.NET but it does not work. Is my method is wrong?
I have two requirement
1)blood cell count
2) blood cell recognition (eg; roundness, saliency, diameter, orientation etc)
can any body help me in this regard...
Mohammad Shakil
shakil0404036@yahoo.com
|
|
|
|