Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!ucsd!helios.ee.lbl.gov!bevsun.bev.lbl.gov!gimpel From: gimpel@bevsun.bev.lbl.gov (Tom Gimpel) Newsgroups: comp.windows.ms Subject: File date and time displayed in dialog box Message-ID: <5135@helios.ee.lbl.gov> Date: 19 Mar 90 08:29:45 GMT Sender: usenet@helios.ee.lbl.gov Reply-To: gimpel@bevsun.bev.lbl.gov (Tom Gimpel) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 103 X-Local-Date: 19 Mar 90 00:29:45 PST Mike Morris sez: >I want the About item to bring up a window which has ... "" >Version NN.NN, dated MM/DD/YY, at HH:MM" Here's what I did: In AboutDlgProc, which is the proc for the About... box put BOOL FAR PASCAL AboutDlgProc (hDlg, message, wParam, lParam) HWND hDlg; unsigned message; WORD wParam; LONG lParam; { struct stat stFileInfo; struct tm *npstFileTime; char *szAmPm; char *szTemp [81]; switch (message) { case WM_INITDIALOG: stat ("vers.exe", &stFileInfo); npstFileTime = localtime (&stFileInfo.st_atime); if (npstFileTime->tm_hour < 12) szAmPm = "am"; else szAmPm = "pm"; if (npstFileTime->tm_hour > 12) npstFileTime->tm_hour -= 12; if (npstFileTime->tm_hour < 1) npstFileTime->tm_hour = 12; sprintf (szTemp, "%2d/%02d/%02d", npstFileTime->tm_mon + 1, npstFileTime->tm_mday, npstFileTime->tm_year); SetDlgItemText (hDlg, ID_FILEDATE, (LPSTR)szTemp); sprintf (szTemp, "%2d:%02d%2s", npstFileTime->tm_hour, npstFileTime->tm_min, szAmPm); SetDlgItemText (hDlg, ID_FILEDATE, (LPSTR)szTemp); return FALSE; . . . (rest of dialog box code) } } Don't forget to export AboutDlgProc in the .DEF file. (I always do) vers.exe is the name of the program and will have a system date & time of the latest compile. No path is specified here, so stat will look in the current working directory. Experiment to see if there may be a problem with this. Use the name of your program in place here. stat and localtime are standard C library functions. For the declarations of these and the typedefs put these includes at the top of your program #include #include #include #include <\include\sys\types.h> #include <\include\sys\stat.h> Note the use of the nefarious sprintf function. You may want to do it right and use simpler library functions, the undocumented windows long pointer string functions, or the recommended method of making your own long pointer functions with the assembler. The dialog box template in the .RC file contains ABOUTBOX DIALOG 60, 30, 117, 110 STYLE WS_DLGFRAME | WS_POPUP BEGIN CONTROL "Vers version 1.00", -1, "static", SS_CENTER | WS_CHILD, 15, 11, 80, 8 CONTROL "File date:", -1, "static", SS_CENTER | WS_CHILD, 12, 27, 48, 10 CONTROL "File time:", -1, "static", SS_CENTER | WS_CHILD, 13, 42, 46, 10 CONTROL "", ID_FILEDATE, "static", SS_LEFT | WS_CHILD, 64, 27, 37, 12 CONTROL "", ID_FILETIME, "static", SS_LEFT | WS_CHILD, 64, 42, 37, 12 CONTROL "Ok", ID_OK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP WS_CHILD 39, 67, 41, 23 . . . (rest of template) END Note the two controls identified by ID_FILEDATE and ID_FILETIME. Unlike other controls of the static class, these will need unique identifiers because you will be writing text to them with the SetDlgItemText function. The values assigned to these will be up to you and will be in your program's header file. Hope this helps. Tom Gimpel -- Tom Gimpel gimpel@bevsun.bev.lbl.gov