|
It's been a while (and I don't have my book with me) but iirc, the std::algorithm (and I think sort is in that) didn't require the structure to be a std::list. (I seem to recall standard arrays being able to be sorted with std as well.)
|
|
|
|
|
// switch pObj1 and pObj2 between them ... but how ?
Try it :
void SortDrawObjects(CDrawObjList& cList)
{
for (int i = 0; i < cList.GetCount(); i++) {
POSITION pos = cList.GetHeadPosition();
while (pos) {
POSITION posFirst = pos;
CDrawObj* pcFirst = cList.GetNext(pos);
if (pos) {
POSITION posSecond = pos;
CDrawObj* pcSecond = cList.GetNext(pos);
if (pcFirst->m_position.left > pcSecond->m_position.left) {
cList.SetAt(posFirst, pcSecond);
cList.SetAt(posSecond, pcFirst);
}
pos = posSecond;
}
}
}
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Well , it's work great ! Thank you very much !
|
|
|
|
|
An algorithm after all is just a modus operandi. As long as a collection class, irrespective of the library that is part of, provides mechanism to insert and remove elements at any location, all the algorithms can be implemented. The performance may be not as expected due to the implementation of the classes themselves.
What I am trying to say is, if you understand the algorithm and read the documentation for the collection class, it must not be difficult at all.
|
|
|
|
|
|
|
If you are wedded to MFC, at least use a CObArray instead of a CObList. The algorithim will be much cleaner and faster with a smaller memory footprint.
For instance ...
typedef CTypedPtrArray<<CObArray, CDrawObj*>> CDrawObjArray;
then create the array ...
CDrawObjArray ObjArray;
const unsigned int nSize = 5;
ObjArray.SetSize(nSize);
fill the array ...
for(int i = 0; i < nSize; i++)
{
CDrawObj* pObj = new CDrawObj(CRect(ptOrigin,sizeRect));
ObjArray[i] = pObj;
}
and finally sort the array (using the most inefficient sorting algorithim known to man).
for(int i = 0; i < nSize; i++)
{
for(int j = i; j < nSize; j++)
{
unsigned int nPrevious = ObjArray[j-1]->m_position.left;
unsigned int nCurrent = ObjArray[j]->m_position.left;
if(nPrevious > nCurrent)
{
CDrawObj* pObj = ObjArray[j-1];
ObjArray[j-1] = ObjArray[j];
ObjArray[j] = pObj ;
}
}
}
modified 17-Jan-19 15:57pm.
|
|
|
|
|
Michael Waters wrote: ...(using the most inefficient sorting algorithim known to man).
I can think of one worse.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Guys , you're overcome me with solutions !!! I want to kindly thank you ! I was learn something here .And after all , seems to must begin use STL ... I will googling and see what I find ... You are very kind !
|
|
|
|
|
hi,
I don't know Graphics in vc++? i want how to develop line graph in vc++?
Win32 GUI use line graph is possible?
any sample code or url please give me
Regards,
M.Mathivanan
|
|
|
|
|
I don't understand from your query on which base do you want to draw the line on.
If it's a Win32 SDI application, you can get the device context and then draw the lines on the graph using the MoveTo and LineTo API's.
I am a HUMAN. I have that keyword (??? too much) in my name........
_AnsHUMAN_b>
|
|
|
|
|
|
Are you using MFC or pure win32 API ? If you are using MFC, take a look at my sig for a charting control I wrote for codeproject.
|
|
|
|
|
|
pDC->MoveTo(x,y);
while(oPoint in points collection)
{
pDC->LineTo(oPoint.x,oPoint.y);
}
onwards and upwards...
|
|
|
|
|
ms chart active x control can be alternative
|
|
|
|
|
Hi all,
I hope that i posted my question in the right place
I would like to know, if there is some examples or courses to create a little application using RTP in order to visualise my webcam video throught the browser. (on localhost host or network)
I'm using VS2005 + DirectShow.
Thank you.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
well.. one option is to develop it as an activex control, and use in browser. You may first make it as a stand alone application to refine the working, then convert it as activex. Google for samples, you will get like this.
|
|
|
|
|
ok ...
Do u mean that i have to create an activex probably a one for capturing frames and then add the activex to the browser or what exactly?$
I'm new to DirectShow and i'aint a wed developper.
could u explain more plz ?
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
yes, exactly. Using Directshow is easy to learn, and you shouldn't be a web developer to develop and test an activex control.
|
|
|
|
|
but how could i add an activex to a web page browser ?
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
|
I saw these lines in an example code. I am not clear about it.
CListVieiw::OnInitialUpdate();
CListCtrl & theCtrl = GetListCtrl();
My questions are
(1) Is GetListCtrl()( on the second line) a member function;Which class does it belong to?
(2) what does the '&' mean at the left hand side?
|
|
|
|
|
cy163@hotmail.com wrote: (1) Is GetListCtrl()( on the second line) a member function;Which class does it belong to?
See here.
cy163@hotmail.com wrote: (2) what does the '&' mean at the left hand side?
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thank you DavidCrow for your reply.
I wonder what exactly is the role of GetListCtrl(); generate a instance of ListCtrl? or sth else?
|
|
|
|