|
Thanks. I just realized I was using the wrong stream operator in this example. However, I still have issues if I try to replace this:
cout << "str4 is " << p->first.get() << " and str5 is " << p->second << endl;
with this:
cout << p->first.get();
I get the following errors:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const *' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Ax> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2676: binary '<' : 'const Node' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
The error is showing, you dont have < operator defined for the variable. I think while using an userdefined type as key, you should overload operator < in the class.
and,
map < Node, string > nodes;
then why you are creating pair of strings?
nodes.insert(make_pair(str, str2));
|
|
|
|
|
hi,
i am required to handle a BSTR string containing some embedded nulls. if I use ConvertBSTRToString to convert it to char pointer will it be safely stroing the Nulls in the char array?? if not then what is the solution.
thanks in advance
amit
|
|
|
|
|
I need to better understand what you are trying to do. A BSTR is a string. A special type of string, yes, but it is a string. Do you need to copy/convert it to a char array, a wchar_t array or a TCHAR array?
When you say "handle", what exactly do you have to do to/with it?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi James,
Thanks for replying here is the detail:
CONTEXT: I receive a Variant data as a VC++ callback function argument. This data has to be passed onto a Java application.
SCHEME: I am thinking of converting this data into a BSTR and then converting it to a (JNI) jstring. But there is no direct conversion from BSTR to jstring, so i need to convert it into char string.
CONCERNS:
(1)The only way to create a jstring, that I know of, is using a char array and JNI function NewStringUTF(char* str).
(2)When i use ConvertBSTRToString(char*) to convert a BSTR into a char*, what happens to the NULLs which may be a Binary/hex value '0' in the original Variant data. I need to preserve these embedded Nulls (binary/hex value 0) to be used in java apllication
amit
|
|
|
|
|
I avoid Java so I do not know how the NewStringUTF works. But I would hazard a guess that it stops at the first NUL character it finds, because the function does not take a length.
Finding the length of the complete data in the BSTR is easy. After that, I would be looking at the WideCharToMultiByte(...) function to transfer the entire contents of the BSTR to a char buffer. Finally, you will need some kind of convert-to-Java-string function that takes a length and would otherwise ignore embedded NUL characters.
However, I do not know if/how you can manipulate a string in Java that has embedded NUL s, so that might be all for nothing.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I am creating a BSTR using wchar* and then converting the BSTR into a char array. The lenght of created char array is coming incorrect in the output its showing 4 invariably.
void CEquipMain::varTest(){
wchar_t str[] = {'L',0x00,0x01,'B',0x00,0x08};
//crating a BSTR
BSTR bstrng = ::SysAllocStringLen(str,sizeof(str));
// creating a char array
char* hostData = _com_util::ConvertBSTRToString(bstrng);
// testing the char array
printf("length of hostData:%d",sizeof(hostData));
SysFreeString(bstrng);
bstrng = NULL;
delete[] hostData;
hostData = NULL;
}
Also please tell me how can i access the char 'B' inside the hostData array in this example. its failing if i try like "hostData[3]". I mean at what index to use??
|
|
|
|
|
I am writing an application which will determine the File opened through the Windows Open/Save as dialog . Example If a File is opened from Open/Save as dialog in Winword . I got an idea about OfnhookProc but i think that will be useful only when our application has a Open/Save as Dialog . Is there anyway to find File opened using default Windows open dialog .
Thanks
|
|
|
|
|
BOOL GetOpenFileName( LPOPENFILENAME lpofn );
include Windows.h
library Comdlg32.lib
it`s may be helpful...
|
|
|
|
|
Thanks . But i tried it is not working . I think that function is for invoking a Open/Save as Dialog from your App . U have any idea about what messages will be posted from the default Open/Save as Dialog ?
|
|
|
|
|
Write simple application with this function(GetOpenFileName) and test it by Spy++.
|
|
|
|
|
Hello all !
I have a custom drawn virtual list view (in icon view) to display thumbnails. Everything behaves as expected, except when I try to du multiple selection using shift+click or shift+cursor key. It selects an extra row of thumbnails, as if the end thumbnail was moved one row down and 1 column to the right.
If I intercept LVN_ODSTATECHANGED, the start and end numbers are wrong.
When I do ctrl+click, it works fine. If I remove OWNERDATA flag, it works fine. In details view it works fine. Do you have any ideas what this might be?
Best regards,
Jan
|
|
|
|
|
I am reading some code like this:
// the line below declares fGetType as a pointer
//to a function which takes an int type parameter
// and returns an int value, right?
typedef int (* fGetType) (int);
//other two declarations
static void SetColumnType(fGetType func) { ......};
int _List_Type( int col ){......};
//below is where I can not understand:
// the function _List_Type return an int type
//value, how can it be cast into the type
//fGetType which returns a pointer to int?
SetColumnType ( (fGetType)_List_Type );
--------------------
thank you very much!
-------------------
I am learning C++ and English
|
|
|
|
|
The cast (which might not really be required) works because the type fGetType is really specifying the signature of the function. In this case, that signature is "function taking an int that returns an int ". It does not return pointer-to-int , it only looks that way at first glance because of the asterisk used in the typedef .
The _List_Type function is already a function that takes an int that returns an int .
Here is the trick: function names, when they are being used to call a function, are really pointers behind the scenes. They point to the address of the start of the function. When you apply the parens to it, the parens become the "function call operator", and cause a jump to the beginning of the address of the function (and it starts being executed). Each function pointer has an implicit type, and that type is basically its signature (although things are a little bit different when dealing with C++ object members).
Take the following examples:
typedef int (*PFSomeFuncType)(int);
int SomeFunc( int iValue )
{
return( iValue + 42 );
}
double SomeOtherFunc( double iValue )
{
return( iValue + 42 );
}
int main( int iArgC, char *pArgVp[] )
{
DWORD dwFuncAddr = (DWORD)SomeFunc;
int iRet = 0;
iRet = ((PFSomeFuncType)dwFuncAddr)( 42 );
return( 0 );
} In the above example, the "type" of SomeFunc is int (__cdecl *)(int) , and the "type" of SomeOtherFunc is double (__cdecl *)(double) . Note that this looks a bit like the typedef above...
If you compile and execute the above code snippet, what do you think iRet will be equal to right before main(...) returns?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
thank you very much, james.
but I don't know wy I can't see where I can rate your post.
-------------------
I am learning C++ and English
|
|
|
|
|
How do you create nice looking GUIs with your own design ideas. For example, I have some button, tool bar, and even user interface ideas i can design in photoshop or 3d software, but I don't know how to use those graphics in my GUI designs. How do I do that? For example, has anyone noticed the windows skins and skins on other applications that make the user interfaces look so good. How is that done?
Thanks good people.
Peace,
BP
|
|
|
|
|
Create your own control classes and make them owner drawn, then you can draw them however you like.
Or if it's an established UI, such as the Outlook look and feel, buy a product like the Ultimate Toolbox and get it all out of the box.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks...and I have one follow up question.
How do I do that?
Thanks again...
|
|
|
|
|
I guess the easiest way would be to look at some articles on this site for things like custom buttons. They will be owner drawn and hopefully the articles will step through the process involved, and give you a feel for how much work is involved.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks...I appreciate it..
|
|
|
|
|
Hello,
Does anybody know how to obtain the FILETIME & FILESIZE from a file stored for example at:
http://www.people.zeelandnet.nl/marco01974/index.htm
http://www.people.zeelandnet.nl/marco01974/soldner4.pak
i searched trough msdn for some nice c++ code,but didn`t found what i was looking for.
Thanx.
|
|
|
|
|
Hi all,
I'm stuggling to resolve a memory leak. The code below gets updated every few seconds and changes the image displayed depending on the state of m_bOn..
CDC* pDC = CDC::FromHandle( lpDrawItemStruct->hDC );
if ( pDC )
{
CRect rect = lpDrawItemStruct->rcItem;
int nSavedDC = pDC->SaveDC();
pDC->SelectStockObject( NULL_BRUSH );
pDC->FillSolidRect( rect, ::GetSysColor( COLOR_BTNFACE ) );
if( m_bOn )
{
pDC->BitBlt( m_ptCentre.x, m_ptCentre.y, m_nWidth, m_nHeight, &m_dcMem, 1 * m_nWidth, 0, SRCCOPY );
}
else
{
pDC->BitBlt( m_ptCentre.x, m_ptCentre.y, m_nWidth, m_nHeight, &m_dcMem, 0 * m_nWidth, 0, SRCCOPY );
}
pDC->RestoreDC( nSavedDC );
}
I know the leak is here somewhere but I can't see what would be wrong! I'd really appreciate some help or some pointers in the right direction.
Many thanks
Tom
|
|
|
|
|
_Tom_ wrote: pDC->SelectStockObject( NULL_BRUSH );
Does this have a return value ? When you select your own brush, a pointer to the old brush is returned and you need to grab it and select it back in to avoid a memory leak.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I have been attempting to extract the "Menu Bar" layout of MS Office Apps, say MS Word. I would appreciate any help. Here is my problem description.
MS Office "Menu Bar" is not accessible using the normal Windows HWND handles. However, they expose the IAccessible interface, which I am trying to use. The handle to the top level "Menu Bar" is first obtained, call it h. The "AccessibleObjectFromWindow()" function is then used with the handle h, in an attempt to get an IDispatch pointer to the menu. Here is the code snip.
IDispatch** ppMenu = NULL;
DWORD OBJID_NATIVEOM = ((LONG)0xFFFFFFF0);
int r = AccessibleObjectFromWindow(h, OBJID_NATIVEOM, IID_IDispatch, (void**)ppMenu);
if (r == S_OK) {printf("S_OK\n");}
if (r == E_INVALIDARG) {printf("E_INVALIDARG\n");}
if (r == E_NOINTERFACE) {printf("E_NOINTERFACE\n"); }
However, the returned value is always E_INVALIDARG. The handle 'h' has been obtianed by (recursively) enumeraing all windows (and child windows) of the MS Word top level window and selecting the one with name="Menu Bar" and class="MsoCommandBar".
I believe, the id OBJID_NATIVEOM is required for Office apps, since they implement their own menu.
If someone has any thoughts or experience with this type of situation, I would really apreciate their help.
Regards,
Ishan.
|
|
|
|
|
I am new to opengl programming and am having trouble using this to display text on my screen. Can anybody help?
|
|
|
|
|