|
Thanks for respone.
the following is codeing -
#include "StdAfx.h"
#include "DataCollector.h"
#include "lmcons.h" // for UNLEN and DNLEN [Dave]
CDataCollector::CDataCollector(void)
{
}
CDataCollector::~CDataCollector(void)
{
}
void CDataCollector::Open(LPCTSTR path)
{
m_file.Open (path,CFile::modeCreate | CFile::modeNoTruncate |
CFile::modeWrite | CStdioFileEx::modeWriteUnicode );
m_file.SeekToEnd ();
}
void CDataCollector::Close()
{
m_file.Close ();
}
void CDataCollector::Write(LPCTSTR lesson,
LPCTSTR sentence, LPCTSTR attempt, double score)
{
// To get user name
CString s;
DWORD userNameLength = UNLEN + 1;
TCHAR userName[UNLEN + 1]; // System user name length + 1.
if (GetUserName(userName, &userNameLength))
{
/* get network name */
// The NetApi calls are very time consuming
// This technique gets the domain name via an
// environment variable
TCHAR domainName[DNLEN + 1]; // System domain name length + 1
if (ExpandEnvironmentStrings(_T("%USERDOMAIN%"), domainName, DNLEN + 1))
{
s += domainName;
s += '-';
} /* get network name */
s += userName;
}
//create the time object
time_t osBinaryTime;
time(&osBinaryTime);
CTime now(osBinaryTime);
CString strTime = now.Format(_T("%d/%m/%y %H:%M:%S\n "));
CString str;
str.Format(_T("\n"));
str.Format(_T("%s, %s, %s, %s, %3.0lf%%, %s \n"), lesson, s, sentence, attempt, score, strTime);
m_file.WriteString (str);
}
thanks a lot
|
|
|
|
|
tunminhein wrote: str.Format(_T("\n"));
str.Format(_T("%s, %s, %s, %s, %3.0lf%%, %s \n"), lesson, s, sentence, attempt, score, strTime);
What exactly are you expecting this to do? The second call to Format() just overrides what the first one did.
In any case, you need to compare:
if (last_time != strTime)
m_file.WriteString(_T("\n"));
str.Format(_T("%s, %s, %s, %s, %3.0lf%%, %s \n"), lesson, s, sentence, attempt, score, strTime);
m_file.WriteString (str);
"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
|
|
|
|
|
Thanks a lot david
but we didn't put anydata to last_time ?
Regards,
|
|
|
|
|
tunminhein wrote: but we didn't put anydata to last_time ?
I assumed you knew that must be done and how to do it.
"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 haven't known yet how to put the previous date data to last_time.
but I tried it that u advice's coding.
here we are,
time_t osBinaryTime;
time(&osBinaryTime);
CTime now(osBinaryTime);
CString strTime = now.Format(_T("%d/%m/%y "));
CString strClock = now.Format (_T(" %H:%M:%S"));
/* CString last_time = strTime.Format (_T("%d/%m/%y "));
//
Cstring str;
if (last_time != strTime){
//m_file.WriteString(_T("\n"));
str.Format(_T("%s, %s, %s, %s, %3.0lf%%, %s , %s\n"), lesson, s, sentence, attempt, score, strTime,StrClock);
m_file.WriteString (str);
)*/
but i got error on the CSting last_time = strTime.format(_T(" %d/%m/%y"));
I'm a beginner in the MFC application. I really sorry u, if u got any inconvience.
thanks again.
|
|
|
|
|
tunminhein wrote: but i got error on the CSting last_time = strTime.format(_T(" %d/%m/%y"));
And rightly so, since CString::Format() has no return value.
"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
|
|
|
|
|
|
Hello,
i found one sample on msdn how to use Singly Linked Lists, and when i try to
build i got this error:
error C2065: '_aligned_malloc' : undeclared identifier
error C2065: '_aligned_free' : undeclared identifier
Can someone explain me how to fix this?
regards
termal
|
|
|
|
|
did you forget some of the #includes ?
|
|
|
|
|
Hello,
thanx for reply, i dont know, i copy all from this site on msdn!
My local msdn dont know this function!
regards
termal
|
|
|
|
|
OK. _aligned_malloc is a memory allocation function in the Visual C Runtime, MSVCRT*.dll.
It isn't usually called directly although I think it is exported. _aligned_free is the matching memory deallocation function. You need to check your project settings for which CLibrary/CRuntime you're using and look at the code to see whether it's using new or malloc or calloc or calling _aligned_malloc directly. Then you may need to add a #include or two. It's difficult to give you more details without knowing which Visual Studio version you're using and closely examining the sample.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello,
thanks for assertion, i use VS6 and my sample is from msdn, link to the site is in my first post!
regards!
termal
|
|
|
|
|
Hmm I'm confused now, The message that turned up in my email is not the message you posted here?!?
Hi,
i change the original line with _aligned_malloc:
pListHead = (PSLIST_HEADER)_aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
to:
pListHead = (PSLIST_HEADER)malloc(MEMORY_ALLOCATION_ALIGNMENT);
and i dont have errors! [confused]
regards
termal
Anyway you'll need to change that to
pListHead = (PSLIST_HEADER)malloc( sizeof(SLIST_HEADER) );
or you certainly will get errors when you run it. The original problem may be that _aligned_malloc is no longer exported from the Visual C Runtime, or it might require you to add an addtional include over and above memory.h e.g. #include <dbg.h> from the C Library source. Either way I wouldn't recommend calling _aligned_malloc directly from your code as it's intended to be an internal function. It will get called from malloc anyway, at least in debug mode, several levels down. If you installed the C Library source code along with VC++ 6 you can step into the malloc call in the debugger and marvel at the amount of stuff that happens just to get you a few bytes of memory to play with. Enjoy.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello,
yes you have right, i delete my previous message because is wrong, i change it like you said!
regards
termal
|
|
|
|
|
To use _aligned_malloc() with Visual Studio 6 you will need to download and install the Microsoft Platform SDK.
http://www.microsoft.com/downloads/details.aspx?familyid=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB[^]
Side Note: The aligned memory allocation functions are generally used for optimizing memory for MMX/SSE/SSE2 instruction usage. Although the standard size of a register is 32 bits (on 32 bit processors), not all registers are 32 bit sized. MMX registers are 64 bits wide and SSE registers are 128 bits wide. When moving, modifying or copying memory the operations are much faster when the data in memory is aligned on these boundries. Hope this helps.
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
Hello Randor,
yes that help's me, i dont know that before!!!
With best regards
Termal
|
|
|
|
|
Hi
In my Modal dialog besed page. I am making a Tab control three page
but when i compile and build this application four button at the buttom of the each page display ( named Ok,Cancel,Apply,Help) . Now According to my
program requirment i need to defined action for each page .
How can i remove all four button. OR
Is it possible the there would be only two button named save and cancel and
Save button behave differently for each page.
The coding for that three page is below.
CPropertySheet property(" New Student...");
CStudentGeneral st_gen;
CStudentFee st_fee;
CStudentAdditional st_add;
property.AddPage(&st_gen);
property.AddPage(&st_add);
property.AddPage(&st_fee);
if(property.DoModal() == IDOK)
{
}
Regard's
Kaushik
|
|
|
|
|
Following code should help -
property.AddPage(&st_fee); //Your code.
property.m_psh.dwFlags |= PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;//To remove Apply and help button.
property.SetFinishText("Save");
|
|
|
|
|
Thanks for reply
Sir ji if i apply your code an error occur
error C2065: 'PSH_NOCONTEXTHELP' : undeclared identifier
I want to remove all button from here.
Regard's
Kaushik
|
|
|
|
|
I am sorry, it was for version 5.80.
To remove all buttons, use SetWizardButtons(0);
and it should work. Good Luck
|
|
|
|
|
Thanks sir
Regard's
Kaushik
|
|
|
|
|
Is your sheet a wizard (i.e., have you called SetWizardMode() )?
"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
|
|
|
|
|
You can set a parameter that says which page is opened. Then switch the funcionality of your button according to the sheet.
Or
you can make more buttons (one per sheet), put specifical code in every button, and make them visible/invisible according to the actual sheet.
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
|
|
|
|
|
In the sheet's OnInitDialog() method, you can move and hide any of the four buttons. For example:
CWnd *pWnd = GetDlgItem(ID_APPLY_NOW);
ASSERT(NULL != pWnd);
pWnd->ShowWindow(SW_HIDE);
"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,
As I mentioned in another message, I have to connect my program with a PLC of Siemens. I have found a quite good DLL to do that. Now I'm reading the documentation and the examples that come with the DLL, but there are somethings that I don't understand very well and the help/tutorial is supposing a high level in plain C (that I don't reach
My programm is made in VC++ 6.0, I would like to have some explanations about the following things and to know if in VC++ 6.0 are needed these commands/prerrogatives.
In the header file
1)
#if defined( _MSC_VER ) && _MSC_VER > 600
#pragma pack( push, 1 )
#else
#pragma pack( 1 )
#endif
2)
#if defined( _MSC_VER ) && _MSC_VER > 600
#pragma pack( pop )
#else
#pragma pack()
#endif
These 2 blocks mean that depending on the version the parameters of those functions are different. I have taken a look in the help but I have not understood it well.
MSDN says:
push (optional)
Puts a specified packing alignment value, n, on the internal compiler stack, and sets the current packing alignment value to n. If n is not specified, the current packing alignment value is pushed.
pop (optional)
Removes the record from the top of the internal compiler stack. If n is not specified with pop, then the packing value associated with the resulting record on the top of the stack is the new packing alignment value. If n is specified, for example, #pragma pack(pop, 16), n becomes the new packing alignment value. If you pop with identifier, for example, #pragma pack(pop, r1), then all records on the stack are popped until the record with identifier is found, and that record is popped and the packing value associated with the resulting record on the top of is the stack the new packing alignment value. If you pop with an identifier that is not found in any record on the stack, then the pop is ignored.
But... wtf does it mean?
In the *.cpp
1) #define WIN32_LEAN_AND_MEAN // we don’t need all specifications
2) __cdecl
A decent explanation will be very wellcome.
Thanks
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
|
|
|
|
|