Solved

Linking scrnsave.lib in Borland 5.00

Posted on 1997-02-25
1
409 Views
Last Modified: 2013-12-04
I'm trying to build a screen saver under Win 32 under Borland C++ 5.00.
I've tried the example provided under the WIN API help provided with the compiler, but when I try to make the project, I cannot link to the library SCRNSAVE.LIB.
I've included the header scrnsave.h but it seems like the compiler is searching for a library that I don't have on my version.
The file scrnsave.lib is missing in the lib section, but I'm not sure that it exists. I think that the solution must be anywhere nearby.

I include here the main file (taken by Win Api help) after some little cut and paste:

Thanks for your help


#include <windows.h>
#include <win32\scrnsave.h>
#include "sscarlo.rh"

#define MINVEL  1               /* minimum redraw-speed value    */
#define MAXVEL  10              /* maximum redraw-speed value    */
#define DEFVEL  5               /* default redraw-speed value    */

LONG    lSpeed = DEFVEL;        /* redraw-speed variable         */

HANDLE hMainInstance; /* screen saver instance handle  */

TCHAR  szAppName[APPNAMEBUFFERLEN];
//CHAR   szAppName[80];           /* .INI section name             */
CHAR   szTemp[20];              /* temporary array of characters */

CHAR   szRedrawSpeed[] = "Redraw Speed";   /* .INI speed entry   */

BOOL WINAPI ScreenSaverConfigureDialog(hDlg, message, wParam, lParam)
HWND  hDlg;
UINT  message;
DWORD wParam;
LONG  lParam;
{
    static HWND hSpeed; /* handle of speed scroll bar */
    static HWND hOK;    /* handle of OK push button */

    switch(message)
    {
        case WM_INITDIALOG:

            /* Retrieve the application name from the .RC file. */

            LoadString(hMainInstance, idsAppName, szAppName, 40);


            /* Retrieve the .INI (or registry) filename. */

            LoadString(hMainInstance, idsIniFile, szIniFile,
                MAXFILELEN);

            /* Retrieve any redraw-speed data from the registry. */

            lSpeed = GetPrivateProfileInt(szAppName, szRedrawSpeed,
                DEFVEL, szIniFile);
 
            /*
             * If the initialization file does not contain an entry
             * for this screen saver, use the default value.

             */

            if(lSpeed > MAXVEL || lSpeed < MINVEL)
                lSpeed = DEFVEL;

            /* Initialize the redraw-speed scroll bar control. */
 
            hSpeed = GetDlgItem(hDlg, ID_SPEED);
            SetScrollRange(hSpeed, SB_CTL, MINVEL, MAXVEL, FALSE);
            SetScrollPos(hSpeed, SB_CTL, lSpeed, TRUE);

            /* Retrieve a handle of the OK push button control. */

            hOK = GetDlgItem(hDlg, ID_OK);


            return TRUE;

        case WM_HSCROLL:
 
            /*
             * Process scroll bar input, adjusting the lSpeed
             * value as appropriate.
             */
 
            switch (LOWORD(wParam))
                {
                    case SB_PAGEUP:
                        --lSpeed;
                    break;
 
                    case SB_LINEUP:
                        --lSpeed;
                    break;

                    case SB_PAGEDOWN:

                        ++lSpeed;
                    break;

                    case SB_LINEDOWN:
                        ++lSpeed;
                    break;
 
                    case SB_THUMBPOSITION:
                        lSpeed = HIWORD(wParam);
                    break;
 
                    case SB_BOTTOM:
                        lSpeed = MINVEL;
                    break;

                    case SB_TOP:
                        lSpeed = MAXVEL;

                    break;

                    case SB_THUMBTRACK:
                    case SB_ENDSCROLL:
                        return TRUE;
                    break;
                }
                if ((int) lSpeed <= MINVEL)
                    lSpeed = MINVEL;
                if ((int) lSpeed >= MAXVEL)
                    lSpeed = MAXVEL;

                SetScrollPos((HWND) lParam, SB_CTL, lSpeed, TRUE);
            break;
 
        case WM_COMMAND:

            switch(LOWORD(wParam))
            {
                case ID_OK:
 
                   /*
                    * Write the current redraw-speed variable to
                    * the .INI file.
                    */

                    wsprintf(szTemp, "%ld", lSpeed);
                    WritePrivateProfileString(szAppName, szRedrawSpeed,
                        szTemp, szIniFile);

                case ID_CANCEL:
                    EndDialog(hDlg, LOWORD(wParam) == ID_OK);

                return TRUE;
            }
    }
    return FALSE;
}




