|
To convert a long to a string:
long l = 42;
TCHAR szBuffer[10];
wsprintf(szBuffer, _TEXT("ld"), l);
To convert a double to a long:
double d = 42.0;
long l = (long) d;
But you should check the range of the double before the conversion.
Oliver
|
|
|
|
|
for the conversion of the double to a long, i use firstly the method ceil(double), which returns a double, and after i want to convert the result to a long, so do you know if the range is good with your method
thanks
|
|
|
|
|
Double variables may hold values which is greater than the maximum long. If you are sure that your value fits into a long you could use the conversion right away.
If not you have to do something like this
if ((d < LONG_MIN) || (d > LONG_MAX))
{
error
}
else
{
conversion
}
The ceil function does not change the integer part.
Oliver
|
|
|
|
|
Hi,
check out _ltoa in the help, or _ultoa if it's unsigned.
/Daniel
|
|
|
|
|
I wrote source code, but won't work:
void CSearchDialog::DeleteAllCol()
{
int i, c;
m_List.DeleteAllItems();
c = m_List.GetItemCount();
for(i = 0; i <= 2; i++)
m_List.DeleteColumn(i);
}
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
void CSearchDialog::DeleteAllCol()
{
int i, c;
m_List.DeleteAllItems();
c = m_List.GetItemCount();
for(i = 2; i >= 0; i--) // i from 2 down to 0
m_List.DeleteColumn(i);
}
alen
|
|
|
|
|
So, there is any way for deleting automatically ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Not with the default list control from MFC. This is how I do it...
while(m_myListCtrl.DeleteColumn(0));
This way, I don't have to get the column count, I know that is not much overhead, but you never know where extra CPU time will come in handy.
|
|
|
|
|
Attention please~~~
Hi~
Last time, I wrote my problem at here.
But In my mistake, I don't gain a solution.
So I record my question again.
I seriously desire your assistance.
I'm a University student preparing a graduation thesis, in Korea.
But in the process, there raised an obstacle, so I'm in stuck with a problem.
So now I sincerely call for your help...
As the question contains some images and source file, I make out html document file.
The address is http://my.netian.com/~sibuzigi/forsite.htm
I hope your quick and adequate answer.
p/s Please~~~ Somebody help me~~~!^^;;;;;;
|
|
|
|
|
Hi,
What's the actual question?
Do you want to know how to make gradients?
It seems that your sample app does them well!
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi,
I think you are approaching this problem from the wrong direction. You should not need to worry about smoothing out discrete bands of color if you are trying to represent continuously variable field strength. I think the easiest approach would be to simply generate the color of each pixel based on the field strengh at that point.
For example say you want to represent field strength with
green=weakest value and yellow=strongest value in an RGB24 image
all you need to do is set G=255 and B=0 and then scale R from 0 to 255 proportional to field strength at that pixel position.
In the simple case of a single field source use pythagorus to find each pixel's position relative to the pixel you designate as the source of the field then use whatever formula you need (probably some inverse square relationship) to calculate the field strength at that pixel poition and scale that position to your R value in the RGB image. ( You may want to do a preliminary pass of the field to find minimum and maximum values in the the area you are representing so you can scale to the full 0-255 value of the R value.
You should get a nice smooth image.
Steve T.
|
|
|
|
|
Hi,
I have the dialog box with the ID: IDD_LISTCTRLDEMO_DIALOG
It has its class CshowResults.
In that dialog box I have a list control, which I would like to print.
The list control's ID is IDC_LIST_CTRL
and its member variable is m_cListCtrl
Now, how can I print that specific tree control, there might be about 40 pages of items in it!
Tanks a lot
|
|
|
|
|
I need to hold an array of values of varialbe type such as int's float's string's etc. The array will be created at compile time.
Any ideas?
|
|
|
|
|
Can you use VARIANT ?
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
I dunno. Is VARIANT compatible with string and iostreams?
Can you say
VARIANT somevar;
somevar >> aniostream;
aniostream << somevar;
|
|
|
|
|
Hmmm, off the top of my head, may I suggest you try creating your own struct/class that holds a string, float, int, etc. Infact, this is how VARIANTs in VB/COM are implemented under the hood anyway. Then use this struct/class in your maps, lists, and other STL structures. You might want to experiment with unions as well.
You could also take a look at MFC's COleVariant, and see if you can bend it to meet your needs (this is mostly used for database related stuff, but am sure you can use it for other needs as well).
|
|
|
|
|
If I understand you want one place to hold variables of different type(long, int, string, etc.).
The only way I'm aware of is to use VARIANT, but this has its draw backs. Using a VARIANT adds bulk and slows down your code. If you don't need to support VB or scripting languages then don't use VARIANT.
Is this for MFC? Then you can COleVariant << and >> operators, otherwise I don't beleive _variant_t has that capability.
Can you use seperate containers for each type? list<int>, list<long>, etc.
|
|
|
|
|
If this is what you want to do, I suggest that you uses a wrapper class like COleVariant or _variant_t (or maybe your own class).
At least those class properly handle memory managment and help a with initialisation. The one to uses depends on your needs. If you need more functionaly, then you should create your own class that may derive or embed a COleVariant or _variant_t.
_variant_t class may be a bit easier to uses since it allows conversion from the variant to another type:
_variant_t v(3.2);
double d = v;
but it does not support writting to CArchive...
You may also uses _variant_t for the container and create ColeVariant object at place you need extra functionaly.
Philippe Mori
|
|
|
|
|
I think this will work
http://www.boost.org/libs/any/index.html
gonna try it out...
|
|
|
|
|
|
with SetCursorPos(x,y);
cheers!!!
Carlos Antollini.
|
|
|
|
|
In MFC, if I didn't want my program to close by hitting Esc or Alt+F4, or any other escape sequence, how would I disable that? I can't find any code that works.
I Want Chicken, I Want Liver, Meow Mix, Meow Mix, Please Deliver...
|
|
|
|
|
I am not sure what you mean by "program". But one way to stop the user closing your dialog would be to overload the OnCancel or OnOK methods of your CDialog inherited class. (eg. They could do nothing at all.)
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
|
Hello every1!
I am looking at some sample code that microsoft is giving out with MSDN and i can't understand what is going on...if some1 knows it...
Here's the problem - the project palmap(can be found in any MSDN library) is a dll file that is used as an extension of aviview(a prog for viewing avi files and also can be found in the MSDN). A part of the source of palmap.c says:
typedef struct {
IAVIStreamVtbl FAR * lpVtbl;
ULONG ulRefCount;
//
// instance data
//
PAVISTREAM pavi;
PGETFRAME pgf;
AVISTREAMINFO sinfo;
HPALETTE hpal;
LPBYTE lp16to8;
LONG lLastFrame;
LPBITMAPINFOHEADER lpdibLast;
} PALMAPSTREAM, FAR*PPALMAPSTREAM;
There is something sneaky in this struct since IAVIStreamVtbl is defined nowhere(i checked the headers and tried to see if any IDLs exist). I searched the whole project directory for that string and there is no match. It is obviously the vtable and also has an interface prefix but i don't find any interface definitions too. BTW: i tried to look for the definition by clicking with the right button on the "IAVIStreamVtbl" and choosing "Goto definition...." but there is no brosing files with that project. After building the project there are no errors or warnings. so - Where could this IAVIStreamVtbl be defined?
Thanks for any reply!
Vladimir Ralev
|
|
|
|