|
I believe you simply should calculate the distance between your line and the point where the user has clicked. If the result is lower than a few pixels, then consider the user has clicked on the line.
As a reminder, the distance between a point M(x0,y0) and a line L with equation Ax+By+C=0 is given by the formula:
d = fabs(Ax0+By0+C) / sqrt(A^2 + B^2)
|
|
|
|
|
My bad. I don't work with graphics (e.g., line drawing) so I forget that lines can be more than just horizontal!
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Normaly I would try something simular to Bresenham's line-drawing algorithm to test if a given point falls on or close to the line.
You can try looking at the DRAWCLI sample program in MSDN or at any victor drawing program you can find (with source), since they all needed to do this.
* Another option you could try, would be to use Regions (regions [Win32]) instead of Rectangles to specify the bounding area. A Region can be any shape you want it to be; therefor, you could use the PtInRegion() function to check if line is selected.
Good Luck!
INTP
|
|
|
|
|
Hi all ,
I have just discovered this forum.Looks great !!
I am trying to use downloaded files for compiling a program to decode DRM short wave HI FI .Article from ELEKTOR april 2004.
After getting everythig ready including the visual studio service pack 5 and corresponding processor pack (all installed)
The C++ refuses to acknowledge the existance of the declarations in the header files
xmmintrin.h and mmintrin.h and display 4 errors per line of prototype function
(syntax errors)going to over 5000 errors .
I suspect that the processor pack is not enabled by the program or the processor is not selected ??? My system uses an AMD 2600 with DDR(500 K).
Am I doing anything wrong ??
I just downloaded the article on SSE
G Brennet
|
|
|
|
|
Does anyone know how to have a button on a toolbar which is of a different width than the other buttons?
I have tried using multiple toolbars, and that works, but does not give the result I want when the window is made resized small and then back large again.
Thanks
|
|
|
|
|
You will need to derive your own class from CToolBar and override some of the functionality.
Here are the notes from my code to fix the drop down arrow problem:
If you want I could zip up the code and send it to you. There is no garantee that it will solve your problem, but it would give you a good start.
INTP
|
|
|
|
|
Thanks for the information and your offer to zip and send me the code.
I will look into the Q article, as well as another possibility.
If I think the zipped code would be useful, I'll send you an email.
Thanks again for the offer.
|
|
|
|
|
Hi, i've got this class
template<class t=""> class pointer
{
private:
T *p;
};
and i get 4 if i do sizeof(pointer).
if i add a static member data, it doesn;t count. why is it that? is it because there's only one copy of that atribute for all the instances of the class?
then, if i add a virtual function (or 2, or 3), i get 8 if i do sizeof(pointer). why is that?
thanks for your help!
|
|
|
|
|
Adding a static member does not affect the size because a static member does not exist in an object (instantiation) of the class. The memory for the static member is allocated in ONE place, not for each object.
The reason that the size increases when you add a virtual method, is that the object needs a pointer to the VTable. This is a table of pointers, one for each virtual method. This table is specific to your class. Each object of the class will contain a pointer to this VTable. The size of this pointer is 4 bytes.
|
|
|
|
|
|
Hi, i would like to know hot to implement an operator to cast a class to void*.
I thought of overloading operator (), but i don't know how to proceed (as i didn't find anything on the web). Any ideas?
thanks!!
|
|
|
|
|
The following example overloads the + operator to add two complex numbers and returns the result.
// operator_overloading.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
class Complex
{
public:
Complex( double r, double i ) : re(r), im(i) {}
Complex operator+( Complex &other );
void Display( ) { cout << re << ", " << im << endl; }
private:
double re, im;
};
// Operator overloaded using a member function
Complex Complex::operator+( Complex &other )
{
return Complex( re + other.re, im + other.im );
}
int main()
{
Complex a = Complex( 1.2, 3.4 );
Complex b = Complex( 5.6, 7.8 );
Complex c = Complex( 0.0, 0.0 );
c = a + b;
c.Display();
}
|
|
|
|
|
Something like:
class MyClass
{
public:
operator LPVOID() const
{
return ???;
}
};
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
what do you mean with ???
thanks!
|
|
|
|
|
Since you did not tell us anything about your class, I obviously don't know what that method needs to return.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hi ,
I want to change the toolbar at click of a button .I am new to vc++ and i dont know how to solve this task.Any help would be much appreciated . thanks in advance .
regards,
vinod
|
|
|
|
|
Here is a partial clip for switching toolbars, from "The MFC Answer Book":
UINT nIDFrom = ::GetWindowLong( pBarFrom->GetSafeHwnd(), GWL_ID );
UINT nIDTo = ::GetWindowLong( pBarTo->GetSafeHwnd(), GWL_ID );
::SetWindowLong( pBarFrom->GetSafeHwnd(), GWL_ID, nIDTo );
::SetWindowLong( pBarTo->GetSafeHwnd(), GWL_ID, nIDFrom );
pFrame->ShowControlBar( pBarFrom, FALSE, bDelay );
pFrame->ShowControlBar( pBarTo, bVisible, bDelay );
This example is used to switch between toolbars that only differ in the size of the buttons. It could also be used to switch between a toolbar that contains image buttons and one that uses test buttons instead.
I hope that helps!
INTP
|
|
|
|
|
i use IMsTscAx control to connect to the TS Server.
setting valid server name and so on i finnaly call connect method. he return s_ok. but exploring other property's values i find that startconnected property is false - thats mean that control is not trying to connect. as a sequel connected property is false too.
what do i do wrong?
regards
|
|
|
|
|
Can anyone tell me how to obtain the screen dimensions in an MFC app?
Thanks
|
|
|
|
|
it doesnt seems to be mfc. but its simply call api functions:
GetSystemMetrics(SM_CXSCREEN);
GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
|
Get SystemMetrics will do the trick, if you'd like to substract the taskbar of other toolbars => use SystemParametersInfo.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
|
CWnd::GetDesktopWindow()->GetWindowRect (...);
Although this will return the same screen size regardless of the presence of app bars. You probably want the size of the workspace.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i would like to paste some word text with special characters, őúűöí. my problem is, that they are always converted to simple chars at paste operation, oúuöi.
Is there anyone who can help me out?
Thanks.
Leo.
|
|
|
|