|
-
Oct 8th, 2001, 02:01 PM
#1
Thread Starter
Fanatic Member
Edit boxes again
I am trying to make a simple program that tell you how many minutes, hours, days, etc., your computer has been on using GetTickCount(). When I click a button, I want ot to display (for example):
Code:
0 days
0 hours
20 minutes
but how can I add the newlines? If I use "\n" it just gives me the little black box.
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 8th, 2001, 04:59 PM
#2
PowerPoster
Perl mimic's C quite a bit (\n is newline in perl too). Perl also has \r for carriage return...have you tried that (if it's in C that is )
Maybe a combination will work, like \r\n (like vbCrLf)
-
Oct 8th, 2001, 05:05 PM
#3
PowerPoster
i don't think you can use those kind of characters in editboxes though
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 8th, 2001, 05:08 PM
#4
PowerPoster
It was a complete guess, I don't know C but I recognised the \n from Perl, which is very C-like.
-
Oct 8th, 2001, 05:11 PM
#5
PowerPoster
what is the diff (in perl) beteen /n and /r?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 8th, 2001, 05:19 PM
#6
PowerPoster
r is carriage return
n is newline (linefeed)
Usually you have to combine them when writing to files so it displays correctly under Windows, otherwise you get boxes (like Wynd was describing).
-
Oct 8th, 2001, 05:31 PM
#7
PowerPoster
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 8th, 2001, 05:49 PM
#8
You can use <<std::endl to change line
-
Oct 8th, 2001, 05:51 PM
#9
I just want to know why you do not take the time in the BIOS. I already did that in VB so I suppose we can do it in C++.
Daok
-
Oct 8th, 2001, 05:55 PM
#10
PowerPoster
what are you talking about?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 8th, 2001, 06:34 PM
#11
Thread Starter
Fanatic Member
I tried \r\n and I get two boxes.
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 8th, 2001, 06:36 PM
#12
Thread Starter
Fanatic Member
DaOK: I don't want the current time, just the time since the computer was turned on.
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 8th, 2001, 07:27 PM
#13
PowerPoster
doesn't time.h get it from the BIOS?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 8th, 2001, 08:06 PM
#14
Originally posted by Wynd
I am trying to make a simple program that tell you how many minutes, hours, days, etc., your computer has been on using GetTickCount(). When I click a button, I want ot to display (for example):
Code:
0 days
0 hours
20 minutes
but how can I add the newlines? If I use "\n" it just gives me the little black box.
Are you sure you gave it the ES_MULTILINE style when you created the edit box?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 8th, 2001, 09:46 PM
#15
Originally posted by sail3005
doesn't time.h get it from the BIOS?
Don't know, but you can also use the GetLocalTime() API function.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 9th, 2001, 06:08 PM
#16
Oops I did an error it's not with the BIOS but with the Kernel.
VB Code:
'Put that in a timer
Dim d As Integer
Dim h As Integer
Dim m As Integer
Dim s As Integer
Dim TimeStamp As String
'Get milliseconds from API
iTick = GetTickCount
'Convert milliseconds in days, hrs, mins, secs
d = iTick \ 86400000
h = (iTick Mod 86400000) \ 3600000
m = ((iTick Mod 86400000) Mod 3600000) \ 60000
s = (((iTick Mod 86400000) Mod 3600000) Mod 60000) \ 1000
'Create a "time stamp" string
TimeStamp = Format(d, "###0 Days. ") & _
Format(h, "#0h. ") & _
Format(m, "00min. ") & _
Format(s, "00sec")
text1.text= TimeStamp
'Module :
Public Declare Function GetTickCount Lib "kernel32" _
() As Long
This is for VB, I hope than you can do something like that with C++
Daok
-
Oct 9th, 2001, 07:02 PM
#17
Thread Starter
Fanatic Member
Originally posted by crptcblade
Are you sure you gave it the ES_MULTILINE style when you created the edit box?
Thanks, you rule.
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 12th, 2001, 10:20 PM
#18
PowerPoster
Try this:
PHP Code:
#include <windows.h>
#include <iostream.h>
#include <math.h>
int main()
{
int x;
int days,hours,mintues,seconds,rem;
DWORD tc;
tc = GetTickCount();
rem = tc/1000;
days = rem/86400;
rem = fmod((DOUBLE)rem,(DOUBLE)86400);
hours = rem/3600;
rem = fmod((DOUBLE)rem,(DOUBLE)3600);
mintues = rem/60;
rem = fmod((DOUBLE)rem,(DOUBLE)60);
seconds = rem;
cout<<"Days: "<<days<<endl;
cout<<"Hours: "<<hours<<endl;
cout<<"Minutes: "<<mintues<<endl;
cout<<"Seconds: "<<seconds<<endl;
cin>>x;
return 0;
}
I think it works fine
-
Oct 12th, 2001, 11:16 PM
#19
Thread Starter
Fanatic Member
Thanks, and thanks from the other thread too
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 12th, 2001, 11:29 PM
#20
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|