|
|
Thanks for the infos
|
|
|
|
|
|
Hello,
Still struggling with the linker. Many things have been solved, but still (at least) one left.
So, I have mylib.lib, which is written in C and I'm using it in my console program, that uses also MFC. I have the source code of that lib, but I can't change it. I use makefile for compiling and linking.
I have (among others) compile options /TP /MT, so it's C++ and multithreaded. With a linker option /NODEFAULTLIB:libc.lib, I avoid crashes with libcmt.lib.
So I compile my selfmade files and then link the .obj files and .libs and I get error LNK2001: unresolved external symbol _errno. The place where I get this error from is in one file in mylib. I checked, that it includes header errno.h.
If I remove linker option /NODEFAULTLIB:libc.lib, this error of _errno disappears, but I get lots of errors, because libc and libctm define same functions. Or if I make it single threaded, the problem is with _begingthreadex and _endthreadex.
I don't understand. Why doesn't the linker realize errno? Could it be because of messing with C and C++?
-Janetta
|
|
|
|
|
The way out of this dilemma is to have both componentes (the MFC program and the lib) compiled for the same version of the C run-time library. Go to the project settings for your MFC app and select (in the first tab) "Use MFC in a static library". Then go to the C/C++ tab, category "Code generation" and set "Use run-time library" to "Multithreaded". Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Janetta wrote:
Could it be because of messing with C and C++?
Yes it could. Try doing this:
extern "C"
{
#include "header_written_in_C_used_from_c_plus_plus"
}
This will inform the C++ compilers to use C calling conventions, not C++ ones which are by default.
Best regards,
Alexandru Savescu
|
|
|
|
|
I have a toolbar that under certain conditions i may need to diable an item.
how can this be done?
the only set function i can find is SetButtonInfo.
i tried to change the state of the toolbar button to point to an id with out a function. i noted if i do that as i am building the toolbar and did not yet attach a function to it that is shows diabled.
i tried the following
CToolBar* pBar = &m_wndToolBar;
if (pBar != NULL) {
pBar->SetButtonInfo(11,ID_NULL,TBBS_BUTTON,11);
}
this had no effect on the toolbar.
thank you for any help
|
|
|
|
|
The easiest and cleanest way to handle enabling/disabling any UI item in an MFC app is by using update handlers, which can be added with the ClassWizard.
Search in MSDN for things like the ON_UPDATE_COMMAND_UI macro and CCmdUI objects, and have a look at MFC Technical Note 021 (TN021 in the index). The automatic disabling of toolbar buttons and menu entries without command handlers is also dealt with through the same architecture, and can be disabled by setting the m_bAutoMenuEnable member of your main frame window to false. See also Mike Dunn's C++ FAQ q.7.1
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
I don´t know myself at all with Toolbars, but after a short read of the msdn, i think you could try the following :
Create a CToolBarCtrl object, assign it the return value of pBar->GetToolBarCtrl where pBar is your CToolBar . Then you have access to the EnableButton() and other functions of the same kind using the CToolBarCtrl .
Hope this helps...
~RaGE();
|
|
|
|
|
Hi,
I am trying to develop a Resource editor like VC++ .
It seems that the way a CDialog is displayed while running
in applications and while CDialog is shown in the Resource
Editor.
Can some tell me what is the difference.
Thanks,
San
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
|
I have both Visual Studio C++ 6.0 and .Net Enterprise Architect installed on an Win 2K platform. Whenever I use the 6.0 debugger it launches the .Net debugger instead. Does anyone know a work around for this bug?
Thanks in advance for your assistance.
Amos Kermisch
|
|
|
|
|
I think .NET puts itself as the default JIT debugger. But if I have a VC 6.0 project set a breakpoing somewhere in the source files and hit F5 then my project is debugged under VC 6.0
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexandru,
Just wanted to thank you...your suggestion works great!
Amos
|
|
|
|
|
i know it's easy for win2000, how abut win98
|
|
|
|
|
In Win2000 the transparency is built in to the GDI. These functions don't exist on Win98, so there's no simple way.
You could cheat, by screengrabbing the area that your window will appear, and then drawing this over the top of your window with an alpha effect, but this will be fairly cpu intensive (unless you start doing directx stuff)
Basically you can do it for very little overhead on Win2000, as it's built in. On Win98 you're going to have to make your own transparency code, which will be complicated, and probably slow
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
some collections are called dictionay, bag ...
we know how to implement list, array because we know their physical structure. but if i want to develop a dictionary or bag class, what are physical stories about them?
i guess a dictionary just = array or list + key.
am i wrong? do u have suggestions?
thx
includeh10
|
|
|
|
|
if i remember my smalltalk, a 'bag' is a collection that you can put any number of things into, duplicates are allowed. but when you take something out, tho, you have an equal chance of getting any of the objects out - it's random.
a dictionary, i think, is an associative map (item + key, lookup by key).
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
my question is about their physical view and to to implement them, not how to use.
thx
includeh10
|
|
|
|
|
bag = array with random accessor function.
dictionary = ...well, there are a thousand ways to do it. use std::map
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
In STL a dictionary is implemented as a map (maps keys and values) and is a binary tree (a red-black tree under the VC implementation). Thus the tree is kept always sorted by its key, so we have logarithimc insertion and look up time.
A map cannot have duplicate keys. However if you want to use duplicate keys you can used multimap (also part of STL).
Another implemntation is to use a hash_map or hash_multimap (not part of the STL library but most of the STL implementations offer them - VC offers it in VC.NET).
A hash works like this:
you provide a hash function that "hashes" the key and thus you have a hashvalue. your hash_map has a vector of lists. The size of the vector may depend on a given hash size. When you want to insert your object, you hash the key, and with the obtained hashed value you insert the object in the in the list indexed at the hash value (i.e if your hashed value is 5 then you insert your element at the tail of the 5th list).
When you want to lookup an object, given the key, you hash the key and then you perform linear search at the list of the index of the hashed value to find your object
If the hash size is big enough you will have lists with only one element then the insertion and lookup time will be O(1), provided that your hash function is fast enough. (it was O (log(n) for a map). However if your hash size is too small (or you have too many elements in the dictionary) then your lists will be very big so inserting and looking up can be slow. That's why people use map and hash_map also.
Best regards,
Alexandru Savescu
|
|
|
|
|
I want to create an COleDispatchDriver through class wizzard to call an object within a ATL project.
I have tried implement the object both as a CCmdTarget and an Atl Simple object. But to no joy.
When my Project calls the createdispatch method of COleDispatch driver it just fails.
Can anyone offer me any advice.
Cheers
Richard
|
|
|
|
|
I can now call "simple Atls objects" in Atl Projects, i hadn't called AfxOleInit.
But i still can't call CCmdTargets which are in a Atl Dll projects.
|
|
|
|
|
I have a class in DLL and a derived class in another dll. The first class contains a std::map <int, CString> that is populated in a method of its class.
After the map is filled, iterating throgh it in the base class works fine.
In the second dll I do this:
1. Call the method from the first class to fill the map. It works fine, I can iterate through the map like for (it = mymap.begin(); it!= mymap.end(); it++)
2. Now I am back in the second dll (of the derived class). And I use the same code to iterate through the map. The first element of the map is displayed correctly. Troubles occour when getting to the second element (i.e. when doing it++)
I have checked to see if the map has not been damaged accross dlls. This is not the case (all the pointers are the same and point to the same data - the _Right, _Left, _Value structures point to the same addresses in the first and second dll.
The problems seems to be in the _Inc member function
void _Inc()
{if (_Right(_Ptr) != _Nil)
_Ptr = _Min(_Right(_Ptr));
else
{_Nodeptr _P;
while (_Ptr == _Right(_P = _Parent(_Ptr)))
_Ptr = _P;
if (_Right(_Ptr) != _P)
_Ptr = _P; }}
The first element of the map is a leaf (it's the lowest) in the tree so the execution should go on the else branch, right?
In the first dll, _Right(_Ptr) is different from _Nil and, so the execution goes on the else branch, but in the second dll (of the derived class) it says they have the same value although I have checked _Right (_Ptr) returns the same value in both cases.
Any idea, CG, Joaquin and other STL gurus, please help!!!
Best regards,
Alexandru Savescu
|
|
|
|
|
My wild stab in the dark would be that if they both point to the same address, then _Nil is what's changing and therefore it seems your copying only the first element between dll's. _Nil obviously changes, have you actually asked the map how many elements it has ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
How can _Nil be changing since it is defined static?
static _Nodeptr _Nil;
and is initialized with 0
template<class _K, class _Ty, class _Kfn, class _Pr, class _A>
_Tree<_K, _Ty, _Kfn, _Pr, _A>::_Nodeptr
_Tree<_K, _Ty, _Kfn, _Pr, _A>::_Nil = 0;
I have checked, it has the same number of elements and I can find them all if I put the map in the watch and expand the _Left, _Right and _Parent correspondents...
Best regards,
Alexandru Savescu
|
|
|
|