|
There is not way for CFileFind to be used in API applications as far as I know (though it's very easy to be done using the API functions),
however if you are using VC++.Net you can use the CString class by inlcuding <atlstr.h<> and use it normally.
I think this might not work in VC++ 6.0
|
|
|
|
|
Just comment out that #error. Everyone does it
Don't forget that the MFC functions are just C++ wrappers for a C core. FindFirstFile, FindNextFile work the exact same way. And CString is just the stanard C functions wrapped, with a bit of magic glue.
|
|
|
|
|
One of my classes keeps a lookup-table that is based on a few constants #define in the header. If one of the constants change before a recompile the table has to be recomputed, but otherwise it is defined as a constant:
m_table[256] = {
0x00000000, 0x6750096, 0xEEEE4455, 0x45DF5C75, 0xB6662D3D, 0x23EE4521,
...
};
I have a function that computes the table and prints it to standard output, so if I change one of the #define constants I can compile, run the function, cut-and-paste the table back to my sourcefile, and finally recompile..
Is there any way to make the preprocessor do this? The table-generating function is not simple enough to make into a macro..
Any suggestions?
Thanks
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
nope, the preprocessor isn't that capable.
but, take a look here: http://www.codeproject.com/string/CXR.asp
i wrote a little system to do string encryption as part of the build process (roughly similar to your table generation). what i do is add a file to the project that causes VC to do a pre-build step. that pre-build step generates a source file (by calling off to a separate EXE), which is then compiled into the app.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Seems like a reasonable solution.
Joaquín M López Muñoz also had an interesting suggestion. I'll first take a shot at template metaprogramming (I like to try out concepts new to me), but if that
fails I'll go with a pre-build step.
Thanks
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
If the function is not very complex, you can convert it to a constant-time template by using a technique called template metaprogramming. If you post the code maybe I can help you with it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks!
Googled for the term and found some nice pages. I'll try to do the conversion myself first - it will be a nice introduction to the concept. But I hope you don't
mind if I ask you for help if I get stuck...
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
Good luck. TMP is an amazing technique, if difficult to tackle at first. Don't hesitate to ask for help.
PS: If you're succesful, your case could be a nice introduction article to this technique here in CP.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how do you do this?? When i make dialog boxes they minimize right above the taskbar as opposed to minimizing into the taskbar with the parent application... Do you have to change the owner of the dialog boxes?? When you call AFXMESSAGEBOX("") that dialog that is created gets put into the taskbar.. So i am asuming that when a window is created whos owner is the main application, it gets put into the taskbar upon minimization - but when a dialog is created as a child, it minimizes right above the taskbar. Ive asked this quesiton before and had no answers - has anyone had this problem before?? Can someone at least point me where to look for the answer?
thanks
-kevin
|
|
|
|
|
am i explaining myself correctly????????????????????????????????
does anyone have anyclue??
|
|
|
|
|
When you create an instance of the dialog, do you pass it a pointer to it's parent window? i.e.
CMyDialog dlg(this);
dlg.DoModal();
This may help if you're not doing it already
-Alex
|
|
|
|
|
hello @all,
i would like to build a hyperterminal into a mfc program (after i pressed a button, the hyperterminal is to appear).
how can that be done?
thank you very much
sunny
|
|
|
|
|
Try using this code:
<br />
::ShellExecute(0,0,"hypertrm.exe",0,0,SW_SHOW);<br />
|
|
|
|
|
Hmmm,
Can somebodu please help me!
Well here is the story.
In my *.h file i #include <windows.h> if i remove this or #include "stdafx.h" I get this error.
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
in one of my *.h file i use CString and must #include <afx.h> or #include "stdafx.h" but when i do that i get this error what should I do?
Please help me.
\Larsson
|
|
|
|
|
make sure stdafx.h is the very first #include in each source file and that you are not including windows.h in any file at all. If you are developing an MFC app you must use afxwin.h instead. The error is generated when the windows.h file is included before afxwin.h. Hope this helps.
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Well,
Thank it works so far but now I get
fatal error C1004: unexpected end of file found
in the file afxv_w32.h
do you now what this is??
\Larsson
|
|
|
|
|
On an exact note: that message is usually given when you didn't terminate an if/else, while, dowhile, or for() statement correctly or if you left a function open. By the above i mean you forgot to add your closing '}'.
If thats not it:
Seems like there is something screwed with your project. Make sure you don't have any circular included ( one file and that includes another that includes the first one ) and then make sure each of your files in question are setup to use a precompiler header. Also make sure your stdafx.h file is in good shape. If its not the compiler generated maybe posting it here would be helpfull.
Joe
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Just comment out the error. It's a stupid error anyway. I've done it for years on numberous projects and it's never broken anything running that way.
|
|
|
|
|
Hi:
I am not able to explain this behaviour:
1. The following code produces 0.013721122105938371, which is correct:
printf("\n\n%4.25Lf\n\n", + mBase[3][3] * exp( -4.0 * fAlpha * fPeriod )
+ mBase[3][2] * exp( -3.0 * fAlpha * fPeriod )
+ mBase[3][1] * exp( -2.0 * fAlpha * fPeriod )
+ mBase[3][0] * exp( -1.0 * fAlpha * fPeriod ));
2. The following code also produces the same number:
double a,b,c,d;
a = mBase[3][3] * exp( -4.0 * fAlpha * fPeriod );
b = mBase[3][2] * exp( -3.0 * fAlpha * fPeriod );
c = mBase[3][1] * exp( -2.0 * fAlpha * fPeriod );
d = mBase[3][0] * exp( -1.0 * fAlpha * fPeriod );
printf("\n\n%4.25Lf\n\n", a+b+c+d);
3. But this code produces a slightly different number 0.013721122105938344 (error in the last 2 digits for a relatively small loop! for larger loops it only gets worse!):
int n;
double fOrthonormal = 0.0;
for (n = 0; n <= 3; n++) {
fOrthonormal += mBase[3][n] * exp( -( double )(n + 1) * fAlpha * fPeriod);
}
4. MOreover this code, surprisingly also produces a different number!
int n;
double fOrthonormal = 0.0;
for (n = 3; n >= 0; n--) {
fOrthonormal += mBase[3][n] * exp( -( double )(n + 1) * fAlpha * fPeriod);
}
Precision in my case is important. It looks like it's really sensitive to the order in which numbers are added. But when I would intuitively expect an error in the last digit only (for a 4 item loop), it produces an error in the last 2 or 3! Any ideas why this happens?
IS THERE A BETTER NUMBER CLASS TO USE WHEN PRECISION MATTERS?
Thanks
|
|
|
|
|
Anton A. Loukine wrote:
Any ideas why this happens?
because doubles are only approximations.
Anton A. Loukine wrote:
IS THERE A BETTER NUMBER CLASS TO USE WHEN PRECISION MATTERS?
you'll probably need a scaled integer solution, if absolute accuracy is important.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Double precision numbers only have 15 places of precision. Also, when doing addition and subtraction, order of operation can change the result since those operations are most prone to error.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Assuming this reference is upto date:
http://www.cs.nyu.edu/exact/core/download/windowsInstr.html
Its code that deals with exact mathematics. Might be what you need
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
This is because of the IEEE format for FP numbers. If you knew how it's stored, then you'd be amazed that you can get that accurate at all.
The difference is the -(double)(n+1)
Try initalizing a negative double array double a[]={-4.0, -3.0 ...} and using that, if at all possible. It is in the negation that you are losing precision, IMHO.
|
|
|
|
|
Negation is just a simple flip of the sign bit. Addition and subtraction are the usual causes in precision problems..
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Skewled
Well I do know that multiplication is addition - you convert to the same base and add exponents. I forget how addition works. It's been a few years.
|
|
|
|