Solved

Linking scrnsave.lib in Borland 5.00

Posted on 1997-02-25
1
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

728 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