Results 1 to 20 of 20

Thread: Edit boxes again

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    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.

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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)

  3. #3
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    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

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    It was a complete guess, I don't know C but I recognised the \n from Perl, which is very C-like.

  5. #5
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    what is the diff (in perl) beteen /n and /r?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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).

  7. #7
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    oh, i see. cool

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  8. #8
    DaoK
    Guest
    You can use <<std::endl to change line

  9. #9
    DaoK
    Guest
    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

  10. #10
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    what are you talking about?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  11. #11

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    I tried \r\n and I get two boxes.
    Alcohol & calculus don't mix.
    Never drink & derive.

  12. #12

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    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.

  13. #13
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    doesn't time.h get it from the BIOS?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  14. #14
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  15. #15
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  16. #16
    DaoK
    Guest
    Oops I did an error it's not with the BIOS but with the Kernel.
    VB Code:
    1. 'Put that in a timer
    2. Dim d As Integer
    3. Dim h As Integer
    4. Dim m As Integer
    5. Dim s As Integer
    6. Dim TimeStamp As String
    7. 'Get milliseconds from API
    8. iTick = GetTickCount
    9. 'Convert milliseconds in days, hrs, mins, secs
    10. d = iTick \ 86400000
    11. h = (iTick Mod 86400000) \ 3600000
    12. m = ((iTick Mod 86400000) Mod 3600000) \ 60000
    13. s = (((iTick Mod 86400000) Mod 3600000) Mod 60000) \ 1000
    14. 'Create a "time stamp" string
    15. TimeStamp = Format(d, "###0 Days. ") & _
    16. Format(h, "#0h. ") & _
    17. Format(m, "00min. ") & _
    18. Format(s, "00sec")
    19. text1.text= TimeStamp
    20. 'Module :
    21. Public Declare Function GetTickCount Lib "kernel32" _
    22. () As Long

    This is for VB, I hope than you can do something like that with C++

    Daok

  17. #17

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    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.

  18. #18
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

  19. #19

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Thanks, and thanks from the other thread too
    Alcohol & calculus don't mix.
    Never drink & derive.

  20. #20
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    welcome
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width