BOOL WINAPI RegisterDialogClasses(hInst)
HANDLE  hInst;
{
    return TRUE;
}

LONG WINAPI ScreenSaverProc(hwnd, message, wParam, lParam)
HWND  hwnd;
UINT  message;
DWORD wParam;
LONG  lParam;
{
static HDC          hdc;    /* device-context handle */
static RECT         rc;     /* RECT structure */
static UINT         uTimer; /* timer identifier */
static UINT                    i;

    switch(message)
    {
        case WM_CREATE:

            /* Retrieve the application name from the .RC file. */
 
            LoadString(hMainInstance, idsAppName, szAppName, 40);

 
            /* Retrieve the .INI (or registry) filename. */

            LoadString(hMainInstance, idsIniFile, szIniFile,
                MAXFILELEN);
 
            /* Retrieve any redraw-speed data from the registry. */

            lSpeed = GetPrivateProfileInt(szAppName, szRedrawSpeed,
                DEFVEL, szIniFile);

           /*
            * Set a timer for the screen saver window using the
            * redraw-rate stored in REGEDIT.INI.

            */
 
            uTimer = SetTimer(hwnd, 1, lSpeed * 1000, NULL);
            break;
 
        case WM_ERASEBKGND:

           /*
            * The WM_ERASEBKGND message is issued before the
            * WM_TIMER message, allowing the screen saver to
            * paint the background as appropriate.
            */
 
            hdc = GetDC(hwnd);
            GetClientRect (hwnd, &rc);
            FillRect (hdc, &rc, GetStockObject(BLACK_BRUSH));

            ReleaseDC(hwnd,hdc);
            break;

        case WM_TIMER:
 
           /*
            * The WM_TIMER message is issued at (lSpeed * 1000)
            * intervals, where lSpeed == .001 seconds. This
            * code repaints the entire desktop with a white,
            * light gray, dark gray, or black brush each
            * time a WM_TIMER message is issued.
            */

            hdc = GetDC(hwnd);
            GetClientRect(hwnd, &rc);

            if (i++ <= 4)
                FillRect(hdc, &rc, GetStockObject(i));
            else
                (i = 0);
            ReleaseDC(hwnd,hdc);
            break;

        case WM_DESTROY:

           /*
            * When the WM_DESTROY message is issued, the screen saver
            * must destroy any of the timers that were set at WM_CREATE
            * time.
            */
 
            if (uTimer)
                KillTimer(hwnd, uTimer);

            break;
    }

   /*
    * DefScreenSaverProc processes any messages
    * ignored by ScreenSaverProc.
    */
 
    return DefScreenSaverProc(hwnd, message, wParam, lParam);
}
0
Comment
Question by:Carlo
1 Comment
 
LVL 1

Accepted Solution

by:
dtowell earned 70 total points
ID: 1298640
The WIN32.HLP example you are using is documentation provided
by Microsoft (the compiler is Borland of course).  The example
assumes you have MSVC++.  MS and Borland object formats are not
the same so (of course) Borland did not ship a useless library
from Microsoft's SDK (as they did ship WIN32.HLP).  However,
SCRNSAVE.LIB is not required (it only contains a small amount
of glue code).  I have a trivial screen saver written in for
Borland's compiler (available via email: dwayne@imagebuilder.com)
if you need it.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Insert filename column as column a 18 76
Issue testing the Class Library 4 58
Please explain "Promise Pattern" and how it's used 2 57
VIDEO DATASOURCE Control Resize issue 2 30
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question