home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / scentbns / bndemo2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-20  |  39.6 KB  |  1,065 lines

  1. //***************************************************************************
  2. //
  3. //  PROGRAM   : BNDEMO2.CPP
  4. //
  5. //  PROGRAMMER: Steven R Clabaugh
  6. //              SRC Enterprises
  7. //
  8. //  PURPOSE   : SRC Enterprises Button Custom Control C++ programming examples
  9. //              and demonstration program.
  10. //
  11. //***************************************************************************
  12. #include <windows.h>
  13. #include <srcentbn.h>
  14. #include "bndemo2.h"
  15.  
  16. //***************************************************************************
  17. //***************************************************************************
  18. //
  19. //      Global Variables
  20. //
  21. //***************************************************************************
  22. //***************************************************************************
  23. HINSTANCE hInst;   // current instance
  24.  
  25. char   MainWndClassName[] = "BNDemo2WClass",
  26.        MainWndMenu[]      = "BNDemo2Menu",
  27.        ProgTitle[]        = "BNDemo2 - Button Sample Application";
  28.  
  29. LPSTR cBuff  = "         ";
  30.  
  31. DWORD TextColor = RGB(0,0,0);
  32.  
  33. //***************************************************************************
  34. //
  35. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  36. //
  37. //  PURPOSE: calls initialization function, processes message loop
  38. //
  39. //***************************************************************************
  40. int PASCAL WinMain(HINSTANCE hInstance,        // current instance
  41.                    HINSTANCE hPrevInstance,    // previous instance
  42.                    LPSTR     lpCmdLine,        // command line
  43.                    int       nCmdShow)         // show-window type
  44.  
  45. {
  46.  
  47.    MSG msg;  // message
  48.  
  49.    //****************************************************************
  50.  
  51.    if (!hPrevInstance)                  // Other instances of app running?
  52.        if (!InitApplication(hInstance)) // Initialize shared things
  53.            return (FALSE);              // Exits if unable to initialize
  54.  
  55.    // Perform initializations that apply to a specific instance
  56.    if (!InitInstance(hInstance, nCmdShow))
  57.        return (FALSE);
  58.  
  59.    // Acquire and dispatch messages until a WM_QUIT message is received.
  60.    while (GetMessage(&msg,        // message structure
  61.            NULL,                  // handle of window receiving the message
  62.            NULL,                  // lowest message to examine
  63.            NULL))                 // highest message to examine
  64.    {
  65.        TranslateMessage(&msg);    // Translates virtual key codes
  66.        DispatchMessage(&msg);     // Dispatches message to window
  67.    }
  68.  
  69.    UnregisterClass((LPSTR)MainWndClassName,hInst);
  70.  
  71.    return (msg.wParam);           // Returns the value from PostQuitMessage/
  72.  
  73. } // end WinMain
  74.  
  75. //***************************************************************************
  76. //
  77. //  FUNCTION: InitApplication(HINSTANCE)
  78. //
  79. //  PURPOSE: Initializes window data and registers window class
  80. //
  81. //***************************************************************************
  82. BOOL InitApplication(HINSTANCE hInstance)
  83. {
  84.  
  85.    WNDCLASS  wc;
  86.  
  87.    //****************************************************************
  88.  
  89.    // Fill in window class structure with parameters that describe the
  90.    // main window.
  91.  
  92.    wc.style = NULL;
  93.    wc.lpfnWndProc = (WNDPROC)MainWndProc;
  94.    wc.cbClsExtra = 0;
  95.    wc.cbWndExtra = 0;
  96.    wc.hInstance = hInstance;
  97.    wc.hIcon = LoadIcon(hInstance,"progicon");
  98.    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  99.    wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  100.    wc.lpszMenuName =  MainWndMenu;
  101.    wc.lpszClassName = MainWndClassName;
  102.  
  103.    // Register the window class and return success/failure code.
  104.    return (RegisterClass(&wc));
  105.  
  106. }  // end InitApplication
  107.  
  108. //***************************************************************************
  109. //
  110. //  FUNCTION:  InitInstance(HINSTANCE, int)
  111. //
  112. //  PURPOSE:  Saves instance handle and creates main window
  113. //
  114. //***************************************************************************
  115. BOOL InitInstance(HINSTANCE hInstance, // Current instance identifier.
  116.                   int       nCmdShow)  // Param for first ShowWindow() call.
  117. {
  118.  
  119.    HWND hWnd;              // Main window handle.
  120.  
  121.    //****************************************************************
  122.  
  123.    // Save the instance handle
  124.    hInst = hInstance;
  125.  
  126.    // Create a main window for this application instance.
  127.    hWnd = CreateWindow(
  128.        MainWndClassName,
  129.        ProgTitle,
  130.        WS_OVERLAPPEDWINDOW,
  131.        10,
  132.        10,
  133.        415,
  134.        270,
  135.        NULL,
  136.        NULL,
  137.        hInstance,
  138.        NULL
  139.    );
  140.  
  141.    // If window could not be created, return "failure"
  142.    if (!hWnd)
  143.        return (FALSE);
  144.  
  145.    // Make the window visible; update its client area; and return "success"
  146.    ShowWindow(hWnd, nCmdShow);  // Show the window
  147.    UpdateWindow(hWnd);          // Sends WM_PAINT message
  148.    return (TRUE);               // Returns the value from PostQuitMessage
  149.  
  150. }  // end InitInstance
  151.  
  152. //***************************************************************************
  153. //
  154. //  FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
  155. //
  156. //  PURPOSE:  Processes messages
  157. //
  158. //***************************************************************************
  159. long FAR PASCAL __export MainWndProc(
  160.                      HWND     hWnd,    // window handle
  161.                      unsigned message, // type of message
  162.                      WORD     wParam,  // additional information
  163.                      LONG     lParam)  // additional information
  164. {
  165.  
  166.    static HWND hVSPEdit1, // Window handles for the vertical
  167.                hVSPEdit2, // Spin Buttons Edit controls              
  168.                hVSPEdit3,
  169.                hVSPEdit4,
  170.                hVSPEdit5,
  171.                hVSPEdit6,
  172.  
  173.                hHSPEdit1, // Window handles for the horizontal
  174.                hHSPEdit2, // Spin Buttons Edit controls
  175.                hHSPEdit3,
  176.                hHSPEdit4,
  177.                hHSPEdit5,
  178.                hHSPEdit6,
  179.  
  180.                // Fancy Spin Button Edit Control
  181.                hVEdit;
  182.  
  183.    // Declare Class Instances of all Buttons
  184.    static CSRCEntBN
  185.  
  186.       // Vertical Spin Buttons
  187.       VSpin1, VSpin2, VSpin3, VSpin4,VSpin5,VSpin6,
  188.  
  189.       // Horizontal Spin Buttons
  190.       HSpin1, HSpin2, HSpin3, HSpin4,HSpin5,HSpin6,
  191.       
  192.       // 2-State Toggle Switch use to disable
  193.       // and enable the vertical spin buttons.
  194.       NFTSw,
  195.  
  196.       // Spin Button used to similate a 2-State 
  197.       // Momentary Toggle Switch used to disable and enable the
  198.       // horizontal Spin buttons.
  199.       Switch1,
  200.                
  201.       // Color Buttons
  202.       RedBut, GrnBut, BluBut, YelBut,
  203.       CynBut, MagBut, GryBut, BlkBut,
  204.                    
  205.       // Fancy Spin Button
  206.       Volume,
  207.  
  208.       // 2-State Push Style Button.
  209.       // Used to Enable and disable the fancy volume button
  210.       Voled;
  211.  
  212.    //****************************************************************
  213.  
  214.    switch (message)
  215.    {
  216.  
  217.       case WM_CREATE:
  218.  
  219.          // Create Spin Button on the Main windlow client area.
  220.          // This will be vertical, using the size 1 predefined bitmaps.
  221.          VSpin1.Create(
  222.             BTN_VERT | BTN_SPIN1,   // Vertical size 1 
  223.             0,0,0,0,                // No User Bitmap
  224.             20,10,                  // Spin button position
  225.             0,0,                    // Spin button size (use defaults)
  226.             1,                      // Step value
  227.             0,100,                  // range
  228.             50,                     // Initial value
  229.             150,10,                 // Delay, Speed
  230.             TRUE,                   // Use Hand Cursor
  231.             hWnd,                   // Parent window handle
  232.             VSPIN1,                 // ID Value
  233.             hInst);                 // This instance owns this window
  234.  
  235.          // EDIT control to display the above Spin Button value
  236.          hVSPEdit1 = CreateWindow(
  237.             "EDIT",
  238.             "0",
  239.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  240.             35,10,32,22,
  241.             hWnd,
  242.             VSPEDIT1,
  243.             hInst,
  244.             NULL
  245.          );
  246.          wsprintf(cBuff,"%d",VSpin1.GetVal());
  247.          SetWindowText(hVSPEdit1,cBuff);
  248.  
  249.          // Create Spin Button on the Main windlow client area.
  250.          // This will be vertical, using the size 2 predefined bitmaps.
  251.          VSpin2.Create(
  252.             BTN_VERT | BTN_SPIN2,   // Vertical size 2
  253.             0,0,0,0,                // No User Bitmap
  254.             18,40,                  // Spin button position
  255.             0,0,                    // Spin button size (use defaults)
  256.             1,                      // Step value
  257.             0,100,                  // range
  258.             50,                     // Initial value
  259.             150,10,                 // Delay, Speed
  260.             TRUE,                   // Use Hand Cursor
  261.             hWnd,                   // Parent window handle
  262.             VSPIN2,                 // ID Value
  263.             hInst);                 // This instance owns this window
  264.  
  265.          // EDIT control to display the above Spin Button value
  266.          hVSPEdit2 = CreateWindow(
  267.             "EDIT",
  268.             "0",
  269.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  270.             35,40,32,22,
  271.             hWnd,
  272.             VSPEDIT2,
  273.             hInst,
  274.             NULL
  275.          );
  276.          wsprintf(cBuff,"%d",VSpin2.GetVal());
  277.          SetWindowText(hVSPEdit2,cBuff);
  278.  
  279.          // Create Spin Button on the Main windlow client area.
  280.          // This will be vertical, using the size 3 predefined bitmaps.
  281.          VSpin3.Create(
  282.             BTN_VERT | BTN_SPIN3,   // Vertical size 3
  283.             0,0,0,0,                // No User Bitmap
  284.             16,70,                  // Spin button position
  285.             0,0,                    // Spin button size (use defaults)
  286.             1,                      // Step value
  287.             0,100,                  // range
  288.             50,                     // Initial value
  289.             150,10,                 // Delay, Speed
  290.             TRUE,                   // Use Hand Cursor
  291.             hWnd,                   // Parent window handle
  292.             VSPIN3,                 // ID Value
  293.             hInst);                 // This instance owns this window
  294.  
  295.          // EDIT control to display the above Spin Button value
  296.          hVSPEdit3 = CreateWindow(
  297.             "EDIT",
  298.             "0",
  299.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  300.             35,70,32,22,
  301.             hWnd,
  302.             VSPEDIT3,
  303.             hInst,
  304.             NULL
  305.          );
  306.          wsprintf(cBuff,"%d",VSpin3.GetVal());
  307.          SetWindowText(hVSPEdit3,cBuff);
  308.  
  309.          // Create Spin Button on the Main windlow client area.
  310.          // This will be vertical, using the size 4 predefined bitmaps.
  311.          VSpin4.Create(
  312.             BTN_VERT | BTN_SPIN4,   // Vertical size 4
  313.             0,0,0,0,                // No User Bitmap
  314.             14,100,                 // Spin button position
  315.             0,0,                    // Spin button size (use defaults)
  316.             1,                      // Step value
  317.             0,100,                  // range
  318.             50,                     // Initial value
  319.             150,10,                 // Delay, Speed
  320.             TRUE,                   // Use Hand Cursor
  321.             hWnd,                   // Parent window handle
  322.             VSPIN4,                 // ID Value
  323.             hInst);                 // This instance owns this window
  324.  
  325.          // EDIT control to display the above Spin Button value
  326.          hVSPEdit4 = CreateWindow(
  327.             "EDIT",
  328.             "0",
  329.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  330.             35,100,32,22,
  331.             hWnd,
  332.             VSPEDIT4,
  333.             hInst,
  334.             NULL
  335.          );
  336.          wsprintf(cBuff,"%d",VSpin4.GetVal());
  337.          SetWindowText(hVSPEdit4,cBuff);
  338.  
  339.          // Create Spin Button on the Main windlow client area.
  340.          // This will be vertical, using the size 5 predefined bitmaps.
  341.          VSpin5.Create(
  342.             BTN_VERT | BTN_SPIN5,   // Vertical size 5
  343.             0,0,0,0,                // No User Bitmap
  344.             12,130,                 // Spin button position
  345.             0,0,                    // Spin button size (use defaults)
  346.             1,                      // Step value
  347.             0,100,                  // range
  348.             50,                     // Initial value
  349.             150,10,                 // Delay, Speed
  350.             TRUE,                   // Use Hand Cursor
  351.             hWnd,                   // Parent window handle
  352.             VSPIN5,                 // ID Value
  353.             hInst);                 // This instance owns this window
  354.  
  355.          // EDIT control to display the above Spin Button value
  356.          hVSPEdit5 = CreateWindow(
  357.             "EDIT",
  358.             "0",
  359.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  360.             35,130,32,22,
  361.             hWnd,
  362.             VSPEDIT5,
  363.             hInst,
  364.             NULL
  365.          );
  366.          wsprintf(cBuff,"%d",VSpin5.GetVal());
  367.          SetWindowText(hVSPEdit5,cBuff);
  368.  
  369.          // Create Spin Button on the Main windlow client area.
  370.          // This will be vertical, using the size 6 predefined bitmaps.
  371.          VSpin6.Create(
  372.             BTN_VERT | BTN_SPIN6,   // Vertical size 6
  373.             0,0,0,0,                // No User Bitmap
  374.             10,160,                 // Spin button position
  375.             0,0,                    // Spin button size (use defaults)
  376.             1,                      // Step value
  377.             0,100,                  // range
  378.             50,                     // Initial value
  379.             150,10,                 // Delay, Speed
  380.             TRUE,                   // Use Hand Cursor
  381.             hWnd,                   // Parent window handle
  382.             VSPIN6,                 // ID Value
  383.             hInst);                 // This instance owns this window
  384.  
  385.          // EDIT control to display the above Spin Button value
  386.          hVSPEdit6 = CreateWindow(
  387.             "EDIT",
  388.             "0",
  389.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  390.             35,160,32,22,
  391.             hWnd,
  392.             VSPEDIT6,
  393.             hInst,
  394.             NULL
  395.          );
  396.          wsprintf(cBuff,"%d",VSpin6.GetVal());
  397.          SetWindowText(hVSPEdit6,cBuff);
  398.  
  399.          // Create Spin Button on the Main windlow client area.
  400.          // This will be horizontal, using the size 1 predefined bitmaps.
  401.          HSpin1.Create(
  402.             BTN_SPIN1 | BTN_WRAP,   // Horizontal size 1 w/Value Wrap
  403.             0,0,0,0,                // No User Bitmap
  404.             95,10,                  // Spin button position
  405.             0,0,                    // Spin button size (use defaults)
  406.             1,                      // Step value
  407.             0,100,                  // range
  408.             50,                     // Initial value
  409.             500,150,                // Delay, Speed
  410.             FALSE,                  // Use Arrow Cursor
  411.             hWnd,                   // Parent window handle
  412.             HSPIN1,                 // ID Value
  413.             hInst);                 // This instance owns this window
  414.  
  415.          // EDIT control to display the above Spin Button value
  416.          hHSPEdit1 = CreateWindow(
  417.             "EDIT",
  418.             "0",
  419.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  420.             115,10,32,22,
  421.             hWnd,
  422.             HSPEDIT1,
  423.             hInst,
  424.             NULL
  425.          );
  426.          wsprintf(cBuff,"%d",HSpin1.GetVal());
  427.          SetWindowText(hHSPEdit1,cBuff);
  428.  
  429.          // Create Spin Button on the Main windlow client area.
  430.          // This will be horizontal, using the size 2 predefined bitmaps.
  431.          HSpin2.Create(
  432.             BTN_SPIN2 | BTN_WRAP,   // Horizontal size 2 w/Value Wrap
  433.             0,0,0,0,                // No User Bitmap
  434.             93,40,                  // Spin button position
  435.             0,0,                    // Spin button size (use defaults)
  436.             1,                      // Step value
  437.             0,100,                  // range
  438.             50,                     // Initial value
  439.             500,150,                // Delay, Speed
  440.             FALSE,                  // Use Arrow Cursor
  441.             hWnd,                   // Parent window handle
  442.             HSPIN2,                 // ID Value
  443.             hInst);                 // This instance owns this window
  444.  
  445.          // EDIT control to display the above Spin Button value
  446.          hHSPEdit2 = CreateWindow(
  447.             "EDIT",
  448.             "0",
  449.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  450.             115,40,32,22,
  451.             hWnd,
  452.             HSPEDIT2,
  453.             hInst,
  454.             NULL
  455.          );
  456.          wsprintf(cBuff,"%d",HSpin2.GetVal());
  457.          SetWindowText(hHSPEdit2,cBuff);
  458.  
  459.          // Create Spin Button on the Main windlow client area.
  460.          // This will be horizontal, using the size 3 predefined bitmaps.
  461.          HSpin3.Create(
  462.             BTN_SPIN3 | BTN_WRAP,   // Horizontal size 3 w/Value Wrap
  463.             0,0,0,0,                // No User Bitmap
  464.             91,70,                  // Spin button position
  465.             0,0,                    // Spin button size (use defaults)
  466.             1,                      // Step value
  467.             0,100,                  // range
  468.             50,                     // Initial value
  469.             500,150,                // Delay, Speed
  470.             FALSE,                  // Use Arrow Cursor
  471.             hWnd,                   // Parent window handle
  472.             HSPIN3,                 // ID Value
  473.             hInst);                 // This instance owns this window
  474.  
  475.          // EDIT control to display the above Spin Button value
  476.          hHSPEdit3 = CreateWindow(
  477.             "EDIT",
  478.             "0",
  479.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  480.             115,70,32,22,
  481.             hWnd,
  482.             HSPEDIT3,
  483.             hInst,
  484.             NULL
  485.          );
  486.          wsprintf(cBuff,"%d",HSpin3.GetVal());
  487.          SetWindowText(hHSPEdit3,cBuff);
  488.  
  489.          // Create Spin Button on the Main windlow client area.
  490.          // This will be horizontal, using the size 4 predefined bitmaps.
  491.          HSpin4.Create(
  492.             BTN_SPIN4 | BTN_WRAP,   // Horizontal size 4 w/Value Wrap
  493.             0,0,0,0,                // No User Bitmap
  494.             89,100,                 // Spin button position
  495.             0,0,                    // Spin button size (use defaults)
  496.             1,                      // Step value
  497.             0,100,                  // range
  498.             50,                     // Initial value
  499.             500,150,                // Delay, Speed
  500.             FALSE,                  // Use Arrow Cursor
  501.             hWnd,                   // Parent window handle
  502.             HSPIN4,                 // ID Value
  503.             hInst);                 // This instance owns this window
  504.  
  505.          // EDIT control to display the above Spin Button value
  506.          hHSPEdit4 = CreateWindow(
  507.             "EDIT",
  508.             "0",
  509.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  510.             115,100,32,22,
  511.             hWnd,
  512.             HSPEDIT4,
  513.             hInst,
  514.             NULL
  515.          );
  516.          wsprintf(cBuff,"%d",HSpin4.GetVal());
  517.          SetWindowText(hHSPEdit4,cBuff);
  518.  
  519.          // Create Spin Button on the Main windlow client area.
  520.          // This will be horizontal, using the size 5 predefined bitmaps.
  521.          HSpin5.Create(
  522.             BTN_SPIN5 | BTN_WRAP,   // Horizontal size 5 w/Value Wrap
  523.             0,0,0,0,                // No User Bitmap
  524.             87,130,                 // Spin button position
  525.             0,0,                    // Spin button size (use defaults)
  526.             1,                      // Step value
  527.             0,100,                  // range
  528.             50,                     // Initial value
  529.             500,150,                // Delay, Speed
  530.             FALSE,                  // Use Arrow Cursor
  531.             hWnd,                   // Parent window handle
  532.             HSPIN5,                 // ID Value
  533.             hInst);                 // This instance owns this window
  534.  
  535.          // EDIT control to display the above Spin Button value
  536.          hHSPEdit5 = CreateWindow(
  537.             "EDIT",
  538.             "0",
  539.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  540.             115,130,32,22,
  541.             hWnd,
  542.             HSPEDIT5,
  543.             hInst,
  544.             NULL
  545.          );
  546.          wsprintf(cBuff,"%d",HSpin5.GetVal());
  547.          SetWindowText(hHSPEdit5,cBuff);
  548.  
  549.          // Create Spin Button on the Main windlow client area.
  550.          // This will be horizontal, using the size 6 predefined bitmaps.
  551.          HSpin6.Create(
  552.             BTN_SPIN6 | BTN_WRAP,   // Horizontal size 6 w/Value Wrap
  553.             0,0,0,0,                // No User Bitmap
  554.             85,160,                 // Spin button position
  555.             0,0,                    // Spin button size (use defaults)
  556.             1,                      // Step value
  557.             0,100,                  // range
  558.             50,                     // Initial value
  559.             500,150,                // Delay, Speed
  560.             FALSE,                  // Use Arrow Cursor
  561.             hWnd,                   // Parent window handle
  562.             HSPIN6,                 // ID Value
  563.             hInst);                 // This instance owns this window
  564.  
  565.          // EDIT control to display the above Spin Button value
  566.          hHSPEdit6 = CreateWindow(
  567.             "EDIT",
  568.             "0",
  569.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  570.             115,160,32,22,
  571.             hWnd,
  572.             HSPEDIT6,
  573.             hInst,
  574.             NULL
  575.          );
  576.          wsprintf(cBuff,"%d",HSpin6.GetVal());
  577.          SetWindowText(hHSPEdit6,cBuff);
  578.  
  579.          // This is a 2-State Toggle Switch located directly beneath the
  580.          // 6 vertical spin button.  It is used as a switch to enable and
  581.          // disable the vertical spin buttons.
  582.          NFTSw.Create(
  583.             BTN_T2S,         // 2-State Toggle Button Type
  584.             "nftlo",         // Bitmap name for state 1 position
  585.             "nfthi",         // Bitmap name for state 2 position
  586.             "nftlog",        // Bitmap name for disabled state 1 position
  587.             "nfthig",        // Bitmap name for disabled state 2 position
  588.             15,200,          // Button position
  589.             0,0,             // Button size (use bitmap size)
  590.             1,               // Step value
  591.             0,1,             // Range
  592.             1,               // Initial value
  593.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  594.             TRUE,            // Use Hand Cursor
  595.             hWnd,            // Parent window handle
  596.             NFTSW,           // ID Value
  597.             hInst);          // This instance owns this window
  598.  
  599.          // This User defined Spin Button is used to simulate a 2-State
  600.          // Momentary Toggle Switch located directly beneath the 6 horizontal
  601.          // Spin buttons.  It is used as a switch to enable and
  602.          // disable the horizontal spin buttons.
  603.          Switch1.Create(
  604.             BTN_SPINU,       // User defined Spin Button Type
  605.             "switch1",       // Bitmap name for Unpushed State
  606.             "switch1n",      // Bitmap name for Incrementing State
  607.             "switch1f",      // Bitmap name for Decrementing State
  608.             0,               // No Bitmap for Disabled State
  609.             90,200,          // Button position
  610.             0,0,             // Button size (use bitmap size)
  611.             1,               // Step value
  612.             0,1,             // Range
  613.             1,               // Initial value
  614.             1,1,             // Delay, Speed
  615.             FALSE,           // Use Arrow Cursor
  616.             hWnd,            // Parent window handle
  617.             SWITCH1,         // ID Value
  618.             hInst);          // This instance owns this window
  619.  
  620.          // Create a Red Color Button on the Main windlow client area.
  621.          RedBut.Create(
  622.             BTN_RED,         // Red Color Button Type
  623.             0,0,0,0,         // No Bitmaps
  624.             180,10,          // Button position
  625.             15,15,           // Button size
  626.             0,               // No Step Value
  627.             0,0,             // No Range
  628.             0,               // No Initial value
  629.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  630.             TRUE,            // Use Hand Cursor
  631.             hWnd,            // Parent window handle
  632.             REDBUTTON,       // ID Value
  633.             hInst);          // This instance owns this window
  634.  
  635.          // Create a Green Color Button on the Main windlow client area.
  636.          GrnBut.Create(
  637.             BTN_GRN,         // Green Color Button Type
  638.             0,0,0,0,         // No Bitmaps
  639.             205,10,          // Button position
  640.             15,15,           // Button size
  641.             0,               // No Step Value
  642.             0,0,             // No Range
  643.             0,               // No Initial value
  644.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  645.             TRUE,            // Use Hand Cursor
  646.             hWnd,            // Parent window handle
  647.             GRNBUTTON,       // ID Value
  648.             hInst);          // This instance owns this window
  649.  
  650.          // Create a Blue Color Button on the Main windlow client area.
  651.          BluBut.Create(
  652.             BTN_BLU,         // Blue Color Button Type
  653.             0,0,0,0,         // No Bitmaps
  654.             230,10,          // Button position
  655.             15,15,           // Button size
  656.             0,               // No Step Value
  657.             0,0,             // No Range
  658.             0,               // No Initial value
  659.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  660.             TRUE,            // Use Hand Cursor
  661.             hWnd,            // Parent window handle
  662.             BLUBUTTON,       // ID Value
  663.             hInst);          // This instance owns this window
  664.  
  665.          // Create a Yellow Color Button on the Main windlow client area.
  666.          YelBut.Create(
  667.             BTN_YEL,         // Yellow Color Button Type
  668.             0,0,0,0,         // No Bitmaps
  669.             255,10,          // Button position
  670.             15,15,           // Button size
  671.             0,               // No Step Value
  672.             0,0,             // No Range
  673.             0,               // No Initial value
  674.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  675.             TRUE,            // Use Hand Cursor
  676.             hWnd,            // Parent window handle
  677.             YELBUTTON,       // ID Value
  678.             hInst);          // This instance owns this window
  679.  
  680.          // Create a Cyan Color Button on the Main windlow client area.
  681.          CynBut.Create(
  682.             BTN_CYN,         // Cyan Color Button Type
  683.             0,0,0,0,         // No Bitmaps
  684.             280,10,          // Button position
  685.             15,15,           // Button size
  686.             0,               // No Step Value
  687.             0,0,             // No Range
  688.             0,               // No Initial value
  689.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  690.             TRUE,            // Use Hand Cursor
  691.             hWnd,            // Parent window handle
  692.             CYNBUTTON,       // ID Value
  693.             hInst);          // This instance owns this window
  694.  
  695.          // Create a Magenta Color Button on the Main windlow client area.
  696.          MagBut.Create(
  697.             BTN_MAG,         // Magenta Color Button Type
  698.             0,0,0,0,         // No Bitmaps
  699.             305,10,          // Button position
  700.             15,15,           // Button size
  701.             0,               // No Step Value
  702.             0,0,             // No Range
  703.             0,               // No Initial value
  704.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  705.             TRUE,            // Use Hand Cursor
  706.             hWnd,            // Parent window handle
  707.             MAGBUTTON,       // ID Value
  708.             hInst);          // This instance owns this window
  709.  
  710.          // Create a Gray Color Button on the Main windlow client area.
  711.          GryBut.Create(
  712.             BTN_GRY,         // Gray Color Button Type
  713.             0,0,0,0,         // No Bitmaps
  714.             330,10,          // Button position
  715.             15,15,           // Button size
  716.             0,               // No Step Value
  717.             0,0,             // No Range
  718.             0,               // No Initial value
  719.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  720.             TRUE,            // Use Hand Cursor
  721.             hWnd,            // Parent window handle
  722.             GRYBUTTON,       // ID Value
  723.             hInst);          // This instance owns this window
  724.  
  725.          // Create a Black Color Button on the Main windlow client area.
  726.          BlkBut.Create(
  727.             BTN_BLK,         // Black Color Button Type
  728.             0,0,0,0,         // No Bitmaps
  729.             355,10,          // Button position
  730.             15,15,           // Button size
  731.             0,               // No Step Value
  732.             0,0,             // No Range
  733.             0,               // No Initial value
  734.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  735.             TRUE,            // Use Hand Cursor
  736.             hWnd,            // Parent window handle
  737.             BLKBUTTON,       // ID Value
  738.             hInst);          // This instance owns this window
  739.  
  740.          // Create Spin Button for the fancy looking Volume Control
  741.          Volume.Create(
  742.             BTN_SPINU,       // User defined Spin Button Type
  743.             "volume",        // Bitmap name for Unpushed State
  744.             "volumei",       // Bitmap name for Incrementing State
  745.             "volumed",       // Bitmap name for Decrementing State
  746.             "volumeg",       // Bitmap name for Disabled State
  747.             200,100,         // Button position
  748.             0,0,             // Button size (use bitmap size)
  749.             1,               // Step value
  750.             0,100,           // Range
  751.             0,               // Initial value
  752.             200,100,         // Delay, Speed
  753.             TRUE,            // Use Hand Cursor
  754.             hWnd,            // Parent window handle
  755.             VOLUME,          // ID Value
  756.             hInst);          // This instance owns this window
  757.  
  758.          // EDIT control to display the above Spin Button value
  759.          hVEdit = CreateWindow(
  760.             "EDIT",
  761.             "0",
  762.             WS_CHILD | WS_VISIBLE | WS_BORDER | WS_DISABLED,
  763.             200,77,47,22,
  764.             hWnd,
  765.             VEDIT,
  766.             hInst,
  767.             NULL
  768.          );
  769.          wsprintf(cBuff,"%d",Volume.GetVal());
  770.          SetWindowText(hVEdit,cBuff);
  771.  
  772.          // Create 2-State Push Button That will enable and disable
  773.          // the fancy looking Volume Control
  774.          Voled.Create(
  775.             BTN_P2S,         // 2-State Push Button Type
  776.             "vold",          // Bitmap name for Unpushed State 1
  777.             "vole",          // Bitmap name for Unpushed State 2
  778.             "volp",          // Bitmap name for Pushed State
  779.             "0",             // No Bitmap for Disabled State
  780.             200,121,         // Button position
  781.             0,0,             // Button size (use bitmap size)
  782.             1,               // Step value
  783.             0,1,             // Range
  784.             1,               // Initial value
  785.             1,1,             // Delay, Speed  (Ingore by this type anyway)
  786.             TRUE,            // Use Hand Cursor
  787.             hWnd,            // Parent window handle
  788.             VOLED,           // ID Value
  789.             hInst);          // This instance owns this window
  790.  
  791.       break;  // end WM_CREATE
  792.    
  793.       case WM_COMMAND:
  794.  
  795.          switch (wParam)
  796.          {
  797.  
  798.             case VSPIN1:
  799.                wsprintf(cBuff,"%d",VSpin1.GetVal());
  800.                SetWindowText(hVSPEdit1,cBuff);
  801.                UpdateWindow(hVSPEdit1);
  802.             break;
  803.  
  804.             case VSPIN2:
  805.                wsprintf(cBuff,"%d",VSpin2.GetVal());
  806.                SetWindowText(hVSPEdit2,cBuff);
  807.                UpdateWindow(hVSPEdit2);
  808.             break;
  809.  
  810.             case VSPIN3:
  811.                wsprintf(cBuff,"%d",VSpin3.GetVal());
  812.                SetWindowText(hVSPEdit3,cBuff);
  813.                UpdateWindow(hVSPEdit3);
  814.             break;
  815.  
  816.             case VSPIN4:
  817.                wsprintf(cBuff,"%d",VSpin4.GetVal());
  818.                SetWindowText(hVSPEdit4,cBuff);
  819.                UpdateWindow(hVSPEdit4);
  820.             break;
  821.  
  822.             case VSPIN5:
  823.                wsprintf(cBuff,"%d",VSpin5.GetVal());
  824.                SetWindowText(hVSPEdit5,cBuff);
  825.                UpdateWindow(hVSPEdit5);
  826.             break;
  827.  
  828.             case VSPIN6:
  829.                wsprintf(cBuff,"%d",VSpin6.GetVal());
  830.                SetWindowText(hVSPEdit6,cBuff);
  831.                UpdateWindow(hVSPEdit6);
  832.             break;
  833.  
  834.             case HSPIN1:
  835.                wsprintf(cBuff,"%d",HSpin1.GetVal());
  836.                SetWindowText(hHSPEdit1,cBuff);
  837.                UpdateWindow(hHSPEdit1);
  838.             break;
  839.  
  840.             case HSPIN2:
  841.                wsprintf(cBuff,"%d",HSpin2.GetVal());
  842.                SetWindowText(hHSPEdit2,cBuff);
  843.                UpdateWindow(hHSPEdit2);
  844.             break;
  845.  
  846.             case HSPIN3:
  847.                wsprintf(cBuff,"%d",HSpin3.GetVal());
  848.                SetWindowText(hHSPEdit3,cBuff);
  849.                UpdateWindow(hHSPEdit3);
  850.             break;
  851.  
  852.             case HSPIN4:
  853.                wsprintf(cBuff,"%d",HSpin4.GetVal());
  854.                SetWindowText(hHSPEdit4,cBuff);
  855.                UpdateWindow(hHSPEdit4);
  856.             break;
  857.  
  858.             case HSPIN5:
  859.                wsprintf(cBuff,"%d",HSpin5.GetVal());
  860.                SetWindowText(hHSPEdit5,cBuff);
  861.                UpdateWindow(hHSPEdit5);
  862.             break;
  863.  
  864.             case HSPIN6:
  865.                wsprintf(cBuff,"%d",HSpin6.GetVal());
  866.                SetWindowText(hHSPEdit6,cBuff);
  867.                UpdateWindow(hHSPEdit6);
  868.             break;
  869.  
  870.             // 2-State Toggle Switch that disables and disables the 
  871.             // vertical spin buttons.
  872.             case NFTSW:
  873.                if (NFTSw.GetVal())  // Enable Vertical Spin Buttons
  874.                {
  875.                   VSpin1.Enable(TRUE);
  876.                   VSpin2.Enable(TRUE);
  877.                   VSpin3.Enable(TRUE);
  878.                   VSpin4.Enable(TRUE);
  879.                   VSpin5.Enable(TRUE);
  880.                   VSpin6.Enable(TRUE);
  881.                }
  882.                else   // Disable Vertical Spin Buttons
  883.                {
  884.                   VSpin1.Enable(FALSE);
  885.                   VSpin2.Enable(FALSE);
  886.                   VSpin3.Enable(FALSE);
  887.                   VSpin4.Enable(FALSE);
  888.                   VSpin5.Enable(FALSE);
  889.                   VSpin6.Enable(FALSE);
  890.                }
  891.             break;
  892.  
  893.             // Spin Button that similates a 2-State Momentary Toggle Switch that
  894.             // disables and disables the horizontal spin buttons.
  895.             case SWITCH1:
  896.                if (Switch1.GetVal())  // Enable Horizontal Spin Buttons
  897.                {
  898.                   HSpin1.Enable(TRUE);
  899.                   HSpin2.Enable(TRUE);
  900.                   HSpin3.Enable(TRUE);
  901.                   HSpin4.Enable(TRUE);
  902.                   HSpin5.Enable(TRUE);
  903.                   HSpin6.Enable(TRUE);
  904.                }
  905.                else   // Disable Horizontal Spin Buttons
  906.                {
  907.                   HSpin1.Enable(FALSE);
  908.                   HSpin2.Enable(FALSE);
  909.                   HSpin3.Enable(FALSE);
  910.                   HSpin4.Enable(FALSE);
  911.                   HSpin5.Enable(FALSE);
  912.                   HSpin6.Enable(FALSE);
  913.                }
  914.             break;
  915.  
  916.             case REDBUTTON:
  917.                TextColor = RGB(255,0,0);
  918.                InvalidateRect(hWnd,NULL,FALSE);
  919.             break;
  920.  
  921.             case GRNBUTTON:
  922.                TextColor = RGB(0,255,0);
  923.                InvalidateRect(hWnd,NULL,FALSE);
  924.             break;
  925.  
  926.             case BLUBUTTON:
  927.                TextColor = RGB(0,0,255);
  928.                InvalidateRect(hWnd,NULL,FALSE);
  929.             break;
  930.  
  931.             case YELBUTTON:
  932.                TextColor = RGB(255,255,0);
  933.                InvalidateRect(hWnd,NULL,FALSE);
  934.             break;
  935.  
  936.             case CYNBUTTON:
  937.                TextColor = RGB(0,255,255);
  938.                InvalidateRect(hWnd,NULL,FALSE);
  939.             break;
  940.  
  941.             case MAGBUTTON:
  942.                TextColor = RGB(255,0,255);
  943.                InvalidateRect(hWnd,NULL,FALSE);
  944.             break;
  945.  
  946.             case GRYBUTTON:
  947.                TextColor = RGB(128,128,128);
  948.                InvalidateRect(hWnd,NULL,FALSE);
  949.             break;
  950.  
  951.             case BLKBUTTON:
  952.                TextColor = RGB(0,0,0);
  953.                InvalidateRect(hWnd,NULL,FALSE);
  954.             break;
  955.  
  956.             case VOLUME:
  957.                wsprintf(cBuff,"%d",Volume.GetVal());
  958.                SetWindowText(hVEdit,cBuff);
  959.                UpdateWindow(hVEdit);
  960.             break;
  961.  
  962.             case VOLED:
  963.                if (Voled.GetVal())
  964.                   Volume.Enable(TRUE);
  965.                 else
  966.                   Volume.Enable(FALSE);
  967.             break;
  968.  
  969.             case IDM_ABOUT:
  970.             {
  971.  
  972.                FARPROC lpProcAbout; // pointer to the "About" function
  973.  
  974.                //*******************************************************
  975.  
  976.                lpProcAbout = MakeProcInstance((FARPROC)About, hInst);
  977.                DialogBox(hInst,
  978.                          "AboutBox",
  979.                          hWnd,
  980.                          lpProcAbout);
  981.  
  982.                FreeProcInstance(lpProcAbout);
  983.             }
  984.             break;
  985.  
  986.          } // end switch(wParam)
  987.  
  988.       break; // end WM_COMMAND
  989.  
  990.       case WM_PAINT:
  991.       {
  992.  
  993.          PAINTSTRUCT ps;
  994.  
  995.          //**********************************************************
  996.  
  997.          BeginPaint(hWnd,&ps);
  998.          SetBkColor(ps.hdc,RGB(192,192,192));
  999.          SetTextColor(ps.hdc,TextColor);
  1000.          TextOut(ps.hdc,160,30,"Change Text Color With Color Button",35);
  1001.          EndPaint(hWnd,&ps);
  1002.       }
  1003.       break;  // end WM_PAINT
  1004.  
  1005.       case WM_DESTROY:                  // window being destroyed
  1006.          PostQuitMessage(0);
  1007.       break;
  1008.  
  1009.       default:   // Passes it on if unproccessed
  1010.          return (DefWindowProc(hWnd, message, wParam, lParam));
  1011.  
  1012.    }
  1013.  
  1014.    return (NULL);
  1015.  
  1016. } // end MainWndProc
  1017.  
  1018. //***************************************************************************
  1019. //
  1020. //  FUNCTION: About(HWND, unsigned, WORD, LONG)
  1021. //
  1022. //  PURPOSE:  "About" dialog box
  1023. //
  1024. //***************************************************************************
  1025. BOOL FAR PASCAL __export About(HWND     hDlg,
  1026.                                unsigned message,
  1027.                                WORD     wParam,
  1028.                                LONG     lParam)
  1029.  
  1030. {
  1031.  
  1032.    BOOL bRC;
  1033.  
  1034.    //****************************************************************
  1035.  
  1036.    bRC = TRUE;
  1037.  
  1038.    switch (message)
  1039.    {
  1040.  
  1041.       case WM_INITDIALOG:
  1042.       break;
  1043.  
  1044.       case WM_COMMAND:
  1045.          switch (wParam)
  1046.          {
  1047.  
  1048.             case IDOK:
  1049.             case IDCANCEL:
  1050.                EndDialog(hDlg,TRUE);
  1051.             break;
  1052.  
  1053.          } // end switch(wParam)
  1054.  
  1055.       break;
  1056.  
  1057.       default:
  1058.          bRC = FALSE;  // Didn't process a message
  1059.  
  1060.    } // end switch(message)
  1061.  
  1062.    return (bRC);
  1063.  
  1064. }  // end About
  1065.