|
Hello, all. I've come to codeproject once again to discuss a custom form, but I understand the concept much more. But, I just can't get the algorithm to make the form stay at the mouse's location while moving, you know, while clicking and holding the top bar. It's probably really sime, but here's what I have so far. If anyone could assist, it would be greatly appreciated. Thanks in advance!
*assuming FormBar is the bar at the top of the form you can move round with.
* there are probably a LOT of beginner errors in here; if you try to correct me (you will), please help me understand.
public bool Moving = false;<br />
public Point xy;<br />
<br />
private void FormBar_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
Moving = true;<br />
xy = MousePosition;<br />
}<br />
<br />
private void FormBar_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
int x1, y1, x, y, x2, y2;<br />
x1 = this.Location.X;<br />
y1 = this.Location.Y;<br />
x = MousePosition.X;<br />
y = MousePosition.Y;<br />
x2 = xy.X;<br />
y2 = xy.Y;<br />
<br />
if (Moving == true)<br />
{<br />
this.Location = new System.Drawing.Point(x - (x2 - 50), y - (y2 - 50));<br />
}<br />
}<br />
<br />
private void FormBar_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
Moving = false;<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
this.Close();<br />
}
The most knowledge doesn't mean the most wise...
|
|
|
|
|
MasterSharp wrote: int x1, y1, x, y, x2, y2;
x1 = this.Location.X;
y1 = this.Location.Y;
x = MousePosition.X;
y = MousePosition.Y;
x2 = xy.X;
y2 = xy.Y;
Declare them as you set their values, i.e. int x1 = this.Location.X;
MasterSharp wrote: public bool Moving = false;
public Point xy;
Make these private if at all possible
MasterSharp wrote: x2 = xy.X;
y2 = xy.Y;
This is superfluous, just use the xy values.
MasterSharp wrote: xy = MousePosition;
What is mousePosition ? The event args has the current mouse pos.
What you want to do is this:
store the current mouse pos from the event args in mouse down.
On mouse move, move the form by the difference between the mouse pos in the event args and the one you stored, and then store the pos from the args over the pos you stored before, so that next time you again move by how much the mouse moved between events.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
I want to embed the Windows Media Player to my C# win app
I did it successfully.
and I know that for changing it's skin, have to use of 'IWMPRemoteMediaServices.GetCustomUIMode' method.
but I can not find this method at all.
I do not know how can select a desired skin for my WMP object in my application.
anybody help me ?!
-- modified at 16:09 Sunday 21st October, 2007
H.R
|
|
|
|
|
Hello Friends,
I need your help setting up a DataGrid. I have this DataGrid, and I want the following
options to be available on it, some I got working, and some only work if I disable another option. How can I get all of these options to be available on my DataGrid?
1) I want to be able to select a single line, or multiple lines. This by clicking on one cell in the
row. I want it to become blue, like when selecting text. If I click control or shift, it will select multiple rows.
This in order to remove rows from the grid.
2) I want to be able to sort the list by a specific coloumn in it.
3) I want the height of the row to be determined by the amount of text inside it. thus if the text in a specific cell in a row takes a bigger space than the default row height, that row's height will be enlarged.
Imagine this situation on a Word's table; if you enter
a big amount of text in a cell, that entire row's height enlarges.
4) Something I don't want - when you click on a cell, the text inside it becomes blue (only in that specific cell) and its format is changed.
e.g if I have:
"This is a
Nice line"
if I click on it it becomes blue and the text becomes "This is aNice line"
I never want the text's format to change.
The problems I have: if I "enable=false" the DataGrid, I get no event for a click on it
thus I can't select it (i.e turn it blue).
I'm very sorry for this over-sized message and I would really appreciate your help.
Thank you very much,
Aviv Giladi
|
|
|
|
|
How long does it take for your article to get "edited" and not have that blue background at the top anymore. I am just tired of it being an "Unedited" project.
Thanks for any help you can give in this matter.
Brad Barnhill
|
|
|
|
|
A long time. Have you seen how many 'unedited reader contributions' there are? Alot.
Im not certain how they decide which articles to check first, or if its just the first article to get posted gets edited first, but either way, it could be a while.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
You should put this in the General Discussion forum, or better yet, email Chris and see what happens. With the volume of articles that get submitted, some fall through the cracks.
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
For a start, you need to ask in the appropriate forum. Don't just randomly pick one and hope for the best. Chris generally receives details from the Suggestions forum, so that's the best place to be.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
To be nice ... I didnt just pick a forum at random. Since I wrote a C# article I posted it in here. I figured I would get some help from here instead of a smart mouth. Ive been wrong before and looks like I was again.
Brad Barnhill
|
|
|
|
|
bbarnhill wrote: I figured I would get some help from here instead of a smart mouth. Ive been wrong before and looks like I was again.
You did get help. You just chose to ignore it.
If you take the time to look around this site, you will see that there is a Suggestions forum - and Chris receives notifications when anybody posts to this forum. The sheer volume of posts means that it's impractical for him to monitor every forum - hence my comment about picking the appropriate forum.
Look at it this way - would you crosspost this question if your article had been about C#, Vista and SQL Server? No - I thought not.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Just work on your presentation skills. You strike me as rude in the delivery of your "help".
Brad Barnhill
|
|
|
|
|
bbarnhill wrote: Just work on your presentation skills. You strike me as rude in the delivery of your "help".
Oh dear - I'm so sorry if I offended you. Listen, I answer approximately 50 calls for help a day. I don't have time to handcraft an essay for you. I give you the information, and then it's up to you to actually do some work. That's not my job - it's yours. Tell you what - if I offend you that much, I won't bother with you in the future. Then we're both happy.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
That would be great. Dont "help" me again. You make it out like I wanted you to do the work for me...which is completely retarded.
Brad Barnhill
|
|
|
|
|
bbarnhill wrote: completely retarded.
Errm. How did you make that out? What moronic planet are you inhabiting?
bbarnhill wrote: You make it out like I wanted you to do the work for me
No - I didn't. You asked a question and I answered it. You then started a flame because you didn't like my "tone". Geez - get over yourself. BTW - I had a look at the article in question, and while it was interesting I was going to offer a couple of helpful pointers, but I guess you don't need any help so I won't bother, but here's a hint - look at making it less monolithic.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: What moronic planet are you inhabiting.
Earth ... which one are you inhabiting?
Pete O`Hanlon wrote: You then started a flame
No - I started to correct you on your blunt delivery.
Help is always appreciated, even constructive criticism. Look there is no reason to argue on here its retarded. If you want to help fine if not then just ignore this conversation.
Brad Barnhill
|
|
|
|
|
bbarnhill wrote: your blunt delivery
Do you honestly think that people have time to be obseqious and all nicey-nice.
bbarnhill wrote: Help is always appreciated, even constructive criticism.
And help is what you got. It isn't my fault that you chose to interpret it as blunt. Having reread my post, I don't actually see anything in it that could be chosen as anything other than help. Once you posted on the correct forum, I replied civilly.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: I replied civilly
but only once I posted in the "right" forum.
You may not always see how you are blunt, and crude in your delivery but others may. Just because I pointed out a short-coming of yours, you dont have to get hostile.
Thanks but no thanks for your help. I am done with this conversation.
Brad Barnhill
|
|
|
|
|
bbarnhill wrote: You may not always see how you are blunt, and crude in your delivery but others may
That's in your opinion and your opinion only. There are reasons that people point you towards the correct forum and they have absolutely nothing to do with you. The reason that we don't have everything in one forum is so that people can easily find information on a particular topic. If you start mixing irrelevant things in, it becomes so much harder for others to separate the wheat from the chaff.
bbarnhill wrote: Just because I pointed out a short-coming of yours, you dont have to get hostile.
It ain't a shortcoming of mine that you're an oversensitive idiot.
bbarnhill wrote: I am done with this conversation.
Good night then.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a little app that i use to connect to my PC at home, upload files, download files, etc.
And it can connect just fine, but only because i put port forwarding on my router, and gave my machine a static ip.
Is there any way i can connect to a pc behind a router by knowing its MAC address, or its local IP? Or something else perhaps.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Not directly, no, as this would represent a serious security risk.
What some applications do is use a third party server which both ends of your transfer connect to - more often than not applications of this sort tend to use one of the well known ports to avoid any firewalling issues.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
Hi,
I run an application in the startup of the computer,
the application is run without a window.
Now I want to send notification to the application to terminate normally
somting like the command Application.CloseMainWindow for an application that run with window
How can I send close command to an application that has no window?
Thanks,
Meir.
|
|
|
|
|
You might be able to use SendMessage:
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
...
int result = SendMessage( handleToApp, WM_SYSCOMMAND, SC_CLOSE, IntPtr.Zero);
There's probably other ways you could do it, but i don't know any.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hi,
My application has no form it runs in a backgroud, so the Sendmessage command didn't help me, it send the command to the main form of the application but i don't have one!
There is several option to run an application without a window for example:
Putting the application in the startup of the computer
Thanks,
|
|
|
|
|
Hi,
you could add a window (possibly invisible) to your app and have it receive messages
(if necessary, by overriding WndProc).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
My application has a window, but when I put the application in the startup of the computer it run without a woindow
Thanks,
|
|
|
|