Solved

Linking scrnsave.lib in Borland 5.00

Posted on 1997-02-25
1
405 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto Apply Receivables Credit Memos to Invoices in Microsoft Dynamics GP 1 93
wordpress limitations 4 105
Post a good COM tutorial 1 50
Recommendation vb6 to vb.net or others 14 112
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now