home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / scentsls / sldemo1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-20  |  41.4 KB  |  1,287 lines

  1. //***************************************************************************
  2. //
  3. //  PROGRAM   : SLDEMO1.C
  4. //
  5. //  PROGRAMMER: Steven R Clabaugh
  6. //              SRC Enterprises
  7. //
  8. //  PURPOSE   : SRC Enterprises Slider Custom Control C programing examples
  9. //              and demonstration program.
  10. //
  11. //***************************************************************************
  12. #include <windows.h>
  13. #include <srcentsl.h>
  14. #include "sldemo1.h"
  15.  
  16. //***************************************************************************
  17. //***************************************************************************
  18. //
  19. //      Global Variables
  20. //
  21. //***************************************************************************
  22. //***************************************************************************
  23. HINSTANCE hInst;  // current instance
  24.  
  25. char   MainWndClassName[] = "SLDemo1WClass",
  26.        MainWndMenu[]      = "SLDemo1Menu",
  27.        ProgTitle[]        = "SLDemo1 - Slider Sample Application";
  28.  
  29. LPSTR cBuff  = "         ";
  30.  
  31. //***************************************************************************
  32. //
  33. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  34. //
  35. //  PURPOSE: calls initialization function, processes message loop
  36. //
  37. //***************************************************************************
  38. int PASCAL WinMain(HINSTANCE hInstance,     // current instance
  39.                    HINSTANCE hPrevInstance, // previous instance
  40.                    LPSTR  lpCmdLine,        // command line
  41.                    int    nCmdShow)         // show-window type
  42. {
  43.  
  44.    MSG msg;   // message
  45.  
  46.    //****************************************************************
  47.  
  48.    if (!hPrevInstance)                  // Other instances of app running?
  49.        if (!InitApplication(hInstance)) // Initialize shared things
  50.            return (FALSE);              // Exits if unable to initialize
  51.  
  52.    // Perform initializations that apply to a specific instance
  53.    if (!InitInstance(hInstance, nCmdShow))
  54.        return (FALSE);
  55.  
  56.    // Acquire and dispatch messages until a WM_QUIT message is received.
  57.    while (GetMessage(&msg,       // message structure
  58.            NULL,                 // handle of window receiving the message
  59.            NULL,                 // lowest message to examine
  60.            NULL))                // highest message to examine
  61.        {
  62.        TranslateMessage(&msg);   // Translates virtual key codes
  63.        DispatchMessage(&msg);    // Dispatches message to window
  64.    }
  65.  
  66.    UnregisterClass((LPSTR)MainWndClassName,hInst);
  67.  
  68.    return (msg.wParam);          // Returns the value from PostQuitMessage
  69.  
  70. } // end WinMain
  71.  
  72. //***************************************************************************
  73. //
  74. //  FUNCTION: InitApplication(HINSTANCE)
  75. //
  76. //  PURPOSE: Initializes window data and registers window class
  77. //
  78. //***************************************************************************
  79. BOOL InitApplication(HINSTANCE hInstance)
  80. {
  81.  
  82.    WNDCLASS  wc;
  83.  
  84.    //****************************************************************
  85.  
  86.    // Fill in window class structure with parameters that describe the
  87.    // main window.
  88.  
  89.    wc.style = NULL;
  90.    wc.lpfnWndProc = MainWndProc;
  91.    wc.cbClsExtra = 0;
  92.    wc.cbWndExtra = 0;
  93.    wc.hInstance = hInstance;
  94.    wc.hIcon = LoadIcon(hInstance,"progicon");
  95.    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  96.    wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  97.    wc.lpszMenuName =  MainWndMenu;
  98.    wc.lpszClassName = MainWndClassName;
  99.  
  100.    // Register the window class and return success/failure code.
  101.    return (RegisterClass(&wc));
  102.  
  103. }  // end InitApplication
  104.  
  105. //***************************************************************************
  106. //
  107. //  FUNCTION:  InitInstance(HINSTANCE, int)
  108. //
  109. //  PURPOSE:  Saves instance handle and creates main window
  110. //
  111. //***************************************************************************
  112. BOOL InitInstance(HINSTANCE hInstance, // Current instance identifier.
  113.                   int       nCmdShow)  // Param for first ShowWindow() call.
  114. {
  115.  
  116.    HWND hWnd;              // Main window handle.
  117.  
  118.    //****************************************************************
  119.  
  120.    // Save the instance handle
  121.    hInst = hInstance;
  122.  
  123.    // Create a main window for this application instance.
  124.    hWnd = CreateWindow(
  125.        MainWndClassName,
  126.        ProgTitle,
  127.        WS_OVERLAPPEDWINDOW,
  128.        10,
  129.        10,
  130.        320,
  131.        220,
  132.        NULL,
  133.        NULL,
  134.        hInstance,
  135.        NULL
  136.    );
  137.  
  138.    // If window could not be created, return "failure"
  139.    if (!hWnd)
  140.        return (FALSE);
  141.  
  142.    // Make the window visible; update its client area; and return "success"
  143.    ShowWindow(hWnd, nCmdShow);  // Show the window
  144.    UpdateWindow(hWnd);          // Sends WM_PAINT message
  145.    return (TRUE);               // Returns the value from PostQuitMessage
  146.  
  147. }  // end InitInstance
  148.  
  149. //***************************************************************************
  150. //
  151. //  FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
  152. //
  153. //  PURPOSE:  Processes messages
  154. //
  155. //***************************************************************************
  156. long FAR PASCAL __export MainWndProc(
  157.                      HWND     hWnd,    // window handle
  158.                      unsigned message, // type of message
  159.                      WORD     wParam,  // additional information
  160.                      LONG     lParam)  // additional information
  161. {
  162.  
  163.    static HWND hSlider1, hSLEdit1,
  164.                hSlider2, hSLEdit2,
  165.                hSlider3, hSLEdit3,
  166.                hSlider4, hSLEdit4;
  167.  
  168.    //****************************************************************
  169.  
  170.    switch (message)
  171.    {
  172.  
  173.       case WM_CREATE:
  174.  
  175.          // Create Slider1 on the Main windlow client area.
  176.          // This will be a vertical, NON-reversed slider w/hand cursor
  177.          hSlider1 = SRCEntSLCreate(
  178.             NULL,      // Vertical, Nonreversed Slider
  179.             "slface1", // Resource name for the Slider Face
  180.             "slknob1", // Resource name for the Slider Knob
  181.             16,30,     // Slider X,Y position within the main client window
  182.             6,         // Knob slide position
  183.             6,         // Knob upper limit position
  184.             99,        // Knob lower limit position
  185.             0,100,     // range min & max
  186.             0,         // set an initial value
  187.             TRUE,      // Use the hand mouse cursor
  188.             TRUE,      // Enable the mouse
  189.             hWnd,      // Parent window handle
  190.             SLIDER1,   // Slider ID value
  191.             hInst);    // This Program's instance
  192.  
  193.          // EDIT control to display Slider1's value
  194.          hSLEdit1 = CreateWindow(
  195.             "EDIT",
  196.             "0",
  197.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  198.             12,140,32,22,
  199.             hWnd,
  200.             SLEDIT1,
  201.             hInst,
  202.             NULL
  203.          );
  204.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider1));
  205.          SetWindowText(hSLEdit1,cBuff);
  206.  
  207.          // Create Slider2 on the Main windlow client area.
  208.          // This will be a vertical, reversed slider w/arrow cursor
  209.          // Use the same face and knob as Slider 1
  210.          hSlider2 = SRCEntSLCreate(
  211.             SL_REVERSED,  // Vertical, reversed Slider
  212.             "slface1",  // Resource name for the Slider Face
  213.             "slknob1",  // Resource name for the Slider Knob
  214.             81,30,      // Slider X,Y position within the main client window
  215.             6,          // Knob slide position
  216.             6,          // Knob upper limit position
  217.             99,         // Knob lower limit position
  218.             0,100,      // range min & max
  219.             0,          // set an initial value
  220.             FALSE,      // Use the arrow mouse cursor
  221.             TRUE,       // Enable the mouse
  222.             hWnd,       // Parent window handle
  223.             SLIDER2,    // Slider ID value
  224.             hInst);     // This Program's instance
  225.  
  226.          // EDIT control to display Slider2's value
  227.          hSLEdit2 = CreateWindow(
  228.             "EDIT",
  229.             "0",
  230.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  231.             77,140,32,22,
  232.             hWnd,
  233.             SLEDIT2,
  234.             hInst,
  235.             NULL
  236.          );
  237.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider2));
  238.          SetWindowText(hSLEdit2,cBuff);
  239.  
  240.          // Create Slider3 on the Main windlow client area.
  241.          // This will be a horizontal, NON-reversed slider w/hand cursor
  242.          hSlider3 = SRCEntSLCreate(
  243.             SL_HORZ,   // Horizontal, Nonreversed Slider
  244.             "slface2", // Resource name for the Slider Face
  245.             "slknob2", // Resource name for the Slider Knob
  246.             140,50,    // Slider X,Y position within the main client window
  247.             6,         // Knob slide position
  248.             5,         // Knob upper limit position
  249.             60,        // Knob lower limit position
  250.             0,100,     // range min & max
  251.             0,         // set an initial value
  252.             TRUE,      // Use the hand mouse cursor
  253.             TRUE,      // Enable the mouse
  254.             hWnd,      // Parent window handle
  255.             SLIDER3,   // Slider ID value
  256.             hInst);    // This Program's instance
  257.  
  258.          // EDIT control to display Slider3's value
  259.          hSLEdit3 = CreateWindow(
  260.             "EDIT",
  261.             "0",
  262.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  263.             210,51,32,22,
  264.             hWnd,
  265.             SLEDIT3,
  266.             hInst,
  267.             NULL
  268.          );
  269.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider3));
  270.          SetWindowText(hSLEdit3,cBuff);
  271.  
  272.          // Create Slider4 on the Main windlow client area.
  273.          // This will be a horizontal, NON-reversed slider w/arrow cursor
  274.          // Use the same face and knob as Slider 3
  275.          hSlider4 = SRCEntSLCreate(
  276.             SL_HORZ | SL_REVERSED ,   // Horizontal, reversed Slider
  277.             "slface2", // Resource name for the Slider Face
  278.             "slknob2", // Resource name for the Slider Knob
  279.             140,110,   // Slider X,Y position within the main client window
  280.             6,         // Knob slide position
  281.             5,         // Knob upper limit position
  282.             60,        // Knob lower limit position
  283.             0,100,     // range min & max
  284.             0,         // set an initial value
  285.             FALSE,     // Use the hand mouse cursor
  286.             TRUE,      // Enable the mouse
  287.             hWnd,      // Parent window handle
  288.             SLIDER4,   // Slider ID value
  289.             hInst);    // This Program's instance
  290.  
  291.          // EDIT control to display Slider3's value
  292.          hSLEdit4 = CreateWindow(
  293.             "EDIT",
  294.             "0",
  295.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  296.             210,111,32,22,
  297.             hWnd,
  298.             SLEDIT4,
  299.             hInst,
  300.             NULL
  301.          );
  302.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider4));
  303.          SetWindowText(hSLEdit4,cBuff);
  304.  
  305.       break;  // end WM_CREATE
  306.  
  307.       case WM_PAINT:
  308.       {
  309.  
  310.          PAINTSTRUCT ps;
  311.  
  312.          //**********************************************************
  313.  
  314.          BeginPaint(hWnd,&ps);
  315.  
  316.          SetBkColor(ps.hdc,RGB(192,192,192));
  317.          TextOut(ps.hdc,5,5,"Slider 1",8);
  318.          TextOut(ps.hdc,70,5,"Slider 2",8);
  319.          TextOut(ps.hdc,150,30,"Slider 3",8);
  320.          TextOut(ps.hdc,150,90,"Slider 4",8);
  321.  
  322.          EndPaint(hWnd,&ps);
  323.  
  324.       }
  325.       break;  // end WM_PAINT
  326.  
  327.       case WM_COMMAND:
  328.  
  329.          switch (wParam)
  330.          {
  331.  
  332.  
  333.             // Here we handle the messages sent from Slider1
  334.             case SLIDER1:
  335.                wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider1));
  336.                SetWindowText(hSLEdit1,cBuff);
  337.             break;
  338.  
  339.             // Here we handle the messages sent from Slider2
  340.             case SLIDER2:
  341.                wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider2));
  342.                SetWindowText(hSLEdit2,cBuff);
  343.             break;
  344.  
  345.             // Here we handle the messages sent from Slider3
  346.             case SLIDER3:
  347.                wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider3));
  348.                SetWindowText(hSLEdit3,cBuff);
  349.             break;
  350.  
  351.             // Here we handle the messages sent from Slider4
  352.             case SLIDER4:
  353.                wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider4));
  354.                SetWindowText(hSLEdit4,cBuff);
  355.             break;
  356.  
  357.  
  358.             case IDM_ABOUT:
  359.             {
  360.  
  361.                FARPROC lpProcAbout; // pointer to the "About" function
  362.  
  363.                //*******************************************************
  364.  
  365.                lpProcAbout = MakeProcInstance(About, hInst);
  366.                DialogBox(hInst,
  367.                          "AboutBox",
  368.                          hWnd,
  369.                          lpProcAbout);
  370.  
  371.                FreeProcInstance(lpProcAbout);
  372.             }
  373.             break;
  374.  
  375.             case IDM_VGAUGE:
  376.             {
  377.  
  378.                FARPROC lpProcAbout; // pointer dialog function
  379.  
  380.                //*******************************************************
  381.  
  382.                lpProcAbout = MakeProcInstance(VGaugeDialog1, hInst);
  383.  
  384.                DialogBox(hInst,
  385.                          "VGaugeDLG1",
  386.                          hWnd,
  387.                          lpProcAbout);
  388.  
  389.                FreeProcInstance(lpProcAbout);
  390.             }
  391.             break;
  392.  
  393.             case IDM_HGAUGE:
  394.             {
  395.  
  396.                FARPROC lpProcAbout; // pointer dialog function
  397.  
  398.                //*******************************************************
  399.  
  400.                lpProcAbout = MakeProcInstance(HGaugeDialog2, hInst);
  401.  
  402.                DialogBox(hInst,
  403.                          "HGaugeDLG2",
  404.                          hWnd,
  405.                          lpProcAbout);
  406.  
  407.                FreeProcInstance(lpProcAbout);
  408.             }
  409.             break;
  410.  
  411.             case IDM_VTHERM:
  412.             {
  413.  
  414.                FARPROC lpProcAbout; // pointer dialog function
  415.  
  416.                //*******************************************************
  417.  
  418.                lpProcAbout = MakeProcInstance(VThermDialog3, hInst);
  419.  
  420.                DialogBox(hInst,
  421.                          "VThermDLG3",
  422.                          hWnd,
  423.                          lpProcAbout);
  424.  
  425.                FreeProcInstance(lpProcAbout);
  426.             }
  427.             break;
  428.  
  429.             case IDM_HTHERM:
  430.             {
  431.  
  432.                FARPROC lpProcAbout; // pointer dialog function
  433.  
  434.                //*******************************************************
  435.  
  436.                lpProcAbout = MakeProcInstance(HThermDialog4, hInst);
  437.  
  438.                DialogBox(hInst,
  439.                          "HThermDLG4",
  440.                          hWnd,
  441.                          lpProcAbout);
  442.  
  443.                FreeProcInstance(lpProcAbout);
  444.             }
  445.             break;
  446.  
  447.             case IDM_RVTHERM:
  448.             {
  449.  
  450.                FARPROC lpProcAbout; // pointer dialog function
  451.  
  452.                //*******************************************************
  453.  
  454.                lpProcAbout = MakeProcInstance(RVThermDialog5, hInst);
  455.  
  456.                DialogBox(hInst,
  457.                          "RVThermDLG5",
  458.                          hWnd,
  459.                          lpProcAbout);
  460.  
  461.                FreeProcInstance(lpProcAbout);
  462.             }
  463.             break;
  464.  
  465.             case IDM_SLBANK:
  466.             {
  467.  
  468.                FARPROC lpProcAbout; // pointer dialog function
  469.  
  470.                //*******************************************************
  471.  
  472.                lpProcAbout = MakeProcInstance(SLBankDialog6, hInst);
  473.  
  474.                DialogBox(hInst,
  475.                          "SLBankDLG6",
  476.                          hWnd,
  477.                          lpProcAbout);
  478.  
  479.                FreeProcInstance(lpProcAbout);
  480.             }
  481.             break;
  482.  
  483.  
  484.          } // end switch(wParam)
  485.  
  486.       break; // end WM_COMMAND
  487.  
  488.       case WM_DESTROY:                  // message: window being destroyed
  489.          PostQuitMessage(0);
  490.       break;
  491.  
  492.       default:   // Passes it on if unproccessed
  493.          return (DefWindowProc(hWnd, message, wParam, lParam));
  494.  
  495.    }
  496.  
  497.    return (NULL);
  498.  
  499. } // end MainWndProc
  500.  
  501. //***************************************************************************
  502. //
  503. //  FUNCTION: About(HWND, unsigned, WORD, LONG)
  504. //
  505. //  PURPOSE:  "About" dialog box
  506. //
  507. //***************************************************************************
  508. BOOL FAR PASCAL __export About(HWND     hDlg,
  509.                                unsigned message,
  510.                                WORD     wParam,
  511.                                LONG     lParam)
  512. {
  513.  
  514.    BOOL bRC;
  515.  
  516.    //****************************************************************
  517.  
  518.    bRC = TRUE;
  519.  
  520.    switch (message)
  521.    {
  522.  
  523.       case WM_INITDIALOG:
  524.       break;
  525.  
  526.       case WM_COMMAND:
  527.          switch (wParam)
  528.          {
  529.  
  530.             case IDOK:
  531.             case IDCANCEL:
  532.                EndDialog(hDlg,TRUE);
  533.             break;
  534.  
  535.          } // end switch(wParam)
  536.  
  537.       break;
  538.  
  539.       default:
  540.          bRC = FALSE;  // Didn't process a message
  541.  
  542.    } // end switch(message)
  543.  
  544.    return (bRC);
  545.  
  546. }  // end About
  547.  
  548. //***************************************************************************
  549. //
  550. //  FUNCTION: VGaugeDialog1(HWND, unsigned, WORD, LONG)
  551. //            Vertical Gauge
  552. //
  553. //***************************************************************************
  554. BOOL FAR PASCAL __export VGaugeDialog1(HWND     hDlg,
  555.                                        unsigned message,
  556.                                        WORD     wParam,
  557.                                        LONG     lParam)
  558. {
  559.  
  560.    BOOL bRC;
  561.  
  562.    //****************************************************************
  563.  
  564.    bRC = TRUE;
  565.  
  566.    switch (message)
  567.    {
  568.  
  569.       case WM_INITDIALOG:
  570.  
  571.          // Initialize the slider
  572.          SRCEntSLInit(
  573.             GetDlgItem(hDlg,D1SLIDER), // The Slider window handle
  574.             "slface3", // Resource name for the Slider Face
  575.             "slknob3", // Resource name for the Slider Knob
  576.             6,         // Knob slide position
  577.             5,         // Knob upper limit position
  578.             60,        // Knob lower limit position
  579.             0,100,     // range min & max
  580.             0,         // set an initial value
  581.             TRUE,      // Use the hand mouse cursor
  582.             TRUE       // Enable the mouse
  583.          );
  584.  
  585.          // Initialize the slider for use as a guage.
  586.          // Since this slider is used as gauge, there is no need
  587.          // to have an enabled mouse cursor.
  588.          SRCEntSLInit(
  589.             GetDlgItem(hDlg,D1GAUGE), // The Slider window handle
  590.             "gauge1f",  // Resource name for the Slider Face
  591.             "gauge1k",  // Resource name for the Slider Knob
  592.             2,          // Knob slide position
  593.             3,          // Knob upper limit position
  594.             111,        // Knob lower limit position
  595.             0,100,      // range min & max
  596.             0,          // set an initial value
  597.             FALSE,      // To use as a gauge; Use the mouse cursor
  598.             FALSE       // No need for an enabled mouse for gauges
  599.          );
  600.  
  601.       break; // end WM_INITDIALOG
  602.  
  603.       case WM_COMMAND:
  604.          switch (wParam)
  605.          {
  606.  
  607.             case D1SLIDER:  // Handle the Slider Message
  608.  
  609.                // Use the Slider value to set the Gauge Value
  610.                SRCEntSLSetVal(GetDlgItem(hDlg,D1GAUGE),
  611.                               SRCEntSLGetVal(GetDlgItem(hDlg,D1SLIDER)),
  612.                               TRUE);
  613.             break;
  614.  
  615.             case IDOK:
  616.             case IDCANCEL:
  617.                EndDialog(hDlg,TRUE);
  618.             break;
  619.  
  620.          } // end switch(wParam)
  621.  
  622.       break; // end WM_COMMAND
  623.  
  624.       case WM_PAINT:
  625.       {
  626.          PAINTSTRUCT ps;
  627.          RECT rect;
  628.  
  629.          //**********************************************************
  630.  
  631.          BeginPaint(hDlg,&ps);
  632.          GetClientRect(hDlg,&rect);
  633.  
  634.          //**** Paint the client area Light Gray *****
  635.          SelectObject(ps.hdc,GetStockObject(LTGRAY_BRUSH));
  636.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  637.  
  638.          EndPaint(hDlg,&ps);
  639.  
  640.       };
  641.       break; // end WM_PAINT
  642.  
  643.       default:                                  
  644.       
  645.          bRC = FALSE; // Didn't process a message
  646.  
  647.    } // end switch(message)
  648.  
  649.    return (bRC);
  650.  
  651. }  // end VGaugeDialog1
  652.  
  653. //***************************************************************************
  654. //
  655. //  FUNCTION: HGaugeDialog2(HWND, unsigned, WORD, LONG)
  656. //            Horizontal Gauge
  657. //
  658. //***************************************************************************
  659. BOOL FAR PASCAL __export HGaugeDialog2(HWND     hDlg,
  660.                                        unsigned message,
  661.                                        WORD     wParam,
  662.                                        LONG     lParam)
  663. {
  664.  
  665.    BOOL bRC;
  666.  
  667.    //****************************************************************
  668.  
  669.    bRC = TRUE;
  670.  
  671.    switch (message)
  672.    {
  673.  
  674.       case WM_INITDIALOG:
  675.  
  676.          // Initialize the slider
  677.          SRCEntSLInit(
  678.             GetDlgItem(hDlg,D2SLIDER), // The Slider window handle
  679.             "slface2", // Resource name for the Slider Face
  680.             "slknob2", // Resource name for the Slider Knob
  681.             6,         // Knob slide position
  682.             5,         // Knob upper limit position
  683.             60,        // Knob lower limit position
  684.             0,100,     // range min & max
  685.             0,         // set an initial value
  686.             TRUE,      // Use the hand mouse cursor
  687.             TRUE       // Enable the mouse
  688.          );
  689.  
  690.          // Initialize the slider for use as a guage.
  691.          // Since this slider is used as gauge, there is no need
  692.          // to have an enabled mouse cursor.
  693.          SRCEntSLInit(
  694.             GetDlgItem(hDlg,D2GAUGE), // The Slider window handle
  695.             "gauge2f",  // Resource name for the Slider Face
  696.             "gauge2k",  // Resource name for the Slider Knob
  697.             20,         // Knob slide position
  698.             8,          // Knob upper limit position
  699.             109,        // Knob lower limit position
  700.             0,100,      // range min & max
  701.             0,          // set an initial value
  702.             FALSE,      // To use as a gauge; Use the mouse cursor
  703.             FALSE       // No need for an enabled mouse for gauges
  704.          );
  705.  
  706.       break; // end WM_INITDIALOG
  707.  
  708.       case WM_COMMAND:
  709.          switch (wParam)
  710.          {
  711.  
  712.             case D2SLIDER:  // Handle the Slider Message
  713.  
  714.                // Use the Slider value to set the Gauge Value
  715.                SRCEntSLSetVal(GetDlgItem(hDlg,D2GAUGE),
  716.                               SRCEntSLGetVal(GetDlgItem(hDlg,D2SLIDER)),
  717.                               TRUE);
  718.             break;
  719.  
  720.             case IDOK:
  721.             case IDCANCEL:
  722.                EndDialog(hDlg,TRUE);
  723.             break;
  724.  
  725.          } // end switch(wParam)
  726.  
  727.       break; // end WM_COMMAND
  728.  
  729.       case WM_PAINT:
  730.       {
  731.          PAINTSTRUCT ps;
  732.          RECT rect;
  733.  
  734.          //**********************************************************
  735.  
  736.          BeginPaint(hDlg,&ps);
  737.          GetClientRect(hDlg,&rect);
  738.  
  739.          //**** Paint the client area Light Gray *****
  740.          SelectObject(ps.hdc,GetStockObject(LTGRAY_BRUSH));
  741.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  742.  
  743.          EndPaint(hDlg,&ps);
  744.  
  745.       };
  746.       break; // end WM_PAINT
  747.  
  748.       default:
  749.          bRC = FALSE; // Didn't process a message
  750.  
  751.    } // end switch(message)
  752.  
  753.    return (bRC);
  754.  
  755. }  // end HGaugeDialog2
  756.  
  757. //***************************************************************************
  758. //
  759. //  FUNCTION: VThermDialog3(HWND, unsigned, WORD, LONG)
  760. //            Vertical Thermometer Style Guage
  761. //
  762. //***************************************************************************
  763. BOOL FAR PASCAL __export VThermDialog3(HWND     hDlg,
  764.                                        unsigned message,
  765.                                        WORD     wParam,
  766.                                        LONG     lParam)
  767. {
  768.  
  769.    BOOL bRC;
  770.  
  771.    //****************************************************************
  772.  
  773.    bRC = TRUE;
  774.  
  775.    switch (message)
  776.    {
  777.  
  778.       case WM_INITDIALOG:
  779.  
  780.          // Initialize the slider
  781.          SRCEntSLInit(
  782.             GetDlgItem(hDlg,D3SLIDER), // The Slider window handle
  783.             "slface3", // Resource name for the Slider Face
  784.             "slknob3", // Resource name for the Slider Knob
  785.             6,         // Knob slide position
  786.             5,         // Knob upper limit position
  787.             60,        // Knob lower limit position
  788.             0,100,     // range min & max
  789.             0,         // set an initial value
  790.             TRUE,      // Use the hand mouse cursor
  791.             TRUE       // Enable the mouse
  792.          );
  793.  
  794.          // Initialize the slider for use as a thermometer guage.
  795.          // Since this slider is used as gauge, there is no need
  796.          // to have an enabled mouse cursor.
  797.          SRCEntSLInit(
  798.             GetDlgItem(hDlg,D3THERM), // The Slider window handle
  799.             "therm5f",  // Resource name for the Slider Face
  800.             "therm5k",  // Resource name for the Slider Knob
  801.             5,         // Knob slide position
  802.             7,          // Knob upper limit position
  803.             107,        // Knob lower limit position
  804.             0,100,      // range min & max
  805.             0,          // set an initial value
  806.             FALSE,      // To use as a gauge; Use the mouse cursor
  807.             FALSE       // No need for an enabled mouse for gauges
  808.          );
  809.  
  810.       break; // end WM_INITDIALOG
  811.  
  812.       case WM_COMMAND:
  813.          switch (wParam)
  814.          {
  815.  
  816.             case D3SLIDER:  // Handle the Slider Message
  817.  
  818.                // Use the Slider value to set the Gauge Value
  819.                SRCEntSLSetVal(GetDlgItem(hDlg,D3THERM),
  820.                               SRCEntSLGetVal(GetDlgItem(hDlg,D3SLIDER)),
  821.                               TRUE);
  822.             break;
  823.  
  824.             case IDOK:
  825.             case IDCANCEL:
  826.                EndDialog(hDlg,TRUE);
  827.             break;
  828.  
  829.          } // end switch(wParam)
  830.  
  831.       break; // end WM_COMMAND
  832.  
  833.       case WM_PAINT:
  834.       {
  835.          PAINTSTRUCT ps;
  836.          RECT rect;
  837.  
  838.          //**********************************************************
  839.  
  840.          BeginPaint(hDlg,&ps);
  841.          GetClientRect(hDlg,&rect);
  842.  
  843.          //**** Paint the client area Light Gray *****
  844.          SelectObject(ps.hdc,GetStockObject(LTGRAY_BRUSH));
  845.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  846.  
  847.          EndPaint(hDlg,&ps);
  848.  
  849.       };
  850.       break; // end WM_PAINT
  851.  
  852.       default:
  853.          bRC = FALSE; // Didn't process a message
  854.  
  855.    } // end switch(message)
  856.  
  857.    return (bRC);
  858.  
  859. }  // end VThermDialog3
  860.  
  861. //***************************************************************************
  862. //
  863. //  FUNCTION: HThermDialog4(HWND, unsigned, WORD, LONG)
  864. //            Horizontal Thermometer Style Gauge
  865. //
  866. //***************************************************************************
  867. BOOL FAR PASCAL __export HThermDialog4(HWND     hDlg,
  868.                                        unsigned message,
  869.                                        WORD     wParam,
  870.                                        LONG     lParam)
  871. {
  872.  
  873.    BOOL bRC;
  874.  
  875.    //****************************************************************
  876.  
  877.    bRC = TRUE;
  878.  
  879.    switch (message)
  880.    {
  881.  
  882.       case WM_INITDIALOG:
  883.  
  884.          // Initialize the slider
  885.          SRCEntSLInit(
  886.             GetDlgItem(hDlg,D4SLIDER), // The Slider window handle
  887.             "slface2", // Resource name for the Slider Face
  888.             "slknob2", // Resource name for the Slider Knob
  889.             6,         // Knob slide position
  890.             5,         // Knob upper limit position
  891.             60,        // Knob lower limit position
  892.             0,100,     // range min & max
  893.             0,         // set an initial value
  894.             TRUE,      // Use the hand mouse cursor
  895.             TRUE       // Enable the mouse
  896.          );
  897.  
  898.          // Initialize the slider for use as a thermometer guage.
  899.          // Since this slider is used as gauge, there is no need
  900.          // to have an enabled mouse cursor.
  901.          SRCEntSLInit(
  902.             GetDlgItem(hDlg,D4THERM), // The Slider window handle
  903.             "therm1f",  // Resource name for the Slider Face
  904.             "therm1k",  // Resource name for the Slider Knob
  905.             20,         // Knob slide position
  906.             9,          // Knob upper limit position
  907.             109,        // Knob lower limit position
  908.             0,100,      // range min & max
  909.             0,          // set an initial value
  910.             FALSE,      // To use as a gauge; Use the mouse cursor
  911.             FALSE       // No need for an enabled mouse for gauges
  912.          );
  913.  
  914.       break; // end WM_INITDIALOG
  915.  
  916.       case WM_COMMAND:
  917.          switch (wParam)
  918.          {
  919.  
  920.             case D4SLIDER:  // Handle the Slider Message
  921.  
  922.                // Use the Slider value to set the Gauge Value
  923.                SRCEntSLSetVal(GetDlgItem(hDlg,D4THERM),
  924.                               SRCEntSLGetVal(GetDlgItem(hDlg,D4SLIDER)),
  925.                               TRUE);
  926.             break;
  927.  
  928.             case IDOK:
  929.             case IDCANCEL:
  930.                EndDialog(hDlg,TRUE);
  931.             break;
  932.  
  933.          } // end switch(wParam)
  934.  
  935.       break; // end WM_COMMAND
  936.  
  937.       case WM_PAINT:
  938.       {
  939.          PAINTSTRUCT ps;
  940.          RECT rect;
  941.  
  942.          //**********************************************************
  943.  
  944.          BeginPaint(hDlg,&ps);
  945.          GetClientRect(hDlg,&rect);
  946.  
  947.          //**** Paint the client area Light Gray *****
  948.          SelectObject(ps.hdc,GetStockObject(LTGRAY_BRUSH));
  949.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  950.  
  951.          EndPaint(hDlg,&ps);
  952.  
  953.       };
  954.       break; // end WM_PAINT
  955.  
  956.       default:
  957.          bRC = FALSE; // Didn't process a message
  958.  
  959.    } // end switch(message)
  960.  
  961.    return (bRC);
  962.  
  963. }  // end HThermDialog4
  964.  
  965. //***************************************************************************
  966. //
  967. //  FUNCTION: RVThermDialog5(HWND, unsigned, WORD, LONG)
  968. //            Reversed Vertical Thermometer Style Guage
  969. //
  970. //***************************************************************************
  971. BOOL FAR PASCAL __export RVThermDialog5(HWND     hDlg,
  972.                                         unsigned message,
  973.                                         WORD     wParam,
  974.                                         LONG     lParam)
  975. {
  976.  
  977.    BOOL bRC;
  978.  
  979.    //****************************************************************
  980.  
  981.    bRC = TRUE;
  982.  
  983.    switch (message)
  984.    {
  985.  
  986.       case WM_INITDIALOG:
  987.  
  988.          // Initialize the slider
  989.          SRCEntSLInit(
  990.             GetDlgItem(hDlg,D5SLIDER), // The Slider window handle
  991.             "slface4", // Resource name for the Slider Face
  992.             "slknob4", // Resource name for the Slider Knob
  993.             6,         // Knob slide position
  994.             5,         // Knob upper limit position
  995.             109,       // Knob lower limit position
  996.             0,100,     // range min & max
  997.             0,         // set an initial value
  998.             TRUE,      // Use the hand mouse cursor
  999.             TRUE       // Enable the mouse
  1000.          );
  1001.  
  1002.          // Initialize the slider for use as a thermometer guage.
  1003.          // Since this slider is used as gauge, there is no need
  1004.          // to have an enabled mouse cursor.
  1005.          SRCEntSLInit(
  1006.             GetDlgItem(hDlg,D5THERM), // The Slider window handle
  1007.             "therm2f",  // Resource name for the Slider Face
  1008.             "therm2k",  // Resource name for the Slider Knob
  1009.             6,          // Knob slide position
  1010.             9,          // Knob upper limit position
  1011.             109,        // Knob lower limit position
  1012.             0,100,      // range min & max
  1013.             0,          // set an initial value
  1014.             FALSE,      // To use as a gauge; Use the mouse cursor
  1015.             FALSE       // No need for an enabled mouse for gauges
  1016.          );
  1017.  
  1018.       break; // end WM_INITDIALOG
  1019.  
  1020.       case WM_COMMAND:
  1021.          switch (wParam)
  1022.          {
  1023.  
  1024.             case D5SLIDER:  // Handle the Slider Message
  1025.  
  1026.                // Use the Slider value to set the Gauge Value
  1027.                SRCEntSLSetVal(GetDlgItem(hDlg,D5THERM),
  1028.                               SRCEntSLGetVal(GetDlgItem(hDlg,D5SLIDER)),
  1029.                               TRUE);
  1030.             break;
  1031.  
  1032.             case IDOK:
  1033.             case IDCANCEL:
  1034.                EndDialog(hDlg,TRUE);
  1035.             break;
  1036.  
  1037.          } // end switch(wParam)
  1038.  
  1039.       break; // end WM_COMMAND
  1040.  
  1041.       case WM_PAINT:
  1042.       {
  1043.          PAINTSTRUCT ps;
  1044.          RECT rect;
  1045.  
  1046.          //**********************************************************
  1047.  
  1048.          BeginPaint(hDlg,&ps);
  1049.          GetClientRect(hDlg,&rect);
  1050.  
  1051.          //**** Paint the client area Light Gray *****
  1052.          SelectObject(ps.hdc,GetStockObject(GRAY_BRUSH));
  1053.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  1054.  
  1055.          EndPaint(hDlg,&ps);
  1056.  
  1057.       };
  1058.       break; // end WM_PAINT
  1059.  
  1060.       default:
  1061.          bRC = FALSE; // Didn't process a message
  1062.  
  1063.    } // end switch(message)
  1064.  
  1065.    return (bRC);
  1066.  
  1067. }  // end RVThermDialog5
  1068.  
  1069. //***************************************************************************
  1070. //
  1071. //  FUNCTION: SLBankDialog6(HWND, unsigned, WORD, LONG)
  1072. //            Bank of Slider2
  1073. //
  1074. //***************************************************************************
  1075. BOOL FAR PASCAL __export SLBankDialog6(HWND     hDlg,
  1076.                                        unsigned message,
  1077.                                        WORD     wParam,
  1078.                                        LONG     lParam)
  1079. {
  1080.  
  1081.    BOOL bRC;
  1082.  
  1083.    static HWND hSlider1,  hSlider2,  hSlider3,  hSlider4;
  1084.  
  1085.    //****************************************************************
  1086.  
  1087.    bRC = TRUE;
  1088.  
  1089.    switch (message)
  1090.    {
  1091.  
  1092.       case WM_INITDIALOG:
  1093.       {
  1094.  
  1095.          HBITMAP hlface1, hmface1, hrface1;
  1096.          BITMAP  BMInfo;
  1097.  
  1098.          int rfw, mfw, lfw;    // width face bitmaps
  1099.  
  1100.          //**********************************************************
  1101.  
  1102.          // Before the Sliders are created, we need to load the face
  1103.          // bitmaps and get the their widths         
  1104.          hlface1  = LoadBitmap(hInst,"lface1");
  1105.          hmface1  = LoadBitmap(hInst,"mface1");
  1106.          hrface1  = LoadBitmap(hInst,"rface1");
  1107.  
  1108.          // Get widths of face bitmaps
  1109.          GetObject(hlface1,sizeof(BITMAP),(LPSTR)&BMInfo);
  1110.          lfw = BMInfo.bmWidth;
  1111.          GetObject(hmface1,sizeof(BITMAP),(LPSTR)&BMInfo);
  1112.          mfw = BMInfo.bmWidth;
  1113.          GetObject(hrface1,sizeof(BITMAP),(LPSTR)&BMInfo);
  1114.          rfw = BMInfo.bmWidth;
  1115.                
  1116.          // Now Delete them      
  1117.          DeleteObject(hlface1);
  1118.          DeleteObject(hmface1);
  1119.          DeleteObject(hrface1);
  1120.  
  1121.          // Now we create the sliders
  1122.  
  1123.          // The reason for using the CreateSlider() function to create
  1124.          // the slider windows rather than the CONTROL statement in the
  1125.          // resource file is because the CONTROL statement position and
  1126.          // size values use dialog box units, thus the sliders cannot be
  1127.          // positioned with pixel precision as is necessary here.
  1128.              
  1129.          // To make the slider bank appear as they do, there is a bitmap
  1130.          // for the left side Slider, the middle Sliders and the right
  1131.          // side Slider, then they are positioned to butt up next to
  1132.          // eack other.
  1133.  
  1134.          hSlider1 = SRCEntSLCreate(
  1135.             NULL,                   // Slider Style
  1136.             "lface1",               // Resource name for the Slider Face  
  1137.             "knob2",                // Resource name for the Slider Knob
  1138.             SLIDERSX,               // Slider X Position
  1139.             SLIDERSY,               // Slider Y Position
  1140.             7,                      // Knob slide position
  1141.             5,                      // Knob upper limit position
  1142.             110,                    // Knob lower limit position
  1143.             0,100,                  // range min & max
  1144.             0,                      // set an initial value
  1145.             TRUE,                   // Use the hand mouse cursor
  1146.             TRUE,                   // Enable the mouse
  1147.             hDlg,                   // Parent window handle
  1148.             D6SLIDER1,              // Slider ID value
  1149.             hInst);                 // This Program's instance
  1150.  
  1151.          hSlider2 = SRCEntSLCreate(
  1152.             NULL,                   // Slider Style
  1153.             "mface1",               // Resource name for the Slider Face
  1154.             "knob2",                // Resource name for the Slider Knob
  1155.             SLIDERSX+lfw,           // Slider X Position
  1156.             SLIDERSY,               // Slider Y Position
  1157.             4,                      // Knob slide position
  1158.             5,                      // Knob upper limit position
  1159.             110,                    // Knob lower limit position
  1160.             0,100,                  // range min & max
  1161.             0,                      // set an initial value
  1162.             TRUE,                   // Use the hand mouse cursor
  1163.             TRUE,                   // Enable the mouse
  1164.             hDlg,                   // Parent window handle
  1165.             D6SLIDER2,              // Slider ID value
  1166.             hInst);                 // This Program's instance
  1167.  
  1168.          hSlider3 = SRCEntSLCreate(
  1169.             NULL,                   // Slider Style
  1170.             "mface1",               // Resource name for the Slider Face
  1171.             "knob2",                // Resource name for the Slider Knob
  1172.             SLIDERSX+lfw+mfw,       // Slider X Position
  1173.             SLIDERSY,               // Slider Y Position
  1174.             4,                      // Knob slide position
  1175.             5,                      // Knob upper limit position
  1176.             110,                    // Knob lower limit position
  1177.             0,100,                  // range min & max
  1178.             0,                      // set an initial value
  1179.             TRUE,                   // Use the hand mouse cursor
  1180.             TRUE,                   // Enable the mouse
  1181.             hDlg,                   // Parent window handle
  1182.             D6SLIDER3,              // Slider ID value
  1183.             hInst);                 // This Program's instance
  1184.  
  1185.          hSlider4 = SRCEntSLCreate(
  1186.             NULL,                   // Slider Style
  1187.             "rface1",               // Resource name for the Slider Face
  1188.             "knob2",                // Resource name for the Slider Knob
  1189.             SLIDERSX+lfw+(2*mfw),   // Slider X Position
  1190.             SLIDERSY,               // Slider Y Position
  1191.             4,                      // Knob slide position
  1192.             5,                      // Knob upper limit position
  1193.             110,                    // Knob lower limit position
  1194.             0,100,                  // range min & max
  1195.             0,                      // set an initial value
  1196.             TRUE,                   // Use the hand mouse cursor
  1197.             TRUE,                   // Enable the mouse
  1198.             hDlg,                   // Parent window handle
  1199.             D6SLIDER4,              // Slider ID value
  1200.             hInst);                 // This Program's instance
  1201.  
  1202.  
  1203.          // Init the EDIT controls that display the Slider values
  1204.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider1));
  1205.          SetDlgItemText(hDlg,D6EDIT1,cBuff);
  1206.  
  1207.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider2));
  1208.          SetDlgItemText(hDlg,D6EDIT2,cBuff);
  1209.  
  1210.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider3));
  1211.          SetDlgItemText(hDlg,D6EDIT3,cBuff);
  1212.  
  1213.          wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider4));
  1214.          SetDlgItemText(hDlg,D6EDIT4,cBuff);
  1215.  
  1216.       }
  1217.       break; // end WM_INITDIALOG
  1218.  
  1219.       case WM_COMMAND:
  1220.          switch (wParam)
  1221.          {
  1222.  
  1223.             case D6SLIDER1:
  1224.                  wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider1));
  1225.                  SetDlgItemText(hDlg,D6EDIT1,cBuff);
  1226.             break;
  1227.  
  1228.             case D6SLIDER2:
  1229.                  wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider2));
  1230.                  SetDlgItemText(hDlg,D6EDIT2,cBuff);
  1231.             break;
  1232.  
  1233.             case D6SLIDER3:
  1234.                  wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider3));
  1235.                  SetDlgItemText(hDlg,D6EDIT3,cBuff);
  1236.             break;
  1237.  
  1238.             case D6SLIDER4:
  1239.                  wsprintf(cBuff,"%d",SRCEntSLGetVal(hSlider4));
  1240.                  SetDlgItemText(hDlg,D6EDIT4,cBuff);
  1241.             break;
  1242.  
  1243.             case IDOK:
  1244.             case IDCANCEL:
  1245.                EndDialog(hDlg,TRUE);
  1246.             break;
  1247.  
  1248.          } // end switch(wParam)
  1249.  
  1250.       break; // end WM_COMMAND
  1251.  
  1252.       case WM_PAINT:
  1253.       {
  1254.          PAINTSTRUCT ps;
  1255.          RECT rect;
  1256.  
  1257.          //**********************************************************
  1258.  
  1259.          BeginPaint(hDlg,&ps);
  1260.          GetClientRect(hDlg,&rect);
  1261.  
  1262.          //**** Paint the client area Light Gray
  1263.          SelectObject(ps.hdc,GetStockObject(LTGRAY_BRUSH));
  1264.          PatBlt(ps.hdc,0,0,rect.right,rect.bottom,PATCOPY);
  1265.  
  1266.  
  1267.          // Label the Sliders
  1268.          SetBkColor(ps.hdc,RGB(192,192,192));
  1269.          TextOut(ps.hdc,20,7,"1",1);
  1270.          TextOut(ps.hdc,44,7,"2",1);
  1271.          TextOut(ps.hdc,68,7,"3",1);
  1272.          TextOut(ps.hdc,92,7,"4",1);
  1273.  
  1274.          EndPaint(hDlg,&ps);
  1275.  
  1276.       };
  1277.       break; // end WM_PAINT
  1278.  
  1279.       default:
  1280.          bRC = FALSE; // Didn't process a message
  1281.  
  1282.    } // end switch(message)
  1283.  
  1284.    return (bRC);
  1285.  
  1286. }  // end SLBankDialog6
  1287.