|
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
|
|
|
|
|
Cpt Rick wrote:
// 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);
GetWindowRect returns screen coordinates, but you are applying a ClientToScreen transformation on them. Later, those coordinates are used in the call to SetWindowPos, which for child windows expects client coordinates. I've never worked with those "overlay" dialogs, so I'm not sure whether m_EQS is a child window of the dialog or not. In any case, here's my suggestion.
void YourDialog::SomeMethod()
{
const CSize szOffset(355, -5);
CPoint ptPosition(0,0);
ptPosition += szOffset;
ClientToScreen(ptPosition);
m_EQS->SetWindowPos(&wndTop, ptPosition.x, ptPosition.y, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
}
However, using a fixed offset in pixels is problematic. Why don't you use one of the dialog controls as a reference to where to locate the overlay? You may add a not visible static control and use it as a place holder.
void YourDialog::SomeMethod()
{
CPoint ptPosition(0,0);
CWnd* pPlaceHolder = GetDlgItem(IDC_PLACEHOLDER);
ASSERT(pPlaceHolder);
if (pPlaceHolder)
{
CRect rPos;
pPlaceHolder->GetWindowRect(rPos);
ScreenToClient(rPos);
ptPosition = rPos.TopLeft();
}
ClientToScreen(ptPosition);
m_EQS->SetWindowPos(&wndTop, ptPosition.x, ptPosition.y, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose:
I tried the second example you gave (BTW: the m_EQS window is a child window of the dialog above it), and got the same results as before when changing the resolution higher (the overlay is down and to the right quite a bit).
The placeholder I used was a static text on the second level window, which I hide when showing the overlay.
Neither of these two windows uses a title or frame - the order they look like is:
-Main Dialog Window for the app
-EQWindow - child of above
-m_EQS - child of above child
It almost seems as if I'm getting the coordinates of one of the other windows in the app when it goes to display the overlay, as I have multiple modeless dialogs being used in this app...
|
|
|
|
|
Let me see if I understood:
Both m_EQS and the placeholder are children of the same window, and that window is an EQWindow , right?
Now, did you tried the sample code in a method of EQWindow , or in a method of the main dialog window? If the former, I can't see why its failing. If the latter, you'd need to modify the calls to ClientToScreen and ScreenToClient so that they refer to the EQWindow (e.g.: m_eqw->ScreenToClient(rPos); and m_eqw->ClientToScreen(ptPosition); )
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Yes to the first question.
Yes to the second, all code dealing with m_EQS is within the EQWindow class.
Like I said, this is why I can't fathom coordinate mapping, it doesn't seem to work as per MSDN rules... I should add that it works until I change the screen resolution, then it fails.
|
|
|
|
|
How can I get a message when clicked on an already selected item in the treeview control? Could anybody help me? Thanks in advance!
|
|
|
|
|