|
Hello,
try to use "SetItemData()" instead of "xx.lParam=xx".
Marco
|
|
|
|
|
Thanks ! It really helps. Now the 2 parameters passed in are different.
But, I still got trouble on sorting result. The sorting result is very weird.
I have traced in my compare function and I thought it should get the right result but actually it doesn't.
My Compare function is something like the following:
int CALLBACK CSortListCtrl::CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamData)
{
int r = 0;
CSortListCtrl* pListCtrl = reinterpret_cast<csortlistctrl*>( lParamData );
ASSERT( pListCtrl->IsKindOf( RUNTIME_CLASS( CListCtrl ) ) );
CString strItem1 = pListCtrl->GetItemText( lParam1, pListCtrl->m_iSortColumn );
CString strItem2 = pListCtrl->GetItemText( lParam2, pListCtrl->m_iSortColumn );
if ( pListCtrl->m_bSortAscending ) // ascending sort
r = strcmp( strItem1, strItem2 );
else
r = strcmp( strItem2, strItem1 );
return r;
}
I have tested an original sequence of alphabet of a specified column like:
M, H, D, V (4 chars)
If ascending sort on 1st time, it would get right result like: D, H, M, V
but when next time I want to sort descendingly, it is wrong !! (i.e, the sequence is NOT V, M, H, D, but something else instead. )
And another run of ascending sort, it got another weird sequence again !!
(I have modified adding items to something like the following:
/// insert sub-item 0
m_CtrlEntryList.InsertItem( iItemNo, szString );
/// insert sub-items 1~3
m_CtrlEntryList.SetItem( iItemNo, iSubItemNo, LVIF_TEXT, szString, 0, 0, 0, 0 );
/// as you suggested, this lParam should be unique, right ?
m_CtrlEntryList.SetItemData( iItemNo, ( DWORD ) iItemNo );
|
|
|
|
|
What exactly is the difference between a dialog box and a form? Why would one use the one and not the other?
|
|
|
|
|
By a form do you mean Winforms, or an SDI/MDI app ? A dialog does not allow you to have floating toolbars, nor does it support doc/view. A dialog is best for simpler apps, or apps that do not use doc/view.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Sorry, stupid of me..
I meant to ask why one would choose to derive a class from CFormView instead of CDialog. My fellow programmer asked me and I realized I have no idea why one would need to use CFormView at all. We are both new at Visual C++ programmers and there are still many holes that need filling.
|
|
|
|
|
No worries - I should have realised. The answer is the same - floating toolbars, doc/view, etc, all useful for a more complex app, but a CFormView allows you to mix that with designing a window full of controls in the resource editor.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
thank you!
|
|
|
|
|
I want to have a line in 80th column of my view which is derived from CView. This is to be used as an 80th column marker. I will be grateful to you if anybody can help me in solving this problem.
|
|
|
|
|
You're going to have to draw it in the erasebackground call, the issue is figuring out where it is, if you have a non-fixed width font.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Sir,
I cannot find anything called erasebackground function anywhere in vc++. Can you suggest me a similar function which i can use with my view which is derived from CView. My exact problem is like this. Suppose, I am drawing a line at 80th column, and if I am increasing the font size, the line comes to some 30th or 35th column and not 80th column. This I want to update on change of the font size. I have a function OnChangeFont() which will be executed when user changes the font.
Thank You and expecting a positive reply.
Krishna Raj.
|
|
|
|
|
WM_ERASEBKGRND, from memory.
You'll need to measure the string to figure out where to draw your line, and as I said, that will not always be 80 columns because different characters have different widths, all you can do is shoot for an average.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
How to correctly implement subj?
|
|
|
|
|
Hi,
I want to use map<string,string> in my program but I don't want it sort for me and I would like to have a NoCase comparation. Can I do that? how?
Thanks
|
|
|
|
|
No. A map is always sorted.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
error C2065: 'MIIM_STRING' : undeclared identifier
Why am I getting this error? I didn't before, but suddenly all my system-tray projects do. I've got WindownXP and I've installed the Microsoft Platform SDK (May 2002). Is there something wrong with my VC++ settings, since MIIM_STRING should exist since Windows98 or something. I am also experiencing other weirdnesses like this:
'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int
This error suddenly came up in one of my projects which previously compiled just fine. The param is a DLGPROC which is declared (and the definition is similar) like this:
INT_PTR CALLBACK ConfigDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
This is correct according to the Platform SDK Documentation. INT_PTR is a long obviously but DialogBoxParamA wants it to be an int. What's up?!
And I'm sure there are other things; I haven't bothered opening up all my old projects just to check...
Please help me. I'm desperate
Sprudling
|
|
|
|
|
For some reason neither the VC++ SP5 upgrade or the Platform SDK install managed to setup the correct include and lib directories in VC++.
Sprudling
|
|
|
|
|
Hello,
simple question:
Can i make a shadow in my custom cursor, like the standard cursor's ?
OS : Win2000
Marco
|
|
|
|
|
Hi, i'm using VC++ 6.0 I have add the file "myprogram.exe" to my project's resource and the file's ID is "IDR_FILE1" I want a program with a button that, when pressed, will copy the file "myprogram.exe" to the targeted directory of my chosen, for example "c:\\test " What code should I write in the on button pressed function to make this work.
thank you so much for your help.
|
|
|
|
|
Check the codeproject MFC FAQ for code allowing to choose a directory. Then CopyFile(oldfilename,newfilename,FALSE); .
Hope this helps...
~RaGE();
|
|
|
|
|
I try do a webbrowser with WebBrowser2 control but I get some errors or uninstpected behaviour. I cannot find any tutorial how to use WebBrowser2 with MFC.
Do you know about any?
My main problem is, that when I press back button and there aren't any more back .html pages. A message box pops up from nowhere. How can I handle this?
|
|
|
|
|
I need to supply a data structure to a new thread as parameter when a create it. How can I do that ??
I have declared the thread as:
DWORD WINAPI CopyFolder(void* p_pvThreadParameter)
and I create it using the following instruction:
l_hCopyFolderThread = CreateThread(NULL, 0, CopyFolderThread, this, 0, &l_dwThreadId);
As fourth parameter, as you can see, I have supplied "this": so the tread can used public members of the class that has created it. This methods work correctly but i don't like it !!!! I prefer to supply to each thread its parameters !!!
I have tried to supply a point to a data structure (casting it to void). But this doesn't work !!!!
How can I do ??
Thank you very much !!!
Cristiano Galeazzi
|
|
|
|
|
I have tried to supply a point to a data structure (casting it to void). But this doesn't work !!!!
Why does it not work? It should.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This solution compiles and runs but...
if I put a break-point inside the thread function and I check the
content of the supplied structure I find that its is empty or it
contain not valid data !!!!
Cristiano Galeazzi
|
|
|
|
|
I guess the problem is that the data you're passing is allocated on the stack instead of the heap, something like:
MyDataStructure data;
CreateThread(...,&MyDataStructure,...); The problem with this approach is that data is destroyed as soon as your function existis from the scope the variable is declared in. You will need to allocate the structure in the heap with new (and don't forget to make the thread delete it when no longer needed.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you very much!!! It works as you says!!!
Cristiano Galeazzi
|
|
|
|
|