|
I need to redraw composite control each time when Enabled stock property was changed.
Composite control do not use OnDraw method foor displaying itself, so technique for traditional controls is not applicable.
Or give me an example of working composite control with Font and Enabled property support
This is my property map:
BEGIN_PROP_MAP(CADialog)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
PROP_ENTRY("AutoSize", DISPID_AUTOSIZE, CLSID_NULL)
PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
PROP_ENTRY("Font", DISPID_FONT, CLSID_StockFontPage)
PROP_ENTRY("TabStop", DISPID_TABSTOP, CLSID_NULL)
END_PROP_MAP()
|
|
|
|
|
How can I make a hash map with an std::string for a key? VC++ .NET barfs, complaining that it cannot convert from type 'std::string' to 'size_t'.
Why couldn't Science, in the long run, serve
As well as one's uncleared lunch-table or
Mme X en Culottes de Matador? James Merrill
|
|
|
|
|
I don't know how to do this but you need to write a hash function.
John
|
|
|
|
|
I found this on a web search:
#include <iostream>
#include <string>
#include <hash_map>
using namespace std;
namespace std
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
hash_map <string, int> months;
int main(void) {
months["january"] = 31;
months["february"] = 28;
return 0;
}
John
|
|
|
|
|
Here's the hash function I've been using:
namespace std {
template<>
size_t hash_compare<string>::operator()(const string &s) const
{
unsigned long retv = 0;
for (string::const_iterator iter = s.begin();
iter != s.end(); ++iter)
{
retv = 5 * retv + *iter;
}
return size_t(retv);
}
} There's probably a better way to do it, though.
- Mike
|
|
|
|
|
The other ways, of course, to get working hash_map s would be to either
- use STLPort (where
hash_map and hash_set have a hash comparison function defined for std::string s - and also you get nice features like debug mode, which tells you when you've made boo-boos like pushing an iterator outside a container, or used mismatched iterators)
- Upgrade to VS.NET 2003. It cost me GBP19 (USD30 roughly) and was worth every penny - especially for the way more compliant compiler and faster IDE (well, I think it is - subjectively).
Of course, the solution in the other posts is rather more immediate
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Here's how Java get a hash code for the string. The algorithm should be fine:
/**
* Returns a hash code for this string. The hash code for a
* <code>String</code> object is computed as
* <blockquote><pre>
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* </pre></blockquote>
* using <code>int</code> arithmetic, where <code>s[i]</code> is the
* <i>i</i>th character of the string, <code>n</code> is the length of
* the string, and <code>^</code> indicates exponentiation.
* (The hash value of the empty string is zero.)
*
* @return a hash code value for this object.
*/
Best regards,
Alexandru Savescu
<small>P.S. Interested in art? Visit <a href="http://www.geocities.com/mirunadutescu" target="_blank"> this! </a></small>
|
|
|
|
|
Thanks to everyone who helped explain this. Thanks especially for the code fragments.
Why couldn't Science, in the long run, serve
As well as one's uncleared lunch-table or
Mme X en Culottes de Matador? James Merrill
|
|
|
|
|
I am having to implement a help key in a Property Sheet. The sheet consists of several pages derived from COlePropertyPage, and one that is an ATL implementation and is derived from IPropertyPageImpl.
I've managed to insert a help button by calling SetHelpInfo from the COlePropertyPage derived pages, but this button is disabled/greyed out when the ATL page is selected.
The property sheet container is not directly within my control as it is created via BEGIN_PROPPAGEIDS. How can I either force a global enable of this Help button, or enable it directly from the ATL page? Or any other imaginative solution would do!
Thanks
Debbie
|
|
|
|
|
I have problem with IWebBrowser2 or IwebBrowserApp.
I use ATL/COM .exe module build a program and
hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (void**)&m_spIE);
To create IWebBrowser2
Later on I can call IWebBrowser2/IwebBrowserApp's Navigate sussefully.
But when I create a thread in my ATL/COM , use that thread
to call IWebBrowser2::Navigate or IwebBrowserApp::Navigate
It pop up error.
If it is IWebBrowser2::Navigate, it pops up Error MessageBox
Said "Run time error"
when I use IWebBrowserApp::Navigate, it don't work without any error messagebox.
When I debug. I found After I call Navigate. It throw out a error
message "0x800401F0: (no name)"..
But if I not call from the new create thread, nothing is wrong.
BTW, I use Visual C++ 5.0 without microsoft SDK.
My computer's IE is IE 6.0 Sp1.
Help...
Thank you
|
|
|
|
|
I have a question that I've found the answer to but still can't figure out.
I've got this class, let's call it "cat". Cat has many methods, but the only one i care about right now is "get_age()" which returns the cat's age as a float. Now I have a vector of these cats and wish to sort that vector by the cat's ages.
cats.sort() by cats.get_age().
I know I have to do something like:
bool apredicate(const cat& a, const cat& b)
{
return &a.get_age < &b.get_age;
}
I am completely confused on how this works (can't get it to work either). Could someone please show be a coded example... maybe then I'll get it
Thank you!
greg
|
|
|
|
|
Greg1421 wrote:
cats.sort() by cats.get_age().
Vectors don't have a sort method, but lists do. To compensate you will need to use the generic STL sort algorithm.
Greg1421 wrote:
return &a.get_age < &b.get_age;
The predicate should call cat::get_age() rather than taking its address.
Make sure that cats::get_age() is declared const, if it isn't the predicate won't compile.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class cat
{
public:
cat(int age)
: age_(age)
{
}
int get_age() const { return age_; }
private:
int age_;
};
bool apredicate(const cat& a, const cat& b)
{
return a.get_age() < b.get_age();
}
int main()
{
vector<cat> v;
v.push_back(cat(0));
v.push_back(cat(2));
v.push_back(cat(1));
v.push_back(cat(4));
v.push_back(cat(3));
v.push_back(cat(9));
sort(v.begin(),v.end(),apredicate);
for(int i = 0; i < v.size(); i++)
{
cout << v.at(i).get_age() << endl;
}
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
I made an ActiveX control. The control haven't input focus for keyboard, but I want to do something when keyboard event occurs. And now the control can't receive the WM_KEYDOWN or WM_CHAR message. What can I do? Please help me?
stanley
|
|
|
|
|
I have implmented a CAxDialogImpl derived dialog, and have defined the caption for the dialog in the resource editor. However, I would like to change the title bar caption dynamically. Though easily done with standard CDialog derived dialogs, this seems to be an effort with CAxDialogImpl derived dialogs. Anyone have any clues?
|
|
|
|
|
|
Well, I would agree that it should, but its not. The SetWindowText() function is returning success, but the caption remains unchanged. Did I mention that I'm creating this ATL based dialog modally?
"Never play drinking games with coffee"
|
|
|
|
|
Example Code
HRESULT MyFunc([in, optional] VARIANT Param1,
[out, optional] VARIANT Param2)
I'm concerned about the client calling sunctions which have optional arguments....my client in cpp raise an error on number of parameters. Any one with time n clue
Swimming in the fish bowl.
|
|
|
|
|
1. I think [out] and [optional] are not compatible
2. C++ client does not translate COM optional argument to C vararg. Instead, for each optional argument you want to skip you have to pass VARIANT of type VT_ERROR with a value of DISP_E_PARAMNOTFOUND
so in you case it would look like
VARIANT vOptional;
vOptional.vt = VT_ERROR;
vOptional.scode = DISP_E_PARAMNOTFOUND;
pMyObj->MyFunc(vOptional, vOptional);
|
|
|
|
|
Example Code
HRESULT MyFunc([in, optional] VARIANT Param1,
[out, optional] VARIANT Param2)
I'm concerned about the client calling sunctions which have optional arguments....my client in cpp raise an error on number of parameters. Any one with time n clue
Wimming in the fish bowl.
|
|
|
|
|
Example Code
HRESULT MyFunc([in, optional] VARIANT Param1,
[out, optional] VARIANT Param2)
I'm concerned about the client calling sunctions which have optional arguments....my client in cpp raise an error on number of parameters. Any one with time n clue
Wimming in the fish bowl.
|
|
|
|
|
Hi,
I have made a collection component, that inherits the functionallity from ICollectionOnSTLImpl ( but no fancy enumerator implemented).
My question is.. how can I use that in my MFC application ?, I'm using fancy smart pointers
<br />
MNEMOSYNELib::IXMLProjectsPtr pIProjects;<br />
<br />
Hr = pIProjects.CreateInstance(__uuidof (MNEMOSYNELib::XMLProjects));<br />
If I call something like "get_count" it fails... but how can I change to the collection interface without having to make a classic query interface, and for which Interface should I ask ?
Thanks in advance, greetings
Braulio
|
|
|
|
|
In my project,I add a ATL object .The wizard add a ***.rgs file to my project.I open the file ,the text like this :
HKCR
{
NoRemove AppID
{
{2C0CA281-E28B-41CA-838C-C7D1BEA311D2} = s 'NewEn'
'NewEn.EXE'
{
val AppID = s {2C0CA281-E28B-41CA-838C-C7D1BEA311D2}
}
}
}
Who can tell me what these words mean?
|
|
|
|
|
Can I add some information into it?
|
|
|
|
|
This is information that is added into the registry to "register" you COM server with Windows.
HKCR = HKEY_CLASSES_ROOT
The rest of the information is assigning an unique identifier to your COM exe server, so whe you make a CreateInstance call it knows which application to load.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|