|
sdancer75 wrote: Is that possible to create a constructor or assignment operator to a structure ?
Yes.
"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
|
|
|
|
|
Hi all
How to display some text in a control which will automatically
adjust it's size according to length of data.
#sanroop#
|
|
|
|
|
IMHO you have to measure the text width via GetTextExtentPoint32 or similar and then resize the control according to it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
When the text is set to your control, you can call GetTextExtent to get the size in logical units.
MoveWindow() your control appropriately.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hi!
I have a dialog which I painted using 'OnEraseBkgnd' function. I placed a CTransparentStatic ctrl (static ctrl with TRANSPARENT BkMode). I wanted to have the same color as dialog background.
I also used:
<br />
HBRUSH CDialList::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <br />
{<br />
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
if( nCtlColor == CTLCOLOR_STATIC )<br />
{<br />
pDC->SetBkColor(BkClr);<br />
pDC->SetTextColor(TxtClr); <br />
}<br />
return hbr;<br />
}
Where BkClr is what I wanted for static ctrl to be painted, and TxtClr is RGB(0,0,0).
When dialog first appear the static control is not painted (it's gray) but on first text placment it gets back colored but only for text lenght, not hole rectangle!!!
I did everything and still cant get static ctrl to get all backround painted and on it's first appear?
Help please!
|
|
|
|
|
P.S.
I tough when setting controls (pDC's) BkMode to TRANSPARENT, control it self's has the color of it's dialog???
|
|
|
|
|
No...
this is for the labels you write down, if you want the to appear just the letters or the letters bounded with an square.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I have to compare two double values upto three decimal places.
Is following logic meaningful?
double Value1, value2;
Value1 = 0.54677788888;
Value2 = 0.54700000000;
CString str1,str2;
str1.Format("%.3f",Value1);
str2.Format("%.3f",Value2);
if (str1.Compare(str2) == 0)
output-> After rounding three decimal places values are equal.
else
output-> After rounding three decimal places values are not equal.
|
|
|
|
|
Did it work for you or not?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
|
congrats then whats the problem?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
I need to compare with double value itself.
how do we do it?
|
|
|
|
|
oh
got it
i shall work it out and reply.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Sakthi_Vel wrote: how do we do it?
You can't. Floating-point values cannot be represented exactly on a binary machine. Instead, you'll have to compare the difference to some very small number. For example,
if (fabs(Value1 - Value2) < 0.000001)
"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
|
|
|
|
|
This is faster than my solution on any case, but... would it work using the function I wrote below rounding the decimals up to a Nth position?
Or will it give problems because of the internal structure of "double"?
I have just used my function to limit the numbers that had to be updated to the screen, due to place problems, not to do comparisons.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
But you are still comparing a double to 0.5 for equality.
"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
|
|
|
|
|
Sakthi_Vel wrote: CString str1,str2;
str1.Format("%.3f",Value1);
str2.Format("%.3f",Value2);
Use %.3lf for double , f is for float .
Nibu thomas
MVP For VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
Nibu babu thomas wrote: Use %.3lf for double, f is for float.
You might want to check the source code of CString::Format() . You'll find something to the contrary. The l prefix has an affect on d, i, o, x, X, u, c, C, s, and S types.
"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
|
|
|
|
|
I made this function to use it in my project before doing updates from edits or labels
double CutAndRoundNumberToNDecimals (double dValue, const int nDec)
{ double dTemp = 0, dFract = 0, dInt = 0, dRes = 0;
dTemp = dValue*pow(10,nDec);
dFract = modf (dTemp, &dInt);
if (dFract >= 0.5)
dInt++;
dRes = dInt/pow(10,nDec);
return dRes;
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I want to serach no of occrances for hex data in integer array .
suppsoe array is
usinged short int array[20] = {0xe1,0x33,044,0,0x33,0x34,0x32,0xed,0xe2,0x1,0x22,0x21,0x24,0x24,0xed,0xe2}
in above array i want to search 0xede2 and also how many time this value occurs in array and at what position. thanks
-- modified at 3:58 Friday 12th October, 2007
|
|
|
|
|
have you perfectly understod your own question?
you didnt specify, what the type, the array is.
and what do you refer it as HEX data.
what is the point in searching it.
explain clearly for us to solve your problem.
and make a note that,
when you are posting some thread, the subject line should be some thing relevant to your description.
"please help" makes no sense, coz,
see this on top of your page
"4,589,938 members and growing! 21,276 now online."
all of us are here only to help.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Well, as you can easily see here [^] hex is only a numeral system, i.e. roughly speaking, a particular representation of a number. That stated, what do you need to do? Have you an array of binary (i.e. not-text, out of ASCII range) values? Or have you an array of characters representing hexadecimal numbers?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
You got short int s (signed BYTES ), and want to search an int in them?
Does casting to int and finding by a loop work?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
1. take each unsigned short from the array.
2. take 2 var byte1 and byte2.
3. from each byte observe each of its nibbles.
4. if any nibble is greater than 9 then that element is your victim.
5. simple ,problem solved!
6. any more doubts?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
I have made a sdi application, in that i have made a worker thread(in main application class) in that i have used some api's. Now my problem is in some case a api is not passing the flow of control. In this case after 10 seconds i want to display a message and break the thread. I tried to use timer through SetTimer method but it was not applicaple because WM_TIMER message is not present.Now, how to solve this problem? Can anybody help me in this.
Thanks in advance
|
|
|
|