|
Hi,
I need to use USB to interface between a hardware and PC. What command/tool should I use? Any sample code?
|
|
|
|
|
I don't realy know USB,but I think the hardware should provide that tool or the driver lib.
Thanks
Benben
|
|
|
|
|
Hi,
What is the difference between using CClientDC to draw graph and using CDC?
|
|
|
|
|
basicly nothing. The only difference is that CClientDC calls GetDC() on the supplied window in it's constructor, and calls ReleaseDC() in it's destructor. It just saves you some typing and debugging time.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I had create a SDI with database. How do I maximize the dialog permanently?
I drawed some pictures on the dialog. When I maximize the dialog, there's a assertion error. What should I do?
|
|
|
|
|
|
hi,
I want to convert the string '\device\harddiskvolume1\windows\..' to the path 'c:\windows\..'
I get that string from the registry. I can replace the string
'\device\harddiskvolume1' to c:
'\device\harddiskvolume2' to d:
etc.
But I doubt there is a much better way using some API.
Can anyone please help ?
regards
hari
Hari Krishnan
|
|
|
|
|
How can i get the path of my dll on disk from within that dll?? Like.. a program loads my dll as a plugin but the dll itself doesnt care where it is. Is there a way to get the path to the dll from within the dll code?
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
but the dll itself doesnt care where it is
I wouldnt say that was 'accurate' .. there's a set path windows uses to locate dll's .. from memory, its (very roughly), assuming NT for the moment
1) The directory the calling exe was loaded from
2) C:\winnt
3) C:\winnt\system32
4) The Contents of the PATH Environment variable
so the dll has to be 'somewhere useful' .... so you could use the file find functions ... checking that the above list was accurate, of course ...
As far as I recall, the info isnt stored 'within' a dll... The only other way may be to enumerate processes and maybe the process stack shows where it was loaded from - www.sysinternals.com has some tools that may demonstrate this .. but thats way complex !!!
Most 'plugin' factories to use a better word should have a configurable parameter that says, 'my plugins are in here' and not assume they are anywhere, imho ..
hth
|
|
|
|
|
A guess:
Try GetModuleFileName() passing in the instance handle of the dll. The handle is the first parameter passed into your DllMain() function, or it can be retrieved using the AfxGetInstanceHandle() function if you are using MFC and your dll was linked with the USRDLL version of MFC.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
I have the following simple code and I cant understand the results I am seeing
Note. This is a big hack in an old peice of code. It would not be like this if I had my way
void SomeFn(void)
{
//these are not hard coded they come from another API in string form
CString result = CalcMargin("0.7033", "0.7000");
}
CString CalcMargin(LPCTSTR exeRate, LPCTSTR rate)
{
double dExeRate, dRate, dMargin;
dExeRate = atof(exeRate);
dRate = atof(rate);
dMargin = dExeRate - dRate;
result.Format("%f", dMargin);
return result;
}
The returned value is "0.003300" and I wondered why i see the trailing zeros. It turnes out that the result of the subtraction is 0.0033000000000001
Can anyone tell me why?
Thanks
|
|
|
|
|
Try this
result.Format("%5.4lf", dMargin);
where 5 is the minimum width and 4 is the precision.
the lf is for double values.
|
|
|
|
|
Rounding error.
Floating-point numbers cannot be stored as the exact equivalent of their decimal representation, unless they all happen to be powers of two (2, 4, .125, etc.). So you should never check for strict equality when dealing with float /double values.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
Thanks but im not sure I understand completely. Would you expect "true" or "false" from the following code? It prints true when i run it.
double d1 = 5; //not a power of 2
double d2 = 2;
if( (d2 * 5.0 / 2.0) == d1)
printf("true");
else
printf("false");
|
|
|
|
|
You are using whole numbers. Try with fractions
double d1 = 1;
double d2 = 3;
double d3 = d1 / d2;
if (d3 == 0.333)
printf ("true");
else
printf ("false); No matter what number you use, you will never get true.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
|
Hi there,
I'm relatively new to the C++ language. Recently I started with a database application in Visual C++6.
Here is my question:
After loading a couple of (lest's say four) Edit boxes from an MS Access database through the MFC ODBC, I would like to calculate the value of some of the boxes and have the sum in a fifth Edit box.
The database consist of both integer and floating numbers.
I use the GetFieldValue to copy database values into a variable using the CString class.
How do I get the variables recognized as numbers?
This is easy to do in VB6 but how is it done in Visual C++6. There must be a way!
I would really appreciate all the help I can get.
Thanks in advance
Lars
|
|
|
|
|
atof()<br />
atoi()<br />
_atoi64()<br />
atol()<br />
atold()<br />
strtod()<br />
StrToInt()<br />
StrToIntEx()<br />
strtol()<br />
strtoul()
Take your pick
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I am a Visual C++ newbie (I worked with Borland Delphi a long time so I know something... although not what I need now).
I have to write a file encoder. In VC++ 6
Everything is set, I began a new project with MFC AppWizard, I selected dialog-based and now I have a dilemma:
How do I show up an "Open file" dialog type window??! and a save one too...
I would like if possible to be able to change the file filter and/or caption (I am developping it in another language)
Like in Notepad when you hit CTRL-O or File->Open. I don't necesarily need it Win2000/XP style but I HOPE THERE IS A FUNCTION IN THE WIN SDK.
In delphi it was so simple.Just drop a OpenFileDialog control on the main form and say: "Dialog1.Execute();"
Visual C++ is certainly no RAD for me...
Thanks in advance!
|
|
|
|
|
Sure there is a function in the windows sdk, it's called GetOpenFileName
Just fill in the OPENFILENAME struct an call the function.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you very much!
It helped
Now I also used GetSaveFileName !
|
|
|
|
|
I've created a dialog with nothing special in it. I don't know why, but I continue to get the following errors:
error C2065: 'IDD_SORU' : undeclared identifier
error C2057: expected constant expression
All for the following line of code, which I did not write:
/ Dialog Data
enum { IDD = IDD_SORU };
</code>
I have rebuilt everything, even deleted the dialog and remade it. Any ideas?
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Looks like IDD_SORU is not declared. This should be in your resource header file, its probably called resource.h
Visula Studio should have added a #define tot his file for IDD_CORU when you created the dialog. Its not unusual for Visual Studio to get confused with these things.
Open your resource.h file
At the bottom there is a line like the following
#define _APS_NEXT_RESOURCE_VALUE 348
Add a #define for IDD_SORU to the resource.h file
use the number from the _APS_NEXT_RESOURCE_VALUE line and increment _APS_NEXT_RESOURCE_VALUE
so in this example you would add the following line
#define IDD_SORU 348
and modify this line
#define _APS_NEXT_RESOURCE_VALUE 349
Hope that helps
|
|
|
|
|
Thanks for the help!
It seems that it is already defined in the resource.h file. It is defined as 132 and the _APS_NEXT_RESOURCE_VALUE is defined as 133. Should I simply delete the entire dialog and try again?
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
That will probably work.
It could be a problem with the pre-compiled headers. Try a rebuild all. Also check that the resource.h is included in the dialog header file
|
|
|
|