|
Use the brute force & pig ignorance solution - it's simple, easy to explain, and it works. And you don't have to think too much.
Open an application which uses the icons you want on its toolbar (Windows accessories /Audio recorder, for example.)
Press Alt-PrtScr to copy the application window image to clipboard.
Paste the image into Windows Paint (or whatever graphics editor you choose)
Copy the images of the toolbar buttons one by one, and paste into Resource editor for your toolbar.
|
|
|
|
|
Hi all,
I am unable to get a clear idea why i am getting wrong.
//=======================================================================
int x;
unsigned long y;
x = -1;
y = 100;
if(x > y){
MessageBox("X is greater than Y");
}
else
MessageBox("Y is greater than X");
//=========================================================================
in the above statement first statement is being executed why.
please let me know.
Uday
|
|
|
|
|
x is being cast to an unsigned int. (UINT)-1 = really_big_positive_number
|
|
|
|
|
//====================================This is the Solution
int x;
unsigned long y;
x = -1;
y = 100;
if( x > (int) y ) //Typecaste here
{
MessageBox("x>y");
}else
MessageBox("y>x");
//=================================================================
any more suggestion please let me know
uday.
|
|
|
|
|
Chris is correct of course; 'y' is unsigned while 'x' is signed. If you check the output window in your IDE the compiler should have issued warnings indicating that you're mixing signed and unsigned values in the assignment and comparison. The reason -1 is actually interpreted as the largest positive number relates to how 2's compliment arithmetic works; you may want to look this up if you’re curious. You used a type cast to fix the problem ; while this works a better solution (if appropriate) would be to simply make 'y' signed. I would also suggest that if you must type cast use static_cast instead of a C-style cast. e.g.
static_cast<int>(y)
There are many reasons to prefer C++ casting operators to C-style casts: in this case visibility applies (in other casting examples there are more pressing reasons to prefer C++ casting operators).
|
|
|
|
|
If I have a string definfed as this: char sir[17] how can i remove any new line or carriage return from the end or the begining of it?
|
|
|
|
|
tanarnelinistit
wroteremove any new line or carriage return
void check(char p[])
{
for(int i=0;i < strlen(p)-1;i++)
{
if(p[i]=='\n')
else
}
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Go the end of the string, start backing up character-by-character while whitespace (or whatever you want to trim) is found. When you find the first non-matching character, place a NUL into that location to terminate the string at that point.
You do not have to do something crazy like copying the string or moving it into and out of a string object.
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! 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! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
What about beginning of string?
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Just reverse the algorithm, being sure not to walk past the end of the string.
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! 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! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
tanarnelinistit wrote: how can i remove any new line or carriage return from the...begining of it?
Something like the following comes to mind:
void TrimLeft( char *str, const char ch )
{
char *pStr = str;
while (ch == *pStr)
pStr++;
strcpy(str, pStr);
} Fine tune it to fit your needs.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Method using CString:
char buffer[17] = {0};
InitializeBuffer(buffer);
CString strBuffer(buffer);
strBuffer.TrimLeft();
strBuffer.TrimRight();
memset(buffer, 0, 17);
strncpy(buffer, strBuffer, 16);
Method using std::string:
char buffer[17] = {0};
InitializeBuffer(buffer);
std::string sBuffer(buffer);
int start_pos = sBuffer.find_first_not_of("\t\n\r ");
int end_pos = sBuffer.find_last_not_of("\t\n\r ");
if (start_pos == npos)
{
start_pos = 0;
}
if (end_pos = npos)
{
end_pos = strlen(buffer) - 1;
}
std::string sTemp = sBuffer.substr(start_pos, end_pos - start_pos + 1);
memset(buffer, 0, 17);
strncpy(buffer, sTemp.c_str(), 16);
Method using char:
int FindFirstNotOf(const char* chars, size_t chars_size, const char* str, size_t str_size)
{
int ret = -1;
for (int i = 0; i < str_size; ++i)
{
bool bFound = false;
for (int j = 0; j < chars_size; ++j)
{
if (str[i] == chars[j])
{
bFound = true;
break;
}
}
if (bFound == false)
{
ret = i;
break;
}
}
return ret;
}
int FindLastNotOf(const char* chars, size_t chars_size, const char* str, size_t str_size)
{
int ret = -1;
for (int i = str_size - 1; i >= 0; --i)
{
bool bFound = false;
for (int j = 0; j < chars_size; ++j)
{
if (str[i] == chars[j])
{
bFound = true;
break;
}
}
if (bFound == false)
{
ret = i;
break;
}
}
return ret;
}
char buffer[17] = {0};
InitializeBuffer(buffer);
char chars[5] = "\t\r\n ";
int start_pos = FindFirstNotOf(chars, 5, buffer, 17);
int end_pos = FindLastNotOf(chars, 5, buffer, 17);
if (start_pos == -1)
{
start_pos = 0;
}
if (end_pos == -1)
{
end_pos = strlen(buffer) - 1;
}
char newBuffer[17] = {0};
strncpy(newBuffer, &buffer[start_pos], end_pos - start_pos);
memset(buffer, 0, 17);
strncpy(buffer, newBuffer, 16);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
OK - perhaps a simple example of trimming a string in-place, because you did not mention the word "copy" in your post (this code comes slightly modified from my TStaticString class):
void TrimRight( LPTSTR cpString,
LPCTSTR cpTrimWhat = _T( " " ) )
{
size_t stStrLen = ::_tcslen( cpString );
if( !stStrLen )
{
return;
}
LPTSTR cpCursor = ( cpString + ( stStrLen - 1 ) );
size_t stCount = 0;
while( ( stCount < stStrLen) &&
( ::_tcschr( cpTrimWhat, *cpCursor ) ) )
{
++stCount;
--cpCursor;
}
if( stCount )
{
++cpCursor;
*cpCursor = _T( '\0' );
}
return;
} See how that works for you. Specify the characters to Example of use:
TCHAR caTest[ 32 ];
strcpy( caTest, _T( "abc\t " ) );
TrimRight( caTest );
strcpy( caTest, _T( "abc\t " ) );
TrimRight( caTest, "\t " );
The first call will trim up to the tab character, the second will also trim the tab character.
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! 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! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
plz send me da code how vc++ can connect to access database either DAO/ODBC
janan
|
|
|
|
|
See here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
See the semi-related article here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hello
i want to display the content of edit control in one form to another edit box content in new from
janan
|
|
|
|
|
Say if you have an edit box in the first dialog then in the second dialog you can place a pointer to the parent class like
CMain* pParent=(CMain*)GetParent();
pParent->m_edit.GetWindowText() etc..//... to get the value from the other edit box
// Put it into the edit box in the second dialog using
m_editOnSecondDlg.SetWindowText()...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Whats application type?
if its dialog you can use
<br />
CMain* m_Main=(CMain*)GetParent();<br />
CString str;<br />
m_Main->m_Edit1.GetWindowText(str);<br />
in another dialog use
<br />
m_Edit2.SetWindowText(str);
|
|
|
|
|
What is the relationship between the two dialogs (i.e., parent/child, siblings)?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello everyone,
I always see the two words -- asynchronized I/O and I/O multiplexing. Are they the same thing -- like select/poll?
I noticed that in some situations, people say they are different and asynchronized I/O is better than I/O multiplexing.
Could anyone help to clarify the differences between the two words?
thanks in advance,
George
|
|
|
|
|
Multiplexed I/O queries multiple I/O channels, and returns if an communication occurs on one channel. The typical use is a Server process that has to respond to multiple connections. The call is blocking, so you can't do anything else (in this thread).
Asynchronous I/O is more versatile, but can be used in the same scenario.
You can request the I/O operation to start, then do your own things. At any time, you can query if the I/O operation has completed It's also possible to set an event or call a callback function when the operation completes.
|
|
|
|
|
Thank you very much peterchen!
Your reply makes senses.
peterchen wrote: Multiplexed I/O queries multiple I/O channels, and returns if an communication occurs on one channel. The typical use is a Server process that has to respond to multiple connections. The call is blocking, so you can't do anything else (in this thread).
I can not imagine why in the situation (server process handles multiple client connections) the call is blocking (other than asynchronous) -- I think the server can process other things even if no new data is received from client connection, which is an asynchronized mechanism other than a blocked mechanism. Could you show me more details please?
regards,
George
-- modified at 8:06 Tuesday 25th July, 2006
|
|
|
|
|
Hello comunity,
how to set an focus to button and select him when user enter a CEdit field, so when the user press enter on keyboard the additional funktion begins, example show an MessageBox with this text from
this CEdit field, and not like now to close my dialog???
Thanx in advance!
break;
|
|
|
|
|
setting the focus is one thing, and select him so that when user presses enter key in an edit box is an onther one.
to set focus :
(GetDlgItem(IDC_MY_BUTTON))->SetFocus();
to set as the default button :
this->SetDefID(IDC_MY_BUTTON);
where IDC_MY_BUTTON is the button you want to act on, and this, is the dialog box which the button is layed on...
|
|
|
|