home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / scentbns / bndemo1.c next >
Encoding:
C/C++ Source or Header  |  1996-11-20  |  40.3 KB  |  1,052 lines

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