|
How do you set the item data of a list item ?
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
The values you're passing into the CListCtrlEx::CompareItems() method are the item data values of the items to be compared, not their indexes (which you've obviously realised, because your code is using FindItem to search for the LPARAM - sorry for stating the obvious!). Are you sure that the item data values are set correctly and uniquely for each list item?
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Thank you for your help,
That was 'obviously' the problem...
Greetings,
Niko
|
|
|
|
|
If you're after every single message, you might be interested in PreTranslateMessage() . It's called in the window that receives the message, which then calls PreTranslateMessage in its parent window, all the way up to the main frame window.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Seems to work, but not all messages.
For example, when I press Ctrl+4, or any other SysCommand, the Frame Window doesn't get any message.
What I basically want to do is monitor inter-mdichild messages (switching windows, closing a window, etc). It seems that the messages stop at the Client Window and doesn't travel up to the Frame Window.
Some other ideas
|
|
|
|
|
|
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
|
|
|
|