|
IN MFC...
Plz guide me how can i apply a bmp on Tab control on all tabs including the upper tab label. Current application has bitmapped dialog box which is used in each tab but the label of tabs should also be bitmapped.
|
|
|
|
|
You have 2 options
1) You have to set the WS_OWNERDRAW style.
Check the MSDN library docs for ownerdrawn controls.
This allow you to draw the labels but not the empty space
where there are no labels.
So this option may not suit you at all.
2) If you want to customize the entire area of the tab, including borders,
you have to subclass the tab control and handle WM_PAINT yourself.
I strongly recommend this article that explains how to do this: http://www.codeproject.com/tabctrl/customtab.asp
|
|
|
|
|
I have a CListCtrl with 3 columns
I am using this function to know when someone clicks on the column button
void OnColumnclickList2(NMHDR* pNMHDR, LRESULT* pResult)
the problem is it is sorting the list according to the first column no matter what column button i press what sshould i do to make it sort according to the column button i press?
In other word how can i know which column button has been pressed?
/\|-||\/|/\|)
|
|
|
|
|
Take a look at CListCtrl::SortItems[^]
If you pass both the list control pointer and a column index in some struct as the dwData parameter to SortItems, your compare function can obtain the text for the appropriate column and use it for the comparison.
struct SORT_DATA
{
CListCtrl* pList;
int nColumn;
}
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
SORT_DATA* pData = (SORT_DATA*) lParamSort;
CListCtrl* pListCtrl = pData->pList;
int nColumn = pData->nColumn
CString strItem1 = pListCtrl->GetItemText(lParam1, nColumn);
CString strItem2 = pListCtrl->GetItemText(lParam2, nColumn);
return strcmp(strItem1, strItem2);
}
void CListCtrl_SortItems(CListCtrl* pList, int nColumn)
{
SORT_DATA data = {pList, nColumn};
pList->SortItems(&MyCompareProc, (LPARAM) &data);
}
You could easily extend this to allow for sorting order (ascending/descending), sort on multiple columns, etc.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
refer to this link to know why this sortitem() doesn't work anyway
/\|-||\/|/\|)
|
|
|
|
|
Halawlaws wrote:
refer to this link to know why this sortitem() doesn't work anyway
Hmm.. yep. You are right. But it's easy to fix, isn't it? You just need to set lParamData (while inserting items) with a pointer to the object from which you obtained the strings, and modify the compare function accordingly.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
ok i ll try that thx
/\|-||\/|/\|)
|
|
|
|
|
The way I've handled this in the past was something like:
BEGIN_MESSAGE_MAP(CMyView, CListView)
ON_NOTIFY(HDN_ITEMCLICK, 0, OnItemclick)
END_MESSAGE_MAP()
int CALLBACK CMyView::CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM )
{
int nReturn = 0;
CInfo *pInfo1,
*pInfo2,
*pTemp;
pInfo1 = (CInfo *) lParam1;
pInfo2 = (CInfo *) lParam2;
if (true == m_bAscending)
{
pTemp = pInfo1;
pInfo1 = pInfo2;
pInfo2 = pTemp;
}
switch (m_nSortColumn)
{
case 0:
nReturn = pInfo1->m_strName.Compare(pInfo2->m_strName);
break;
case 1:
nReturn = pInfo1->m_lUSANumber - pInfo2->m_lUSANumber;
break;
case 2:
if (pInfo1->m_timeBirthdate < pInfo2->m_timeBirthdate)
nReturn = -1;
else
nReturn = 1;
break;
}
return (nReturn);
}
void CMyView::OnItemclick(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
CListCtrl &ctrlList = GetListCtrl();
m_bAscending = ! m_bAscending;
m_nSortColumn = phdn->iItem;
ctrlList.SortItems(CompareFunc, 0);
*pResult = 0;
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
when I create the edit as a child window????
But it blinks when it's created through a
dialog resource.
I have used spy to view the window style of my edit inside a normal
window, and the edit control inside a dialog box. Both styles are
exactly the same.
Why doesn't the caret blink?
Thank you for any help
|
|
|
|
|
I found out the problem. I was doing something wrong in my code. Too much detail to explain here.
|
|
|
|
|
Hi. I am using a listview in a win32 api application...
I want to set the text of the listview item.
I do this:
//
LvItem.pszText= (LPSTR)_bstr_t(RsITEM(pSet,"FILE_NAME"));
//
it displays some junk characters... The listview works normally and there isnt any problem with the database nor with the data collection (made with RsITEM(pSet,"FILE_NAME") ) ...
Thank you very much in advance for your answers...
Well... I am a beginner ...
|
|
|
|
|
You can't simply cast a BSTR to LPSTR because they are different formats.
Try using one of ATL conversion macros
LvItem.pszText = OLE2T(_bstr_t(RsITEM(pSet,"FILE_NAME")));
Or assign the BSTR to a CString, which will do the conversion for you
CString sAux = _bstr_t(RsITEM(pSet,"FILE_NAME"));
LvItem.pszText = sAux;
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Ok I used the second one and it worked! Thanks a lot!
Well... I am a beginner ...
|
|
|
|
|
can some1 help me to draw a pie chart using MSCHART control.I am unable to obtain sufficient info from the msdn docs.
|
|
|
|
|
Are you using API, MFC or net?
Well... I am a beginner ...
|
|
|
|
|
I'm also very confused with the poor information about using MS Chart in VC++ provided by msdn. Look at these examples, they'll help you:
Using the MS Chart control in VC++[^] and MS Chart[^]
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
thanx 4 the piece of info.but i happened to see that info earlier.i seem to have a serious problem in inderstanding the COleSafeArray .can u plz explain why we create an array DWORD numElements[] = {10, 10}; .is that a one dimensional array or something else.im totalled.plz mail me at
rajeshvv007@yahoo.com if u aint mind.
thanx 4 helpin.....
|
|
|
|
|
Taking the first example, COleSafeArray is the chart data and simplyfing it's:
<br />
COleSafeArray saRet;<br />
SAFEARRAYBOUND sab[2];
<br />
sab[0].cElements = NUM_DISCS;
sab[1].cElements = m_iCols;
sab[0].lLbound = sab[1].lLbound = 1;
<br />
saRet.Create(VT_BSTR, 2, sab);
m_msChart.SetChartData(saRet.Detach());
I hope it helps,
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hello,
I would like to add a new member-function to all the controls of different kind in my dialog, e.g. CEdit, CButton and so on.
Since they are all derived from CWnd I would like to know if there is a possibility to insert a new class "CWndEx" between CWnd and the control class, so that e.g. CEdit is not longer derived directly from CWnd but from CWndEx. This way I could add a new member function to CWndEx so all the my controls would inherit this function?
Seems to be a newbie question, yes?
Thank you very much...
|
|
|
|
|
i thought of extending this in CEdit Class.. so not a newbie.. he he..;P
|
|
|
|
|
No, this is not directly possible in the C++ language. I've wanted to do this myself on occasion along with making some necessary functions virtual that for some inexplicable reason are not.
But there are ways around it to get the job done. Depending on what you'd like to achieve the simplest thing you can do is just to use a global function that takes a CWnd as a parameter. You won't be able to access protected members, but for most cases this generic function should be able to achieve what you want. It's not as pretty certainly, but the most important thing is to get the program to work.
Another approach (at least for objects you directly create) would be to multiply inherit. This wouldn't apply to objects that are dynamically created, however.
|
|
|
|
|
Bill Buklis wrote:
Another approach (at least for objects you directly create) would be to multiply inherit. This wouldn't apply to objects that are dynamically created, however.
Actually I was trying to get this work for three days, I derived classes from CEdit and CButton and both from my own class "CInputCtrl" too, like this:
class CEditEx : public CEdit, public CInputCtrl
{
public:
void MyFunc();
}
class CInputCtrl
{
public:
void MyFunc();
}
But now, when running this code
CInputCtrl* pCtrl = (CInputCtrl*)GetFocus();
pCtrl->MyFunc();
the CInputCtrl::MyFunc() is called. If only I was able to "virtualize" the MyFunc() of CEditEx everything was OK.
Can I change something so it works the way I expect? I already read about multiple inheritance but could not find something helping me further on...
Thank you very much again...
|
|
|
|
|
With the code listed, you created two completely separate functions:
CEditEx::MyFunc and CInputCtrl::MyFunc. If you have a pointer to a CInputCtrl, it will call CInputCtrl::MyFunc.
To use multiple inheritance, what you want is for the code on the 2nd derivation to be more generic and not window oriented. Ths second branch should not be derived from CWnd, CObject, etc.
Sort of like this:
class CGeneric
{
virtual bool DoSomething();
}
class CMyEdit : public CEdit, CGeneric
{
bool DoSomething();
};
The CGeneric class won't have direct access to any windowing features. It's similar to using the global functions, but with more inheritance control.
|
|
|
|
|
This has always been one of those areas I get completely confused in - maybe somebody can set me straight...
I use a lot of "overlay" modeless dialogs on other dialogs (add extra functions, etc.), and I can get them to work fine, until the screen resolution is changed, then they don't match. I've tried lots of combos of ClientToScreen, etc., but no luck so far - heres the code I generally use:
// Modeless dialog #1 (which is itself an overlay on main dialog).
CRect rc;
GetWindowRect(&rc);
ClientToScreen(&rc);
// m_EQS is the overlay on the overlay.
m_EQS->SetWindowPos(&wndTop, rc.left+355, rc.top-5, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
This works fine, until the screen resolution changes, then the overlay window is somewhere else where it should not be. Usually on top of a different window.
Please help a tired old programmer, who apparently has a pea brain when it comes to coordinate mapping
|
|
|
|