|
No problems. Two small caveats though.
First, the "sensitivity" is the distance you want the user to click within SQUARED. This saves calculating a sqrt.
Secondly, I forgot to mention in the original post that this code calculates the perpendicular distance to the line defined by the two points - extended to infinity in both directions. In other words
.
.
X
\ *
\
\
X
.
.
.
* .
if your line is defined by the X's then BOTH points marked with * would return true. If you want to restrict the result to only the top asterisk, you will need to add extra checking to the routine. The last line would need to be
return (h < Sensitivity && a < c && b < c);
I should also explain what the code is doing. It assumes that your start point, stop point and the click point form a triangle
*
|h
X------------------------X
the code calculates h - the perpendicular distance. First, we calculate the length of each side. Second, we use the three side lengths to calculate the area of the triangle using Heron's formula
Area = sqrt(s(s-a)(s-b)(s-c)) where s is (a+b+c)/2;
Third, we use the other formula for area of a triangle
Area = 1/2 base * height.
We know the area, we know the base, we can find the height. The code actually calculates h squared as described above.
Finally, the && a < c && b < c part of the modified last works this way.
*
|h
X-----------c------------X............
c is the distance between the X's and a would be the distance between the first X and the *. Because a > c, we know that the * is on the "extended" line.
I hope this all makes sense. Sorry I didn't explain it better the first time.
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
Hi..
What is the code i will need to connect to another computer
in my network and retrive files stored in directory at that
machine..
thanks
|
|
|
|
|
i think ur wrong here... this is not a "do my homework" forum!
Don't try it, just do it!
|
|
|
|
|
What's the code?
Try this resoucrce! Reading, you'll be amazed at what you'll learn.
msdn.microsoft.com[^]
|
|
|
|
|
Buy SAMS MFC Programming with Visual C++ 6 UNLEASHED
It's got a fair bit on communicating between networked computers....I think?!
I read only the bits that interest me.
Ashman
|
|
|
|
|
If the drive you want the data on is shared and you have the proper permissions it might be as easy as copying a file on the local machine. Lookup UNC paths. Basically it is \\<ip address>\<share name>\<file name>
John
|
|
|
|
|
There is this wonderful thing called MSDN and if you would have did a search for "copy files" you probably would have discovered this wonderful object called File which has a memeber Copy .
I suppose it is always faster just to ask in an open forum than to do a little work searching.
|
|
|
|
|
hi
i m new to MFC ..
i want to creat my own toolber in my dialog.
how can i do it
thanx
|
|
|
|
|
|
|
Ok, I'm really new to this so please be gentle. I just started taking a C++ course and I was wondering how could I have the user input some form of information but on the screen only see an asterix or a blank, sorta like when a password is entered. Right now we're only writing VERY basic code and using the win32 non-gui cosole. We're not even gonna get to objects this semester. Can anyone help? If so thanks, if not thanks for listening.
Pakled
|
|
|
|
|
If you want to use a blank instead of the password, you can print what you need to as far as telling the user to enter a password, then set the text color to the same color as the background color. When the user enters the password and presses enter, you can set the text color to what it was before.
This way, when the user enters the password, nothing will be seen.
<br />
int main(void)<br />
{<br />
char password[10];<br />
printf("Enter password...\n");<br />
SetTextColorToSameAsBackground();<br />
gets(password);<br />
SetTextColorToWhatItWasBefore();<br />
return 0;<br />
}<br />
|
|
|
|
|
Hi,
is this possible? I know how to enumerate the local IP adresses, however I am missing the netmask... and googled here and there, but couldn't find an answer. Thanks for help.
|
|
|
|
|
See if this article helps.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I am sure it does! thanks, I will rate for it it later.
(strange again i am not logged in)
|
|
|
|
|
Hi all,
I am looking for code/articles that can show me how to implement bandwidth throttling on a local machine using C/C++. The reason being is that I have users on Satellite Internet that if trying to download more than 160+ megabytes upon reaching the 160 megabyte limit before 24 hours get throttled down to a 10K connection and everything dies. They have requested I write a tool that will allow them to set a bandwidth level on their connection that will keep them under 159 megabytes per 24 hours. Any help would be great.
Thanks,
Rex Winn
|
|
|
|
|
You could write your own application proxy. I would suggest that you get the source code for SOCKS (firewall proxy software) and modify it. Mostly because it's a proxy standard which most internet tools can use.
Then you add your throttling code inside the proxy. It will not be exact throttling though, as you will not be operating on TCP-level. You will never be able to throttle the data which is in your receiving TCP buffer, the sender's TCP buffer and what's currently in air. I don't know how much data that is, but it's at most a megabyte I'd imagine (probably much less).
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
Jorgen, (Up The IRONS!!!)
SOCKS PROXY EH? You gotta a link or do I have to call the clickety police? I'll go google it but if you have one of the top of you head that would be great.
On your second paragraph, I am interpreting a solution to that to mean that if the limit is 159 megabytes then I better throttle to less than 158 and probably 155 would be safe? Is that how I should interpret that?
Thanks,
Rex
"Back to school, back to school; to prove to dad I'm not a fool." - Billy Madison (Adam Sandler)
Rex Winn
|
|
|
|
|
Code Frog wrote:
Up The IRONS
Oi!
You're in luck: I found this: http://www.naughter.com/sockssvc.html[^]
Code Frog wrote:
On your second paragraph, I am interpreting a solution to that to mean that if the limit is 159 megabytes then I better throttle to less than 158 and probably 155 would be safe? Is that how I should interpret that?
Yep. I might be totally off the scale though regarding how large the TCP buffers are. I imagine the data on the server is accounted for when it's passed through write() rather than when it's actually been TCP-acknowledged by the receiving end. That's why one may have to take the server buffers into account. Is there a technician who you could ask about this?
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
Rather than ask a technician I bet I can get a better number by experimentation. I don't want to slam a business but the place I would call to ask... I really think that they don't have a clue and they WILL NOT forward me to their engineers... been down that road. It was like going "From here to eternity." but hey "...it's not a bad place" they just don't know anything.
- Rex
Off to go browse that link... This is going to be fun!!! I'm looking forward to this one!!!
"Back to school, back to school; to prove to dad I'm not a fool." - Billy Madison (Adam Sandler)
Rex Winn
|
|
|
|
|
I am trying to make a function that is called every time the mouse is moved (using MFC).
I have this in the dialog header file right before the MESSAGE_MAP is called:
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
In the MESSAGE_MAP I have:
ON_WM_MOUSEMOVE()
My function looks like this:
afx_msg void CBattleBot3Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
//stuff here
}
The function is only called when my mouse is moved INSIDE the dialog box. When the mouse is outside of the dialog box, the function is not called. Anyone have any idea why? Any help is appreciated.
-Dev578
|
|
|
|
|
Call SetCapture() to receive WM_MOUSEMOVE messages when the mouse is outside your dialog. Be sure to ReleaseCapture() when you're no longer interested in receiving these messages when the mouse is outside your dialog.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Anyone have any idea why? Any help is appreciated.
Because that's how WM_MOUSEMOVE works - it's send to the window under the cursor when the mouse is not captured. As Ravi said, you have to capture the mouse to get notified regardless of where the cursor is. You can't do that all the time though, as capturing the mouse means that no other windows will get mouse messages.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber | RightClick-Encrypt
|
|
|
|
|
BYTE ks[256];
GetKeyboardState(ks);
WORD w;
UINT scan;
scan=0;
ToAscii(wParam,scan,ks,&w,0);
ch =char(w);
MessageBox(0,"" + ch,"Key pressed",MB_OK); // <-- is this the right way of getting the char into a string? The results are jumbled
|
|
|
|
|
please buy a book about C++ and windows programming
|
|
|
|