|
what do you mean?
in the mouse down i currently grab the offset from the button's corner to the mouse, then use that in the mouse move so i can seamlessly move the button in the mouse move by saying button1.Left += (e.X - xOffset); and the same for the top coordinate.
Mouse Down event is only sent once, its not a continuous thing is it? I tried moving in just the mouse down and it only moved once.
"Details details. Things to do Things to get done. Don't bother me with details just tell me when they're done." James Price
|
|
|
|
|
AtomRiot wrote: what do you mean?
Exacly what I said.
Have a look at the Capture property of the control that you want to move.
---
single minded; short sighted; long gone;
|
|
|
|
|
The Capture property is simply a bool variable that you can set. that doesnt change the fact that the button mousedown event is only thrown once and is not continuously. i already have a bool variable in that example that does the same thing the Capture property does.
"Details details. Things to do Things to get done. Don't bother me with details just tell me when they're done." James Price
|
|
|
|
|
AtomRiot wrote: The Capture property is simply a bool variable that you can set.
And you don't think that something happens when you set it? If it was "just a bool variable", then there would hardly be a point of having it as a property of the control.
AtomRiot wrote: that doesnt change the fact that the button mousedown event is only thrown once and is not continuously.
Why would you want the mouse down event to fire continously? That's what you have the mouse move event for.
---
single minded; short sighted; long gone;
|
|
|
|
|
Sorry, but I am a little confused by the usage. I have tried setting the Capture property but I guess I just don't know how to use it properly.
Can you point me to an example of this? Everywhere I search, it looks to be used just as a bool variable for that control.
"Details details. Things to do Things to get done. Don't bother me with details just tell me when they're done." James Price
|
|
|
|
|
Here's how you use it:
private Point start;
private void movable_MouseDown(object sender, MouseEventArgs e) {
Control c = (Control)sender;
start = c.PointToScreen(e.Location);
c.Capture = true;
}
private void movable_MouseUp(object sender, MouseEventArgs e) {
Control c = (Control)sender;
c.Capture = false;
}
private void movable_MouseMove(object sender, MouseEventArgs e) {
Control c = (Control)sender;
if (c.Capture) {
Point mouse = c.PointToScreen(e.Location);
c.Left += mouse.X - start.X;
c.Top += mouse.Y - start.Y;
start = mouse;
}
}
Note: As this code uses the sender argument to reference the control, the code can be reused for the events of several controls that you want to be able to move.
---
single minded; short sighted; long gone;
|
|
|
|
|
Does anyone know if it's possible to write control extenders (similar in concept to the Ajax/ASP extendors) for WinForms controls?
What I'd like to be able to develop is a security widget which attaches to a control(s) which can hide/disable a control(s) based on the users role within an application.
Although I could do this with code in the form, it just seems that having an extender type do-hickey would be a nicer and more re-usable way of doing it...
|
|
|
|
|
I know I am very late with this but I found your question while browsing the web for a solution for a similar problem and I think it is important that other who get here with the same google search are provided with a suggestion for a solution...
C# Custom Control Featuring a Collapsible Panel[^]
|
|
|
|
|
I tries but i don't know how in msn messenger there are several kinds of fonts and icons in one richTextBox
How can i do that????
|
|
|
|
|
Hello,
So i have a windows application and I want to be able to set up an auto download and installation of updates when the user starts up the software. Do i need some kind up FTP connection or webservices or what. I am at a lose as to how to approach. I am a beginning programmer and I need help. Thank you.
Nana
|
|
|
|
|
|
Yeah, I've only just started experimenting with this. It's pretty cool.
Kevin
|
|
|
|
|
I want to merge cells in a table in word 2003 from visual studio 2005 C#.
I manage to merge cells once in a table but when I try to merge other cells in the same table I get an error that says that the rows is not accessable because som cells have been merged.
This is the way I do it.
Word.Range range = MyWordApplication.Selection.Range;
range.Start = wordTable.Rows.Item(1).Cells.Item(2).Range.Start;
range.End = wordTable.Rows.Item(2).Cells.Item(2).Range.End;
range.Cells.Merge();
When I try it once more with other cells I get an error.
Does anyone have any Idea how I can get this to work?
Is there another way to select cells and then merge them?
I think that my way maybe selects all cells from row 1 column 2 to row 2 column 2 but I only want to select these two cells.
If you have any idea please let me know. Thanks!
|
|
|
|
|
Hi Larza.
To answer what I'm assuming you already know, yes, you're not specifying your range properly. When you try to merge a 2nd time, you're re-merging cells that are already merged.
I set my range a little differently. I have 1 line of code that specifies the 2 specific cells I wish to work with(and every cell within their range).
Try using it and see if it helps.
range = Worksheet.get_Range(Worksheet.Cells[1, 1], Worksheet.Cells[1, 2]);
range.Merge(true);
This code never gives me a problem. Try it and see if it helps.
-Goalie35
|
|
|
|
|
Hi! sorry for my late reply.
Thanx for your help but I have a few questions.
What type is the Worksheet?
I have an object of type Word.ApplicationClass.
But I can't find the worksheet.
Won't your range be from the first cell to your last cell?
I mean if you write it like this:
range = Worksheet.get_Range(Worksheet.Cells[1, 1], Worksheet.Cells[2, 2]);
Will the range then only contain 2 cells or every cell between the cells?
Thanx!
|
|
|
|
|
worksheet is an item of excel.
Word.Cell mergeBeginCell = wordTable.Cells(1, 2);
Word.Cell mergeEndCell = wordTable.Cell(2, 2);
mergeBeginCell.Merge(mergeEndCell);
|
|
|
|
|
Hi there,
Is there anyway that I can print the html file from commandline without showing print dialog?
I tried ShellExecuteEx and it does nothing.
Thank you.
|
|
|
|
|
Have you looked at PrintDocument?
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref8/html/T_System_Drawing_Printing_PrintDocument.htm
Example:
class Program
{
static Font printFont = new Font("Arial", 10);
static void Main(string[] args)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
doc.Print();
}
static void doc_PrintPage(object sender, PrintPageEventArgs e)
{
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
float yPos = topMargin + (printFont.GetHeight(e.Graphics));
e.Graphics.DrawString("Hello", printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
e.HasMorePages = false;
}
}
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...’
|
|
|
|
|
Hello,
I've derived Stream class to receive an internet audio stream.
But the DirectSound class can't play this because of the missing length and position informations.
But I don't have this, because the stream has no end!
How can I solve this?
|
|
|
|
|
Freak.2k wrote: I've derived Stream class to receive an internet audio stream.
But the DirectSound class can't play this because of the missing length and position informations.
But I don't have this, because the stream has no end!
1) Create a SecondaryBuffer object.
2) Set the length to some amount, say 8192, for example.
3) Create two arrays, each with a length half as long as the length of the SecondaryBuffer .
4) Initialize the buffer with Notify objects to notify you when the buffer reaches position 0 and half the length of the buffer.
5) Read data from your stream and place it into the first array.
6) Write the array data to the SecondaryBuffer .
7) Play the SecondaryBuffer with the looping option.
8) As you get notified by the SecondaryBuffer read another array from your stream and write it to the buffer.
This should work ok as long as your stream is staying ahead of your buffer, no guarrantees since this is an internet audio stream, so you may want to make the arrays large enough to give the internet stream a good head start. And be prepared to handle the situation when there are no bytes yet available from your stream.
Hope this helps.
|
|
|
|
|
Hello everyone,
I have an Array which holds list of items. Some of the items in the list are repeated (Undesirable).
Can someone tell me how I can remove/rearange/rebuilt the array without the repeated items?
Thank you very much and have a great weekend.
Khoramdin
|
|
|
|
|
Just off the top of my head... this seems good, it's O(n)
<font>public datatype[] UnduplicateArray(datatype[] startarray)
{
List<datatype> endarray = new List<datatype>();
foreach (datatype d in startarray)
if (!endarray.Contains(d))
endarray.Add(d);
return endarray.ToArray();
}
</datatype></datatype></font>
Last modified: 1hr 31mins after originally posted --
|
|
|
|
|
eggsovereasy wrote: this seems good, it's O(n)
Are you sure?
The List.Contains method loops throught each item in the collection looking for an existing item. That doesn't seem very good...
I would rather use a Dictionary, as that uses a hash table, which is much faster when looking for an existing item.
---
single minded; short sighted; long gone;
|
|
|
|
|
You are absolutely correct, I didn't consider what Contains() was doing, so its probably more like O(n^2).
|
|
|
|
|
I've got a .NET 2 generic library that does operations on any kind of list. I have a Distinct method in that library that returns only the unique elements in the list. It looks something like:
public static IEnumerable<T> Distinct<T>(IEnumerable<T> items)
{
Queue<T> distinct = new Queue<T>();
foreach (T element in items)
{
if (!distinct.Contains(element))
{
distinct.Enqueue(element);
}
}
return distinct;
}
Then you can use it like this:
string[] myStrings = { "hello", "world", "hello" };
IEnumerable<string> distinct = Distinct(myStrings);
|
|
|
|