home *** CD-ROM | disk | FTP | other *** search
- /*
- **************************************************************
- * newpaper.c *
- * 7/28/90 by Jim Button *
- *------------------------------------------------------------*
- * Updates WIN.INI Wallpaper specification to point to the *
- * to the next BMP file in the windows subdirectory. *
- * *
- * This hardly looks like a Windows program. The traditional *
- * message loop is not even needed, since it does no input, *
- * has no output, and terminates almost before it starts! *
- **************************************************************
-
- Modified by Roger Hadgraft
-
- 16/10/1990 Looks in Win.ini for tiling or centering.
- Otherwise it asks, and records the setting.
- Pressing "Cancel" causes no setting to be recorded, and
- sets centering on as a means of previewing the bitmap.
- */
-
- #ifndef _WINDOWS
- #define _WINDOWS
- #endif
-
- #include <windows.h>
- /* #include <types.h>
- #include <stat.h> */
- #include <dos.h>
- #include <string.h>
-
- static char msg[] = " By Jim Button ";
- static char WallPaper[] = "Wallpaper";
-
- #define MAX_PROF_STR 13
-
-
- int PASCAL WinMain( HANDLE hInstance,
- HANDLE hPrevInstance,
- LPSTR lpszCmdLine,
- int nCmdShow)
- {
- unsigned int done;
- char oldbmp[MAX_PROF_STR+1];
- char firstbmp[MAX_PROF_STR+1];
- char newbmp[MAX_PROF_STR+1];
- struct find_t dta;
- /* struct stat buf; */
- char *tiled;
- int result;
-
- GetProfileString((LPSTR)"Desktop", (LPSTR)"WallPaper", (LPSTR)"", (LPSTR)oldbmp, MAX_PROF_STR);
- newbmp[0] = '\0'; /* In case no BMP files exist */
-
- /*** Get the list of .BMP files ***/
- done = _dos_findfirst("*.BMP", 0, &dta); /* Find files */
- if (!done) {
- strcpy(firstbmp, dta.name);
- strcpy(newbmp, firstbmp);
- }
-
- while (!done) {
- if (!strcmpi(dta.name, oldbmp)) { /* Current one? */
- done = _dos_findnext(&dta);
- strcpy(newbmp, (done ? firstbmp : dta.name));
- break;
- }
- done = _dos_findnext(&dta);
- }
-
- /*** Update WIN.INI ***/
- WriteProfileString((LPSTR)"Desktop", (LPSTR)"WallPaper", (LPSTR)newbmp);
-
- /*** Check for a previously recorded setting, otherwise ask ***/
- result = GetProfileInt("Desktop", newbmp, -1);
- if( result == -1 ) {
- /* this bitmap hasn't been specified yet */
- result = MessageBox( GetActiveWindow(), (LPSTR)"Tile this BitMap on the DeskTop ?\n(Otherwise centre it)",
- (LPSTR)newbmp, MB_ICONQUESTION | MB_YESNOCANCEL );
- if( result == IDYES )
- tiled = "1"; /* Point to string "1" */
- else
- tiled = "0";
- if( result != IDCANCEL )
- /* record choice as a permanent setting */
- WriteProfileString((LPSTR)"Desktop", (LPSTR)newbmp, (LPSTR)tiled);
- }
-
- else {
- if( result == 1 )
- tiled = "1"; /* Point to string "1" */
- else
- tiled = "0";
- }
-
- WriteProfileString((LPSTR)"Desktop", (LPSTR)"TileWallpaper", (LPSTR)tiled);
-
- return(FALSE);
- }
-
-
-