|
To compare what kind of strings (sorry, I'm not following )?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
<br />
string somecode;<br />
strstr and strcmp does not work for string unless its declared as a char
I dont know what to search for because i've already tried Google and nothing came up that refers to what im looking for.
|
|
|
|
|
Stuff like this?
strcmp(str.c_str(), str2.c_str());
wcscmp(str.c_str(), str2.c_str());
operator== ( <string> )[^]
basic_string::compare[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
You may try the following
CString s1, s2;
if ( s1.GetLength() != s2.GetLengtth() )
// Not equal
else
{
for( int i = 0; i < s1.GetLength(); i++ )
{
if ( (Byte) s1.GetAt(i) != (BYTE) s2.GetAt(i) )
break;
}
if ( i != s1.GetLength() )
// String Not equal.
else
// String equal.
}
Hope this will help u, if ur string length is small.
Regards,
Ram
|
|
|
|
|
Why do people continue to recommend using CString methods when the OP is using a string object? It just doesn't make sense.
Furthermore, why would you not just use CString 's Compare() , CompareNoCase() , or == operator ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Try using CString::Compare.
CString s1( "abc" );
CString s2( "abd" );
ASSERT( s1.Compare( s2 ) == -1 );
ASSERT( s1.Compare( "abe" ) == -1 );
Regards,
Paresh.
|
|
|
|
|
"string" class has overloaded "==" operator. You can directly use the == operator.
Eg:
string s1("hi");
string s2("hello");
if (s1==s2)
{
....
}
else
{
....
}
|
|
|
|
|
Hi All,
Does anybody out there know of any functionality that returns the maximum size of the recycle bin?, or is there any functionality to scale the size of the recycle bin?. Im aware of SHQueryRecycleBin, which will get me the current size information but what im after is finding out whether a file will fit into the recycle bin. In order to delete the file im using SHFileOperation but im not using and UI attached to it, nor do i want to as i would like to handle any messages by my own system.
Regards
|
|
|
|
|
|
I want to have a button with an icon and text. I used Visual Studio to create a dialog based MFC app and added this to OnInitDialog and made the OK button bigger:
// TODO: Add extra initialization here
HICON voipIcon = (HICON)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE( IDR_MAINFRAME ),
IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);
::SendMessage(::GetDlgItem(m_hWnd, IDOK), BM_SETIMAGE, IMAGE_ICON, (LPARAM)voipIcon);
The icon and text appear correctly on Vista, but on XP only the text appears. Also, it only appears under Vista if the manifest has a dependency on Common Controls v6.
If I set the BS_ICON style on the button the icon appears with no text. This is expected behavior based on the MS documentation: http://msdn2.microsoft.com/en-us/library/ms673567.aspx.
Any ideas why the icon and text only appears on Vista? Why does it require Common Controls v6?
Thanks,
Ken
|
|
|
|
|
Maybe if you derived CButton you can solve this problem.
|
|
|
|
|
I'm calling some c++ functions stored in a DLL by using the matlab function calllib.
The complete set of functions is correctly loaded (I checked them by using libfunctionview) but matlab produces segmental error when I use doublePtrPtr (declared by using libpointer) as input...
error message refers to this function
void __stdcall transpose(double **x,int n){<br />
for(int i=0; i<n;i++){<br />
for(int j=0; j<i; j++){swap(x[i][j],x[j][i]) <br />
}}}
I have done many examples by using type* or type[] without have any problem..
No example about **type input are supported in the matlab calllib function reference, and this is very strange ... is there someone that can help me ?
|
|
|
|
|
Hello
Is there a way to hide a parent window of a win32 application from the windows taskbar (as in hide the little box with the window name and icon in the taskbar) and also the alt+tab window (as in the window which appears when you press alt+tab)?
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Add the WS_EX_TOOLWINDOW extended style to your top-level window.
|
|
|
|
|
Thanks, Mike
Although I would like a window without a caption or border.. Is there any way to do it like that?
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Just remove the corresponding styles - WS_CAPTION and WS_BORDER
|
|
|
|
|
Thanks again :p
You mean with SetWindowLong()? How do you remove multiple styles?
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Perspx wrote: How do you remove multiple styles?
Bit twiddling. For example, to remove the caption and border, use:
style &= ~(WS_BORDER | WS_CAPTION);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for all of your help, guys
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Do you still have to explicitly remove the WS_EX_APPWINDOW style?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Perspx wrote: Is there a way to hide a parent window...
How about creating it as a child of a hidden window?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The child window will appear in the alt+tab window :p
Thanks anyway
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
You still have to add in the WS_POPUP style for that to work (IIRC).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Greetings,
I am very new to C++ and after many searches I am unable to figure out how to set the values of my array containing a character string.
class DataStruct
{
public:
char *mName;
char mInitial;
int mId;
int mAge;
int mDay;
DataStruct(char *Def_mName = "Paddy", char Def_mInitial = 'A' , int Def_mId = 1, int Def_mAge = 1, int Def_mDay = 1)
{
cout << endl << "Constructor Called ";
mName = new char [ strlen(Def_mName) + 1 ];
strcpy_s (mName, strlen(Def_mName) + 1, Def_mName);
mInitial = Def_mInitial;
mId = Def_mId;
mAge = Def_mAge;
mDay = Def_mDay;
}
When trying to use:
DataStruct data1[2] = { ("Andy",'A',1,20,30), ("Andy",'A',1,20,30 )};
I get the error:
error C2440: 'initializing' : cannot convert from 'int' to 'DataStruct'
Clearly I am not understanding somthing correctly either about strings or pointers, I am trying not to use specific string lengths if possible in this scenario.
Please can someone tell me what command I should be using to create this array, also if possible I would like to dynamicaly create the array data1 using new if anyone would be kind enough to show that example too.
Kind regards,
BS
|
|
|
|
|
Two problems:
1) You're using the wrong brackets in your initializer list:
DataStruct data1[2] = { ("Andy",'A',1,20,30), ("Andy",'A',1,20,30 )};
should be
DataStruct data1[2] = { {"Andy",'A',1,20,30}, {"Andy",'A',1,20,30 }};
2) You can't use an initializer list like this unless you remove the constructor from the struct.
See Compiler Error C2552[^] for details.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|