|
HI,
I am doing visual c++ 2003, and I want to ask about how to convert the data type format ( TotalSeconds) to date format, I know how to convert from date format to total seconds but how to convert in the reverse way, I don't know
this is the way that I convert from date format to total seconds
Ctime Now = CTime::GetCurrentTime();
CTime UCT(0);
CTimeSpan Diff = Now - UCT;
return Diff.GetTotalSeconds();
but how to convert in the reverse way
I would be grateful if you guys can help me
Regards,
Arif Liminto
|
|
|
|
|
arifliminto86 wrote: but how to convert in the reverse way
I am not sure that I understand your question but I believe that you are asking how to convert a 64 bit integer containing CTime total seconds back into a CTime object. If this is what your looking for then perhaps the following code will help.
CTime tNow = CTime::GetCurrentTime();
OutputDebugString(tNow.Format(_T("Current Time: %A, %B %d, %Y\n")));
LONGLONG i64TotalSeconds = tNow.GetTime();
CTime tBack(i64TotalSeconds);
OutputDebugString(tBack.Format(_T("Converted Time: %A, %B %d, %Y\n")));
Best Wishes,
-David Delaune
|
|
|
|
|
Store your number of seconds in a time_t variable and pass it to one
of the functions that takes a time_t (or time_t *); then process the
result.Eg
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "The current date/time is: %s", asctime (timeinfo) );
return 0;
}
Hope it helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hello, can anyone give me a suggestion about how can I draw my windows application without the windows system border? Like those Yahoo widget which floating in the desktop? Which GUI SDK support this feature? Thanks!
Nacho
|
|
|
|
|
It's just a matter of the style used when the call to CreateWindowEx is made.
If I use a style of WS_VISIBLE|WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX
and a styleEx of WS_EX_APPWINDOW
I get a window without a border, that has an entry on the task-bar and who may be minimized or closed from the system-menu, activated by right-clicking the task-bar entry for the program.
See this project for a quick demo: Clock Application[^]
|
|
|
|
|
hello Friends,
i need simple accounting software source code in Visual C++ for learn more about accounting software projects . Please help me if possible
Thanx
|
|
|
|
|
So what you want is for us to give you full source code for accounting software so you can "learn" from it (aka use bits of the code)?
Oh, of course!
Regards,
--Perspx
"A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year." -Andrew Tanenbaum
"Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer." -Fred Brooks
|
|
|
|
|
You are asking the same thing in multiple forums. DO YOUR OWN WORK.
Blog link to be reinstated at a later date.
|
|
|
|
|
Geeze, the OP spammed/cross posted this forum, too
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
As long as he's not cross-dressing across forums.
Blog link to be reinstated at a later date.
|
|
|
|
|
Hi guys, I've written an application in pure C++ and the command line and now I'd like to convert it to Windows.
I am at the very first steps in using MFC and I am wondering if anyone could be kind enough to help.
To simplify the problem, let's suppose my application is composed of 2 input edit text boxes (Box1, Box2), a button (Calculate), and 1 output textbox (Box3). What is the correct code required to display the result of the calculation (Box1+Box2) in the output textbox (Box3)?
I've read 1300 pages of the excellent Ivor Horton's Beginning C++ 2008 book....only to discover that this simple topic is not covered!!
Many thanks
jEDI
|
|
|
|
|
J_E_D_I wrote: What is the correct code required to display the result of the calculation (Box1+Box2) in the output textbox (Box3)?
Call SetWindowText() , or send the control a WM_SETTEXT message.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks to both of you. I'll try it soon and let you know.
jEDI
|
|
|
|
|
in MFC you may also map the three textboxes to three integer variables and use the UpdateData mechanism see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I know that you can use the pragma comment directive in your code to link to a specific .lib file. Is it possible to also use this to pull in a .res file?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Nothing in the doc's even hint at this ability, nor would it make sense for it to work based on what the pragma does.
As a workaround you might want to try creating a resource only dll that includes your res, tinker with the build options to build as a static lib, and then use the pragma to link in the static lib.
What are you trying to accomplish ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I found another way around this. I have existing build .res files and I was wanting an easy way to link to them to pull it into the statically built .exe. I was hoping the pragma comment stuff could pull this off. The reason I thought this might work was because you can feed in various .lib or even .res files into the "Object/Library modules" edit in the Link settings, so I was hoping pragma comment (lib,...) would do the same trick.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: existing build .res files and I was wanting an easy way to link to them to pull it into the statically built .exe
I had the same problem. I've manually added refences to the source .rc files via the 'Resource Includes' dialog 'Compile-time directives' by adding lines like: '#include "path/res.rc"'.
So between libs i've had to add these statements as needed (i.e. one lib/dll uses resources from another), as well as in any final .exe. It's a pain, but i think the Resource Includes - Compile-time directives is the 'documented' way to do it.
By adding the #include .rc you also make it a dependent, so no risk of the .res being out of date.
How did you end up doing it ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi there,
I am trying to populate a combo box of available com ports.
I call my openSerialport function from my init dialog function but as soon as CreateFile is executed I get an Unhandled Exception error which has the info 0xC0000005 : Access Violation.
Can anyone help???????
Code Below
InitDialog call
BOOL CPTZControlDlg::OnInitDialog()
{
int i, j, hr;
char portStr[7];
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
j=0;
for (i=0 ; i<PORTNUM ; i++)
{
hr = m_serialCtrl->OpenSerialPort(i,0);
if (hr == 0)
{
g_exists[i] = 1;
g_nComPortInd[j] = i;
g_comport[i] = j;
j++;
sprintf(portStr,"COM%d",i+1);
m_comPort.AddString(portStr);
}
else
g_exists[i] = 0;
}
return TRUE;
}
Open Serial port function
int CSerialControl::OpenSerialPort(int pcCommPortInd,int radd)
{
DCB dcb;
BOOL fSuccess;
char pcCommPort[14];
int m_nComPort;
m_nComPort = pcCommPortInd;
sprintf(pcCommPort,"COM1",pcCommPortInd+1);
m_hCom = CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
NULL
);
if (m_hCom == INVALID_HANDLE_VALUE)
{
m_hCom = NULL;
return COMMSERROR;
}
if (radd==0)
{
CloseSerialPort();
return COMMSGOOD;
}
Cheers
Jim
|
|
|
|
|
What happens if you use OPEN_EXISTING instead of CREATE_ALWAYS ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
jimjim733 wrote: sprintf(pcCommPort,"COM1",pcCommPortInd+1);
What is the purpose of the above line?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In addition to the "For communications resources, the dwCreationDisposition
parameter must be OPEN_EXISTING" problem...
jimjim733 wrote: if (m_hCom == INVALID_HANDLE_VALUE)
{
m_hCom = NULL;
return COMMSERROR;
}
NULL is not an invalid handle value. INVALID_HANDLE_VALUE is an invalid
handle value.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
NULL is not INVALID_HANDLE_VALUE , but (I guess) it is still is an invalid handle value.
That's said, I agree with you: he should return INVALID_HANDLE_VALUE.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|