|
You can use the /E switch (preprocess to stdout) or /P switch (preprocess to a file). Run cl /? for a full list of switches.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello,
How to round a number into nearest integer in C++?
Is there any function to do that?
THX!!!
|
|
|
|
|
double a_bouble_val = 23,34;
int an_integer = (int)a_double_val;
This small code will assign an_integer to 23.
double a_bouble_val = 23,7;
int an_integer = (int)a_double_val;
This, will assign an_integer to 24.
Did I understand you?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
double a_bouble_val = 23,7;int an_integer = (int)a_double_val;
This, will assign an_integer to 24.
Actually, this will evaluate to 23. Casting a double to an int will always round to the whole number given (down for positive numbers, up for negative)
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
You can use floor() , ceil() , or just cast to an int eger.
This code rounds a value to the nearest integer.
int rounded = (int)(doubleval + 0.5);
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
it rounds up, to the nearest integer.
this goes both ways.
int i = (d > 0 ? (int)(d + 0.5) : (int)(d - 0.5));
-c
WWT2D?
|
|
|
|
|
It's a little more complicated if you are going to be dealing with both positive and negative numbers, as the floor() function moves the decimal number toward zero and the ceil() function moves the decimal number away from zero. The value of floor(-23.7) is -23, where rounded you probably would want -24. Adding 0.5 to the value before casting to an int works only for positive values, and not for negatives. There, you would have to subtract.
floor(-23.7 - 0.5) = floor(-24.2) = 24<br />
floor( 23.7 + 0.5) = floor( 24.2) = 24
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
|
show yur code where you subclass it.
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
BOOL CMyStatic::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CStatic::PreCreateWindow(cs)) { return FALSE; }
cs.style |= SS_OWNERDRAW;
return TRUE;
}
void CMyStatic::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
ModifyStyle(0, SS_OWNERDRAW);
}
I did both just to make sure. Winspector Spy shows SS_OWNERDRAW style in the window styles, but no call to DrawItem occurs.
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
what about the code creating the instance of CMyStatic on the toolbar?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
|
Good question, i remember there are issues with toolbars and messages not getting routed. i think that the solution is to override PreTranslateMessage and handle them ur self.
Did you watch messages with spy and see if the frame or dialog is receiving the DRAWITEM for that window?
-pete
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
|
|
Well i don't believe CStatic get input focus. Perhaps you just need a custom window so derive from CWnd. Then do ur OnPaint handler. For focus rect drawing look at CDC::Draw3dRect/DrawEdge/DrawState
Something there should do the trick.
-pete
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
WM_DRAWITEM is not sent to the owner draw control but to the owner window (the dialog it is on) of the control.
No need to subclass...
Oliver
|
|
|
|
|
I have created a List box using CreateWindow in my app's client area. Is there any way I can make the background of my list box transparent so that it is the same color as the background of my main window?
Thanks in advance,
Paddy.
|
|
|
|
|
Get the handle to the device context of the listbox (HDC) and use the Win32 function SetBkColor to set the color you want.
For more, see function SetBkColor in MSDN.
If you would like to use the same color as in your main window, you first have to get the standard color of your window, which is usually done by a call to GetSysColor.
Hope this helps,
-Dominik
|
|
|
|
|
ummm i don't believe that 'transparent' is the same as setting the background color to the same as the background window. Not to mention how do you know what window and what background color it is, and what about if it has something in it... or am I totaly lost?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
I understand what you are saying, they are not the same thing but for this particular case changing the background colour will work fine for me.
Thanks,
Paddy.
|
|
|
|
|
Thanks that exactly what I was looking for. I knew there was some simple way of doing it but I didn't know what to look for!
Paddy.
|
|
|
|
|
Hi,
I have some VC projects in which I can trace into the MFC classes like CDialog::OnInitDialog() and other projects that refuse to trace into the MFC classes. Sometimes not even a newly generated project is able to trace into the MFC classes.
Does anyone has any idea of what are the settings you need to use? I have carfuly compare the settings between the projects that allow me to trace into the MFC classes and the one that don't, but can not find anything different.
Any suggestions are welcome,
Daniel
Daniel
|
|
|
|
|
Do you mean 'step into'??
You would have to be missing the paths to the MFC code folders in your project settings I would think.
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Thanks for your answer.
By "Step into" I mean "Trace into", i.e. go into the source code for the MFC class.
The strange thing that I am experiencing is that some porjects will Trace into the MFC classes but other will not.
Your suggestion of checking the MFC folder settings is good and make sence but still doesn't explain why some projects won't work.
The Folder settings apply to the whole IDE independent of the project.
Still looking,
Daniel
|
|
|
|