|
According to MSDN[^], you must pass the address of a 'comparison function' (have also a look at the provided code sample).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
using this method also gives same error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int (__stdcall CItemDlg::* )(LPARAM,LPARAM,LPARAM)' to 'PFNLVCOMPARE'
|
|
|
|
|
Please show us both the code and the error.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
m_List.InsertColumn(0,"Name",100,100);
m_List.InsertColumn(1,"Number",100,100);
m_List.InsertItem(0,"Item1");
m_List.SetItemText(0,1,"2");
m_List.InsertItem(1,"Item2");
m_List.SetItemText(1,1,"3");
m_List.InsertItem(2,"Item3");
m_List.SetItemText(2,1,"1");
I want to sort these items according to second column i.e "number" column
int CALLBACK CItemDlg::MyCompareProc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort)
{
UNREFERENCED_PARAMETER(lParamSort);
return (int)(lParam1 - lParam2);
}
void CItemDlg::OnBnClickedButton1()
{
m_List.SortItems(&CItemDlg::MyCompareProc, 0);
}
when i compile this code, it shows this error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int (__stdcall CItemDlg::* )(LPARAM,LPARAM,LPARAM)' to 'PFNLVCOMPARE'
Thanks for helping
|
|
|
|
|
MyCompareProc cannot be an ordinary member of the class (must be a global function or a static class member). We should blame MSDN for providing a broken code sample.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Should be:
m_List.InsertColumn(0,"Name",100,100);
m_List.InsertColumn(1,"Number",100,100);
int x = m_List.InsertItem(0,"Item1");
m_List.SetItemText(x,1,"2");
x = m_List.InsertItem(1,"Item2");
m_List.SetItemText(x,1,"3");
x = m_List.InsertItem(2,"Item3");
m_List.SetItemText(x,1,"1");
int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
UNREFERENCED_PARAMETER(lParamSort);
return (int)(lParam1 - lParam2);
}
void CItemDlg::OnBnClickedButton1()
{
m_List.SortItems(MyCompareProc, 0);
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
I want to display image which is in fits format in my application like an image viewer.
thanks in advance
|
|
|
|
|
Have you tried checking out the libraries on the NASA website[^]?
|
|
|
|
|
I need to get desktop rect, which excludes start-bar, how?
|
|
|
|
|
includeh10 wrote: I need to get desktop rect, which excludes start-bar, how?
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
Just for completeness, if you wanted to include the taskbar:
RECT rect;
::GetWindowRect(::GetDesktopWindow(), &rect);
|
|
|
|
|
If you have multiple monitors, the method mentioned by Hans Dietrich may not work. In a multiple monitor environment, different settings may require special treatments. For example, on some systems, the task bar may not be stretched to the full width of the whole virtual desktop. In this case the work area on those monitors without the task bar will be larger than the one with the task bar. Then again the task bar can be stretched to all monitors. This means the work area cannot be simply expressed by a rectangle.
You can find more information on virtual screen by searching the web.
|
|
|
|
|
This is probably a dumb question, but I was examining the vector class source code (Visual C++ 2003) and noticed some method definitions that were confusing me. After some thought, I got on this tangent about template definitions in general and started to question why all the method definitions needed to be "templatized" (for lack of a better word) if some methods never dealt directly with any "typename" for the template.
In other words, if a template method (lets call it "GetVersion") did something simple like return an integer constant, irregardless of any "typename", and the class was instantiated twice, lets say...
CMyClass<int> first;
CMyClass<float> second;
and then somewhere in the code, each instance (first and second) calls "GetVersion", I'm assuming only one copy of "GetVersion" gets created by the compiler.
If this is true, why does the method definition need to "templatized"? Or Does it need to be "templatized"?
The code for vector almost appears to be taking advantage of some technique that only bothers with template syntax for the methods that deal with any typename but I could easily have been deceived. Is it possible to define non-templatized methods in a template class or am I just off my rocker? Or does the compiler require template syntax for every method? (So far, I only get compiler errors if I try to omit template syntax for such methods so I'm guessing I've strayed from reality a bit here but I thought I'd ask anyway)
|
|
|
|
|
This is a very good question.
I do think that a function within a templated class, such as GetVersion() will indeed be implemented for each class the template gets instantiated for, creating redundand code. If this is not the case I'd really like to know from someone more knowledgable than me.
You can however avoid it with various tricks, such as moving the function(s) in question out of the class definition, or into a base class that doesn't depend on a template class argument.
|
|
|
|
|
I've thought about it a bit, and found something that forces the compiler to create individual methods, even if it considers the code of the entire project. What I am thinking of is Template specialization: any code using a template class may define a specialized implementation of an otherwise 'non-templatized' method, and that might happen even outside the project the compiler is looking at:
template<class C>
class MyClass {
public:
int version() const { return 1; }
};
#include "MyClass.h"
template <>
class MyClass<int> {
public:
int version() const { return 2; }
};
|
|
|
|
|
Yeah. I'm now realizing I really lost track of reality on this one.
I think I got turned around a bit trying to think about it too much (thinking is such a dangerous pastime).
C# has been rotting my brain lately so I'll blame it on that.
|
|
|
|
|
No worries. It was a good question. I had to think for quite a time to come up with a good reason.
While all you could get out of preventing the redundand template instantiation would be a few bytes less in your executable, I appreciate that some people at least consider the possibility to avoid unneccessary clutter. If all software developers were like you, Windows would run on 500 KB rather than 5 GB.
|
|
|
|
|
Of course the compiler will generate two 'GetVersion ' methods, one for each class.
Please note, they have even different signature.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You're right. I don't know what I was thinking.
I think my reality got altered a bit looking at the source code for vector and I started to believe the world was flat.
Thanks for helping straighten me back out!
|
|
|
|
|
Hi I m trying to load the dll using LoadLibrary which works fine.
But for one of the method paramter is an object of class which is refered inside the dll . So in this case in my client app how do i refer the .h file which is already refered in the dll inside ?
As i m trying to link dynamically how does header file references are dealt with ?
Thanks
|
|
|
|
|
When you want to call a function that is in a DLL - whether it is dynamically loaded or not - you must tell the compiler what the function parameters are. The is what the .h file does.
|
|
|
|
|
See if this[^] helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You repeatedly use the term 'refer', but didn't really clarify at which point you have trouble making the connection between your application and the DLL - it could be at compile time, at linking time, or at run time:
1. compiling
Any parts of the DLL that you are supposed to use from outside have to be declared in header files, using the 'extern ' keyword. These header files then have to be included in the application that wants to use the DLL. This is neccessary for the compiler to understand the format of the function calls and the types of the parameters and return values.
2. linking
Once your application is successfully compiled, the linker will try to resolve the function calls into the DLL. This requires information about the already compiled DLL, which is contained in a file called '<dll-name>.lib'. You have to specify this Lib file (and possibly it's path) in the linker options. With the help of this Lib file, the linker will look up the offset of the function within the DLL and encode this into the function call.
3. running
At run-time your application will eventually call the LoadLibrary function that you specified. Provided the DLL can be found at the same location as your application is, or else, if you provided a path, at that path's location, the DLL will now be loaded into memory. When your code runs into a DLL function call, the system will use the linker-provided offset to invoke the correct function within the DLL.
|
|
|
|
|
Hi all,
i m using a access file as databse with odbc connection.
and use CRecordset class to perform action over database file and its tables like add,update,movenext etc.
some time in access file table filed have value like "#Error" and when i select this row or column access file popup the error message "Not a valid bookmark"
When I compacted/repaired it I received these errors in a table called MSysCompactError:
-1206 Could not find field 'Description'
-1053 Could not find field 'Description'
please help me how can i resolve this and prevent to occur this error.
thanks in advance.
|
|
|
|
|
Sounds like an Access issue rather than a C/C++/MFC issue.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|