|
You need to declare WM_MOUSEMOVE and WM_LBUTTONUP/DOWN and you need to get current postion of mouse with GetCursorPos and then you can use of LineTo/MoveTo.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks Hamid ,thanks for your valuable reply.
|
|
|
|
|
In addition to what Hamid said, you will also have to set the raster operation code to R2_XORPEN when you draw your line. Doing so you will be able to draw the line once to show the line, and then draw it again in the same spot to erase the line. Use CDC::SetROP2(R2_XORPEN) in your drawing code.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks Arends ,thanks for your valuable reply.
|
|
|
|
|
You can use Rubberbanding[^] to create the line. (Ivor Horton is the best author to reference for sample graphics applications using MFC )
To interact with it you could simply use CRectTracker with a few modifications if you don't mind a simple rectangular hit test region. This is more than adequate for forms based line manipulations since a good portion or the lines will be vertical or horizontal.
If you need more advanced hit testing that is not restricted to a rectangle, such as for an advanced graphics application, then you will likely need to roll your own tracker class.
|
|
|
|
|
Thanks bob,
Thanks for spending your valuable time for getting me to the conclusion page.
|
|
|
|
|
I am looking for something that I have not been able to find.
1. example code that analyzes the colors in a bitmap, and
2. code that organizes the colors sampled into a palette of 16x16 or 32x32 or something like that.
can anyone help?
|
|
|
|
|
Richard Perrine wrote: example code that analyzes the colors in a bitmap
Define 'analyze'. To just gather colours, I'd probably go through the bitmap a pixel at a time and store the RGB triplet for each pixel into a std::set . That would make it easy enough to get a list of the unique colours in the bitmap.
To cull the colours to a smaller number (as required if you want to define a fixed palette for the image), you'd use some form of colour quantisation[^].
Richard Perrine wrote: code that organizes the colors sampled into a palette of 16x16 or 32x32
Maybe you can get some ideas from this color picker control[^]? The source is available.
|
|
|
|
|
|
|
Hi,
I want to use an explorer in my program (it's a C++ program) which is under Windows CE platform. I want to know that is it applicable or not? If yes, does any body know how can I do it?
(If here is not a right forum, Sorry, I don't know under which topic I should write my question)
Thanks a lot
Sincerely Yours
Miss_F
|
|
|
|
|
Miss_F wrote: an explorer
What do you mean by 'an explorer'? If you mean manipulating the filesystem/namespace using explorer interfaces like IFolderView [^], then I suspect you're out of luck. If you mean a treeview, then you should be OK[^].
|
|
|
|
|
I mean adding Internet browsing (using browser) functionality to my application.
|
|
|
|
|
|
|
A trackBar->Value in a form has to be read out from a thread. I read so many articles, but still I got a problem.
I use a delegate which should return me the value of the trackBar position:
delegate int DelegateTrackBarCallBack(System::Object ^object);
I started the Thread by a ParametriziedThreadStart after a Button-Click
Thread^ oThread = gcnew Thread(gcnew ParameterizedThreadStart(&ProcessCANMessage::CAN_Thread::CANThread));
In CANThread I do
target_velocity=Get_TrackBar1_Value(object);
with
int ProcessCANMessage::CAN_Thread::Get_TrackBar1_Value(System::Object^ object)
{
CAN_Anbindung::Form1^ form;
form = (CAN_Anbindung::Form1^)object;
int trackBar_Value;
if (form->trackBar1->InvokeRequired==false)
{
trackBar_Value=form->trackBar1->Value;
}
else
{
CAN_Anbindung::Form1::DelegateTrackBarCallBack ^d = gcnew CAN_Anbindung::Form1::DelegateTrackBarCallBack(Get_TrackBar1_Value);
form->Invoke(d, gcnew array<system::object^>{form});
}
return (trackBar_Value);
}
During debugging the correct value is assigned to trackBar_Value. But when leaving Get_TrackBar1_Value trackBar_Value is set to "0".
Any ideas what to do?
|
|
|
|
|
Member 3919138 wrote: Any ideas what to do?
Post to the C++/CLI[^] forum, as that's what you're using?
From what I can understand of your message, you're expecting trackBar_Value to keep its value in two different invocations of Get_TrackBar1_Value ? Nope - local variables don't do that unless they're static. However - doesn't Invoke return the return value of the delegate? So you could do something like this?
trackBar_Value = form->Invoke(d, gcnew array<system::object^>{form});
You might need some casting to convert Invoke 's return value from System::Object to int - wouldn't know - I've never really used .NET, never mind C++/CLI.
|
|
|
|
|
I tried this befor
I got an error
1>.\ProcessCANMessage.cpp(74) : error C2440: '=': 'System::Object ^' kann nicht in 'int' konvertiert werden
|
|
|
|
|
Did you convert as shown in this article[^]?
int z = 44;
Object^ o = z;
int y = *reinterpret_cast<int^>(o);
|
|
|
|
|
I will try that. Thanks for your answers and help!
I used a code which shown in one of the articles from this forum which helps to control 4 Progressbars in a Form from 4 Threads.
See: http://www.codeproject.com/KB/mcpp/managedsafethreads.aspx[^]
It works fine, since the delegate function seems to be recalled until the InvokeRequired-property is false. in this case the progressbars can be controlled directly in the thread by "form->progressBar1->PerformStep();"
In my case I want to get the Value (Position) of the trackBar-component. So if the delegate function is called 2 times we have a recursive calling of the same function. I assumed that the return value is then overwritten by the previous call of my function "Get_TrackBar1_Value(object)".
I will let you know about the result.
|
|
|
|
|
Everything is working fine...
Thanks again!
|
|
|
|
|
Hi,
i m taking help from
http://www.codeproject.com/KB/dialog/wizard2000.aspx[^]
article its very gud article of wizard.
i m having 8 pages,there are no. of controls present.
if i run the application than its works fine but after some its look like hang or its not responding.
i m checking the memory usage from task manager than i have noticed that in thisapplication when i reached the last page of wizard the the memory of application constant.
but in my application after reached on last page,if i coninously click on back or next button than memory is still increase i think thats why it becomes not responding and looks like hang the applicaton.
please help me for this.
i m waiting for your reply.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Seems you have the problem mentioned here[^]
|
|
|
|
|
In this example property sheet not use to add property pages.
here the class is used for add pages is derived from CDialog base type class.
now what can i do.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|