|
Hello dear friends,
I've browser plugin(toolbar) application & using VC++ 6.0.
I've included a dialogbox resource in the resource file and a class for this dialogbox.
When I use DoModal() to display the dialogbox the GetLastError() returs
"Error BC31019: The specified image file did not contain a resource section"
The problem here is i don't understand.In the text mode the resource
script shows all the things right.Please help me out.
ritz1234
|
|
|
|
|
first test whether ur program initilazing com library. that is coinitialize(NULL).
let me give some piece of code if above method is not solved.
|
|
|
|
|
Are you working with any icons?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I created a MFC Regualr DLL using shared MFC. DLL contains 4 functions which are exported using __declspec(dllexport). Now in the client application i tried to make use of this DLL. two of exported functions are imported using __declspec(dllimport). They are working fine.
Now i tried to make use of third function using LoadLibrary and GetProcAddress. This time i am getting NULL pointer instead of function pointer. Again i placed extern "C" while exporting the function and tried to make use of it.This time i am getting the function pointer and every thing is fine.
Usage of extern "C" makes it work fine. Can any one explain me what actually happening here?
Thanks in advance...
|
|
|
|
|
Because your two first functions probably don't have any arguments. When you are using extern "C", it means that the function should be exported as a C function. In C, there is no function overloading so a function is identified only by its name. In C++, you can overload a function (a function with the same name can have different arguments). Which means that the name is not enough to identify the function. Thus, in C++ is introduced what is called name mangling: the types (and number) of parameters of the function are also used to identify the function. When you use GetProcAddress, you need to use the mangled name of the function (if there's no argument, the mangled name is the same as the function name).
So, by using a C function, you avoid the name mangling.
Hope it makes sense.
|
|
|
|
|
__declspec(dllexport/dllimport) uses C++ naming convention, so that the name exported from the dll is name mangled with C++ language convention, so when you try to get the address of the exported function using GetProcAddress(), the function name string won't match with name of the exported function which is decorted with c++ style, when using extern "C" linkage specifier naming convention used is that of C language which has the same undecorated name as that of the function.
|
|
|
|
|
Hi,
It is very clear now.
Thanks for your reply.
|
|
|
|
|
If you don't use extern "C" the name of the function is mangled the C++ way (you can see this effect viewing your DLL with Dependecy Walker ). That means you need to pass the mangled name to GetProcAddress() .
On the other hand, using extern "C" makes the function have C linkage, hence, roughly speaking, without mangling.
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
|
|
|
|
|
HI,
I got the point.
Thanks for your reply.
|
|
|
|
|
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
|
|
|
|
|
one last solution to avoid using "extern C" is to put a .DEF file in your dll project, which tells to export a symbol as you name it in the file.
|
|
|
|
|
Hi,
Thaks for your solution.
|
|
|
|
|
Hi,
I have ListView with 4 colom, I want to fill color in 3rd coloum. How can I do this?
|
|
|
|
|
|
Replacement message:
ListView is just a CListCtrl wrapped in a View class, so look at CListCtrl articles here on CP. Luckily, it's a later control and more easily part-owner-draw-able, unlike ListBoxes.
Iain.
-------------------------
Original:
I don't know the answer off the top of my head - but I bet you'd have to do some level of ownerdraw. Luckily, the ListView is a later control, and more easily part-owner-drawable. (Unlike ListCtrl).
Have a look on the articles here on CP. You may not find an exact answer, but I bet someone has an article with (eg) different fonts in different rows / columns that could give you a string hint.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
modified on Tuesday, May 13, 2008 9:53 AM
|
|
|
|
|
Iain Clarke wrote: Luckily, the ListView is a later control, and more easily part-owner-drawable. (Unlike ListCtrl).
How so?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This was a little bit off the cuff - but ListCtrl has been around since my windows 3.1 programming days - ListView is all new fangled and windows 95ish.
Just look at the API for the common controls - with its NMCUSTOMDRAW, multi stages etc.
I didn't say it was *easy* in an absolute sense - just a relative one.
On the other hand, I usually either use ListCtrl for a simple list o' stuff, or jump straight to Maunder's original grid control - the early seed of codeproject. I've yet to give serious time to the new Dundas' open sourced one, as it would require too much rewiring of too many parts of my code.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: ...ListCtrl has been around since my windows 3.1 programming days...
Hmm, I don't recall seeing a list control until at least Windows 95. Prior to that, it was all listboxes.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Prior to that, it was all listboxes.
That's where we're going adrift.
Replace my texted ListView with ListCtrl, and my ListCtrl with ListBox...
Phew. I was wondering how we were disagreeing.
(earlier message edited)
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I am creating a class as follows...
extern"C" class Logger
{ public:
string message;
void logMIN(string message);
void logMID(string message);
void logMAX(string message);
};
extern "C"
void Logger::logMIN(string message)
{
.....
}
extern"C"
void Logger::logMID(string message)
{
.....
}
extern"C"
void Logger::logMAX(string message)
{
......
}
I call these functions from main. Following is the error that I get on building... Please help me resolve this
Logger.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl log(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >) " (?l
og@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z)
...THANKS </char></char,struct></char></char,struct>
|
|
|
|
|
I just reported your message for posting the same thing over and over. You were given answers when you asked this question yesterday.
See here and here
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
yes but it was not resolved..
|
|
|
|
|
If it was not resolved, it could be only because you did not give sufficient information at first, and then you did not care to reply to the ones who posted to you. You could have replied to them, explaining what you tried and what was the outcome.
Is it hard to understand that if you post the same thing again, you will get the very same reply?
Also, I find it very difficult to understand things like "it is not working", "it was not resolved", etc.,
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
It was either Benjamin Franklin or Albert Einstein that defined insanity as doing the same thing over and over again and expecting different results.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|