|
Since sorting is a big issue, this is how I do it:
struct MyData { int nVal, CString str };
for (int i = 0; i < nItems; i++) {
MyData *pData = new MyData;
pData->nVal = nIntVal;
pData->str = "Hello";
int nRow = list.InsertItem(i, pData->str);
list.SetItemData((DWORD) pData);
} now sorting on integer value would be
#define SORT_INT_ASC 1
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
MyData *pData1 = (MyData*) lParam1;
MyData *pData2 = (MyData*) lParam2;
if (lParamSort == SORT_INT_ASC)
{
if (pData1->nVal < pData2->nVal) return -1;
if (pData1->nVal > pData2->nVal) return 1;
return 0;
}
}
list.SortItems(CompareFunc, SORT_INT_ASC);
The whole idea is to place useful 'user data' in every list item. Cause these are what you can sort on.
This is from heart, I bet the compiler has a few things to say about it
|
|
|
|
|
Thankyou ..I think that was my problem I had sort Ascending selected in the styles property
|
|
|
|
|
what are good books for learning atl ?
i've got "beginning atl com programming" by Gimes Stockton Reily and Templeton
but its pretty much unreadble
any suggestions?
bryce
|
|
|
|
|
I found the same thing and bought Jonothan Bates 'Creating Lightweight Components with ATL'. I never looked back.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I've been using Developer's Workshop to COM and ATL 3.0 by Andrew w. Troelsen. The first few chapters cover the basics of COM, and then he dives into how ATL works. Troelsen covers important features such as ATL's smart pointer template class, how the "BSTR" type is wrapped by ATL, and then finishes up with the basic windowing functionality in the ATL.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
I've just bought 'COM+ Programming, A Practical Guide using Visual C++ and ATL'; I'm only a couple of chapters in but I'd recommened it.
It's on Hewlett-Packard Professional Books if you want to check it out
Dylan Kenneally
London,UK
|
|
|
|
|
|
Hi all. I'd like to know how to get CPU and memory information by C++. Is it neccessary to use MFC? How can I do it without MFC?
Thanks!
|
|
|
|
|
I created a VC++ application under Win'98. I try to run under Win'2000 , i cannot...Why?
Also from the workspace i cannot execute the application.
|
|
|
|
|
Manikandan wrote:
I created a VC++ application under Win'98. I try to run under Win'2000 , i cannot...Why?
It's because there is something wrong with your code.
Manikandan wrote:
Also from the workspace i cannot execute the application
Probably the same cause.
(HINT: Try to be a bit more specific)
|
|
|
|
|
...if the code is wrong it should not run under win'98, right?
|
|
|
|
|
It just might. I used a ON_NOTIFY_EX macro where I should have used a ON_NOTIFY the other day. Worked like a charm on ME in both Debug and Release build. It also worked fine on w2k in Debug build, but created access violations in Release. So, there is one example. There are probably thousends of others.
|
|
|
|
|
Yes, you are right. But this one look strange to me. I don't know what to do.
Just now i tried to implement something from,
http://www.codeproject.com/w2k/access_api.asp
//////////////////////////
#define _WIN32_WINNT 0x0500 // allow Win2000 specific calls
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#undef _WIN32_WINNT // allow CFileDialog to build with
///////////////////////////
this stuff too not working...
anyway i try to fix the problem. thank you very much for responding.
|
|
|
|
|
For my opinion it's compiled wrong ... you try compile for 32platform and unicode format; because i guess that your pc(with win2000) ... it's disabled a option for loading your bilt format(for win98).
|
|
|
|
|
Hi,
I would like to make an Active Document Server with Active Document Container capebilities.
In short I have tried to modifiy the Microsoft MFCBIND (http://msdn.microsoft.com/code/default.asp?URL=/code/sample.asp?url=/MSDN-FILES/026/001/803/msdncompositedoc.xml) sample to be a Server also. I want the MFCBIND to be running in a container (Word, Excel or myown) and still be able to use MFCBIND as a container for other Active Document Servers.
Have you tried something like that - nested Active Documents? I am really lost and I am about to think it is not possible..... but even the Visual Studio Wizard lets you define such projects but they dosen't seem to work correct....
Any help will be highly appreciated...
Best regards
Nyrup
|
|
|
|
|
i abstract data from database ,but this could create a temp file .i want real-time abstract the data,it will chock up my C tray .i want know how to delet the temp file in vc?
if (pb.Open("mymib"))
{
CBisheSet*PB=new CBisheSet();
PB->Open(CRecordset::snapshot,NULL);
PB->MoveLast();
m_interfacename=PB->m_Name;
UpdateData(false);
ac="data total:";
dbltotal=PB->m_Total;
ab.Format("%-10.2f",dbltotal);
ac.Insert(18,ab);
m_listdata.AddString(ac);
ac="";
|
|
|
|
|
A lot depends on how you are creating the temp file.
Have a look at DeleteFile on MSDN.
Michael
|
|
|
|
|
i would like to know if there is a predefined window class or control (or a free implementation) similar to iexplorer´s "mail" toolbar button, that is, it has a bitmap, an arrow on it´s right and it shows a context menu when clicked.
Thanks
Gabriel
sometimes truth it´s stranger than fiction
|
|
|
|
|
|
I was try to incorporate this cool TabCrtl software
... http://www.codeproject.com/useritems/mditabs.asp
into my project.
I followed the instructions and try to
build my project and I get that C1010 error?
I didn't change any code but merely added
the .h and .cpp to my project.
What am I doing wrong?
|
|
|
|
|
You need to make sure that the cpp file has the "stdafx.h" file included in it. this is the precompiled header file.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
1/ Open a CP account
2/ Post this question on the article in question.
Because you have opened an account, the author will get an email letting them know you asked the question.
BTW in this case, the problem is that the original article must have used automatic inclusion of precompiled headers, so go to the project settings and set them to automatically use stdafx as a precompiled header, instead of always doing so. Or #include "stdafx.h" at the top of the cpp file, but I presume he had a reason for not doing so in the first instance.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Hi.
Is it possible to enable/disable a message from the message for a time interval?
For example, let say I have a program that plays AVI files. For the first ten seconds, I want to disable the open button. I can disable a button. However, I found that if the user clicks on it while it is disabled, the framework keeps the message and class the message handler after I enable the button.
Is it possible to disable a button *completely*, or even better, ignore/unignore a specific message?
Thanks,
Kuphryn
|
|
|
|
|
m, the button is either disabled or not disabled. Possibly what is happening is the button is not even getting the mouse message until after it is re-enabled; ensure you are processing messages at an acceptable rate.
--------
Well actually they are sort of interesting Nish, on Nudes
|
|
|
|
|
You could remove all the WM_LBUTTONDOWN messages from the message queue before reenabling the button.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|