I want to know how exactly to add the button at the top of the search to note as the search criteria is for example asc to desc or vise versa
![kk

that is here i need a icon beside the colors
to show me when i search weather the sorting is asc to desc or vice versa

please help is appreciated
need to very badly and very urgently as well

Attachments kk[.JPG 8.92 KB

your attachment is unreadable. what compiler, operating system, and gui library are you using? But it should be a simple thing to place a button wherever you want it and add the text "up" or "down", but maybe a checkbox would be better suited for that.

sas

this might help?

operating system is xp

visual studio

the work of this button should be like if i click on it then based on the asc or desc it has to place the arrow up or down

Just add a button, set it's property to hold a picture, then add the picture of the arrows. In the OnClick event handler change the picture from up to down, or vice versa and set a BOOL flag accordingly. The hardest part is finding the two pictures you want to use, or use the icon editor to create your own.

how to Add arrow to indicate column sorted on by and order asc/desc in c++ was my question

Edited 4 Years Ago by ranam

I told you how in my previous post. There are all sorts of things you can do with MFC buttons -- here are some of them. Look though those links and you will probably find some example code.

Here are some google links for you to study

Edited 4 Years Ago by Ancient Dragon

how to incorporate the arrow button in exisitng application as shown in the above attachment :(

    if (pGrid->GetSortColumn() == nCol && nRow == 0)
    {
        CSize size = pDC->GetTextExtent(_T("M"));
        int nOffset = 2;

        // Base the size of the triangle on the smaller of the column
        // height or text height with a slight offset top and bottom.
        // Otherwise, it can get drawn outside the bounds of the cell.
        size.cy -= (nOffset * 2);

        if (size.cy >= rect.Height())
            size.cy = rect.Height() - (nOffset * 2);

        size.cx = size.cy;      // Make the dimensions square

        // Kludge for vertical text
        BOOL bVertical = (GetFont()->lfEscapement == 900);

        // Only draw if it'll fit!
        if (size.cx + rect.left < rect.right + (int)(2*GetMargin()))
        {
            int nTriangleBase = rect.bottom - nOffset - size.cy;    // Triangle bottom right
            //int nTriangleBase = (rect.top + rect.bottom - size.cy)/2; // Triangle middle right
            //int nTriangleBase = rect.top + nOffset;                 // Triangle top right

            //int nTriangleLeft = rect.right - size.cx;                 // Triangle RHS
            //int nTriangleLeft = (rect.right + rect.left - size.cx)/2; // Triangle middle
            //int nTriangleLeft = rect.left;                            // Triangle LHS

            int nTriangleLeft;
            if (bVertical)
                nTriangleLeft = (rect.right + rect.left - size.cx)/2; // Triangle middle
            else
                nTriangleLeft = rect.right - size.cx;               // Triangle RHS

            CPen penShadow(PS_SOLID, 0, ::GetSysColor(COLOR_3DSHADOW));
            CPen penLight(PS_SOLID, 0, ::GetSysColor(COLOR_3DHILIGHT));
            if (pGrid->GetSortAscending())
            {
                // Draw triangle pointing upwards
                CPen *pOldPen = (CPen*) pDC->SelectObject(&penLight);
                pDC->MoveTo( nTriangleLeft + 1, nTriangleBase + size.cy + 1);
                pDC->LineTo( nTriangleLeft + (size.cx / 2) + 1, nTriangleBase + 1 );
                pDC->LineTo( nTriangleLeft + size.cx + 1, nTriangleBase + size.cy + 1);
                pDC->LineTo( nTriangleLeft + 1, nTriangleBase + size.cy + 1);

                pDC->SelectObject(&penShadow);
                pDC->MoveTo( nTriangleLeft, nTriangleBase + size.cy );
                pDC->LineTo( nTriangleLeft + (size.cx / 2), nTriangleBase );
                pDC->LineTo( nTriangleLeft + size.cx, nTriangleBase + size.cy );
                pDC->LineTo( nTriangleLeft, nTriangleBase + size.cy );
                pDC->SelectObject(pOldPen);
            }
            else
            {
                // Draw triangle pointing downwards
                CPen *pOldPen = (CPen*) pDC->SelectObject(&penLight);
                pDC->MoveTo( nTriangleLeft + 1, nTriangleBase + 1 );
                pDC->LineTo( nTriangleLeft + (size.cx / 2) + 1, nTriangleBase + size.cy + 1 );
                pDC->LineTo( nTriangleLeft + size.cx + 1, nTriangleBase + 1 );
                pDC->LineTo( nTriangleLeft + 1, nTriangleBase + 1 );

                pDC->SelectObject(&penShadow);
                pDC->MoveTo( nTriangleLeft, nTriangleBase );
                pDC->LineTo( nTriangleLeft + (size.cx / 2), nTriangleBase + size.cy );
                pDC->LineTo( nTriangleLeft + size.cx, nTriangleBase );
                pDC->LineTo( nTriangleLeft, nTriangleBase );
                pDC->SelectObject(pOldPen);
            }

            if (!bVertical)
                rect.right -= size.cy;
        }
    }

    if (HasButtonsInCell ())
        rect.DeflateRect (3, 0, 0, 0);

    // We want to see _T('&') characters so use DT_NOPREFIX
    DrawText(pDC->m_hDC, GetText(), -1, rect, GetFormat() | DT_NOPREFIX);

    pDC->RestoreDC(nSavedDC);

    return TRUE;
}

Don't you have the slightest idea how to write MFC program? Or use VC++? If not, then google for tutorials. I already gave you lots of links, its up to you to study and learn.

Edited 4 Years Ago by Ancient Dragon

This question has already been answered. Start a new discussion instead.