Results 1 to 4 of 4

Thread: I don't know what is happening here

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Question I don't know what is happening here

    I want to get the time since my computer was started. I use this function in vb

    GetTickCount()

    Now, in C++, I used this code to get the time since I started my computer.

    long int ticktime;
    ticktime = GetTickCount();

    Until now, it works fine but now I want to show a messageBox like this:

    MessageBox(NULL, ticktime, "The title", MB_OK);

    It gives me an error on the variable "ticktime". What is the problem??
    Last edited by abdul; Apr 30th, 2001 at 04:30 PM.
    Baaaaaaaaah

  2. #2
    ChimpFace9000
    Guest
    try this...

    Code:
    char buffer[200];
    wsprintf(buffer, "%i", ticktime);
    MessageBox(NULL, buffer, "The title", MB_OK);

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Or the itoa function;

    Code:
    char buffer[8];
    MessageBox(hWnd, itoa(GetTickCount(), buffer, 8) , "Your Number", MB_OK);

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Or even my all-singing, all-dancing printf-stylie MsgBox function:
    Code:
    #include <windows.h>
    #include <stdlib.h>
    #include <stdarg.h>
    
    int MsgBox(HWND hParent, int iFlags, TCHAR *pcCaption, TCHAR *pcText, ...) {
    	va_list args;
    	TCHAR pcBuf[1024];
    
    	va_start(args, pcText);
    	_vsntprintf(pcBuf, 1024, pcText, args);
    	va_end(args);
    	return MessageBox(hParent, pcBuf, pcCaption, iFlags);
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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