home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / various / skelet / skeleton.cpp < prev    next >
C/C++ Source or Header  |  1994-08-15  |  25KB  |  751 lines

  1.  
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Filename:     skeleton.cpp
  5. //
  6. // Description:  Skeleton Visual Basic Custom Control.
  7. //
  8. //               Main module. Contains the control procedure and all message
  9. //               processing routines.
  10. //
  11. // Date Created: <Date>
  12. //
  13. // Author:       <Your Name>
  14. //
  15. // Copyright (c) <Your Company Name> 1994
  16. //
  17. //               Portions of this product are based on original
  18. //                  source code from Anton Software Limited.
  19. //
  20. //////////////////////////////////////////////////////////////////////////////
  21.  
  22. #include <string.h>
  23. #include <windows.h>
  24. #include <vbapi.h>
  25.  
  26. #include "skeleton.hpp"
  27. #include "skelexp.hpp"
  28. #include "skelext.hpp"
  29.  
  30. //////////////////////////////////////////////////////////////////////////////
  31. //
  32. // Local function forward declarations
  33. //
  34. //////////////////////////////////////////////////////////////////////////////
  35. static LONG VBM_CheckProperty(HCTL, HWND, USHORT, USHORT, LONG);
  36. static LONG VBM_CheckProperty_MyProp1(HCTL, HWND, USHORT, USHORT, LONG);
  37. static LONG VBM_Created(HCTL, HWND, USHORT, USHORT, LONG);
  38. static LONG VBM_GetProperty(HCTL, HWND, USHORT, USHORT, LONG);
  39. static LONG VBM_GetProperty_MyProp2(HCTL, HWND, USHORT, USHORT, LONG);
  40. static LONG VBM_Help(HCTL, HWND, USHORT, USHORT, LONG);
  41. static LONG VBM_HelpControl(HCTL, HWND, USHORT, USHORT, LONG);
  42. static LONG VBM_HelpEvent(HCTL, HWND, USHORT, USHORT, LONG);
  43. static LONG VBM_HelpProperty(HCTL, HWND, USHORT, USHORT, LONG);
  44. static LONG VBM_InitPropPopup(HCTL, HWND, USHORT, USHORT, LONG);
  45. static LONG VBM_InitPropPopup_About(HCTL, HWND, USHORT, USHORT, LONG);
  46. static LONG VBM_Initialize(HCTL, HWND, USHORT, USHORT, LONG);
  47. static LONG VBM_Loaded(HCTL, HWND, USHORT, USHORT, LONG);
  48. static LONG VBM_SetProperty(HCTL, HWND, USHORT, USHORT, LONG);
  49. static LONG VBM_SetProperty_MyProp2(HCTL, HWND, USHORT, USHORT, LONG);
  50. static LONG WM_NCDestroy(HCTL, HWND, USHORT, USHORT, LONG);
  51.  
  52. //////////////////////////////////////////////////////////////////////////////
  53. //
  54. // Function Name: SkeletonCtlProc
  55. //
  56. // Description:   Skeleton control procedure. Called by Visual Basic.
  57. //
  58. // Parameters:    hctl - Visual Basic control handle
  59. //                hwnd - Window handle
  60. //                msg  - message
  61. //                wp   - word parameter
  62. //                lp   - long parameter
  63. //
  64. // Return Code:   The result from the appropriate message function, or from
  65. //                the default control procedure if the message is not
  66. //                processed.
  67. //
  68. //////////////////////////////////////////////////////////////////////////////
  69.  
  70. LONG CALLBACK _export SkeletonCtlProc
  71. (
  72.     HCTL   hctl,    // Visual Basic control handle
  73.     HWND   hwnd,    // Window handle
  74.     USHORT msg,     // message
  75.     USHORT wp,      // word parameter
  76.     LONG   lp       // long parameter
  77. )
  78. {
  79.     // Process the message appropriately.
  80.  
  81.     switch (msg)
  82.     {
  83.         case VBM_CHECKPROPERTY:
  84.             return VBM_CheckProperty(hctl, hwnd, msg, wp, lp);
  85.  
  86.         case VBM_CREATED:
  87.             return VBM_Created(hctl, hwnd, msg, wp, lp);
  88.  
  89.         case VBM_GETPROPERTY:
  90.             return VBM_GetProperty(hctl, hwnd, msg, wp, lp);
  91.  
  92.         case VBM_HELP:
  93.             return VBM_Help(hctl, hwnd, msg, wp, lp);
  94.  
  95.         case VBM_INITIALIZE:
  96.             return VBM_Initialize(hctl, hwnd, msg, wp, lp);
  97.  
  98.         case VBM_INITPROPPOPUP:
  99.             return VBM_InitPropPopup(hctl, hwnd, msg, wp, lp);
  100.  
  101.         case VBM_LOADED:
  102.             return VBM_Loaded(hctl, hwnd, msg, wp, lp);
  103.  
  104.         case VBM_SETPROPERTY:
  105.             return VBM_SetProperty(hctl, hwnd, msg, wp, lp);
  106.  
  107.         case WM_NCDESTROY:
  108.             return WM_NCDestroy(hctl, hwnd, msg, wp, lp);
  109.  
  110.         default:
  111.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  112.  
  113.     } // end switch message
  114.  
  115. } // SkeletonCtlProc
  116.  
  117. //////////////////////////////////////////////////////////////////////////////
  118. //
  119. // Function Name: VBM_CheckProperty
  120. //
  121. // DESCRIPTION:   Processes the VBM_CHECKPROPERTY message. Sent by VB when a
  122. //                property needs to be checked for validity.
  123. //
  124. // Parameters:    hctl - Visual Basic control handle
  125. //                hwnd - window handle
  126. //                msg  - message
  127. //                wp   - word parameter
  128. //                lp   - long parameter
  129. //
  130. // Return Code:   The result from the appropriate message function, or from
  131. //                the default control procedure if the message is not
  132. //                processed.
  133. //
  134. //////////////////////////////////////////////////////////////////////////////
  135.  
  136. static LONG VBM_CheckProperty
  137. (
  138.     HCTL   hctl,    // Visual Basic control handle
  139.     HWND   hwnd,    // window handle
  140.     USHORT msg,     // message
  141.     USHORT wp,      // word parameter
  142.     LONG   lp       // long parameter
  143. )
  144. {
  145.     // Switch on the property whose value is being checked...
  146.     switch (wp)
  147.     {
  148.         case IPROP_MYPROP1:
  149.             return VBM_CheckProperty_MyProp1(hctl, hwnd, msg, wp, lp);
  150.  
  151.     } // end switch on the property being checked
  152.  
  153.     // Return the result from the default control procedure.
  154.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  155.  
  156. } // VBM_CheckProperty
  157.  
  158. //////////////////////////////////////////////////////////////////////////////
  159. //
  160. // Function Name: VBM_CheckProperty_MyProp1
  161. //
  162. // Description:   Processes the VBM_CHECKPROPERTY message for the MyProp1
  163. //                property.
  164. //
  165. // Parameters:    hctl - Visual Basic control handle
  166. //                hwnd - window handle
  167. //                msg  - message
  168. //                wp   - word parameter
  169. //                lp   - long parameter
  170. //
  171. // Return Code:   An error code if the property assignment should not proceed,
  172. //                or 0 otherwise.
  173. //
  174. //////////////////////////////////////////////////////////////////////////////
  175.  
  176. static LONG VBM_CheckProperty_MyProp1
  177. (
  178.     HCTL   hctl,    // Visual Basic control handle
  179.     HWND   hwnd,    // window handle
  180.     USHORT msg,     // message
  181.     USHORT wp,      // word parameter
  182.     LONG   lp       // long parameter
  183. )
  184. {
  185.     // TO DO: call VBSetErrorMessage if the property is being set to an
  186.     //        invalid value and return its result.
  187.  
  188.     // All OK, so return 0.
  189.     return 0L;
  190.  
  191. } // VBM_CheckProperty_MyProp1
  192.  
  193. //////////////////////////////////////////////////////////////////////////////
  194. //
  195. // Function Name: VBM_Created
  196. //
  197. // Description:   Processes the VBM_CREATED message. Sent by VB when the
  198. //                control has just been created.
  199. //
  200. // Parameters:    hctl - Visual Basic control handle
  201. //                hwnd - window handle
  202. //                msg  - message
  203. //                wp   - word parameter
  204. //                lp   - long parameter
  205. //
  206. // Return Code:   The result from the default control procedure.
  207. //
  208. //////////////////////////////////////////////////////////////////////////////
  209.  
  210. static LONG VBM_Created
  211. (
  212.     HCTL   hctl,    // Visual Basic control handle
  213.     HWND   hwnd,    // window handle
  214.     USHORT msg,     // message
  215.     USHORT wp,      // word parameter
  216.     LONG   lp       // long parameter
  217. )
  218. {
  219.     // Flag the control as being "created".
  220.     LP_SKELETON_DEREF(hctl)->fCreated = TRUE;
  221.  
  222.     // Return the result from the default control procedure.
  223.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  224.  
  225. } // VBM_Created
  226.  
  227. //////////////////////////////////////////////////////////////////////////////
  228. //
  229. // Function Name: VBM_GetProperty
  230. //
  231. // Description:   Processes the VBM_GETPROPERTY message. Sent by VB when it
  232. //                requires the value of a property.
  233. //
  234. // Parameters:    hctl - Visual Basic control handle
  235. //                hwnd - window handle
  236. //                msg  - message
  237. //                wp   - word parameter
  238. //                lp   - long parameter
  239. //
  240. // Return Code:   The result from the appropriate message function, or from
  241. //                the default control procedure if the message is not
  242. //                processed.
  243. //
  244. //////////////////////////////////////////////////////////////////////////////
  245.  
  246. static LONG VBM_GetProperty
  247. (
  248.     HCTL   hctl,    // Visual Basic control handle
  249.     HWND   hwnd,    // window handle
  250.     USHORT msg,     // message
  251.     USHORT wp,      // word parameter
  252.     LONG   lp       // long parameter
  253. )
  254. {
  255.     // Process the property whose value is being obtained...
  256.     switch (wp)
  257.     {
  258.         case IPROP_MYPROP2:
  259.             return VBM_GetProperty_MyProp2(hctl, hwnd, msg, wp, lp);
  260.  
  261.         default:
  262.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  263.  
  264.     } // end switch on the property being obtained
  265.  
  266. } // VBM_GetProperty
  267.  
  268. //////////////////////////////////////////////////////////////////////////////
  269. //
  270. // Function Name: VBM_GetProperty_MyProp2
  271. //
  272. // Description:   Processes the VBM_GETPROPERTY message for the MyProp2
  273. //                property.
  274. //
  275. // Parameters:    hctl - Visual Basic control handle
  276. //                hwnd - window handle
  277. //                msg  - message
  278. //                wp   - word parameter
  279. //                lp   - long parameter
  280. //
  281. // Return Code:   0 to indicate success.
  282. //
  283. //////////////////////////////////////////////////////////////////////////////
  284.  
  285. static LONG VBM_GetProperty_MyProp2
  286. (
  287.     HCTL   hctl,    // Visual Basic control handle
  288.     HWND   hwnd,    // window handle
  289.     USHORT msg,     // message
  290.     USHORT wp,      // word parameter
  291.     LONG   lp       // long parameter
  292. )
  293. {
  294.     // TO DO: cast lp to a long pointer to the appropriate type, and use it to
  295.     //        return the property's value. Then return 0L. The default control
  296.     //        procedure is just called for the purposes of the skeleton code.
  297.  
  298.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  299.  
  300. } // VBM_GetProperty_MyProp2
  301.  
  302. //////////////////////////////////////////////////////////////////////////////
  303. //
  304. // Function Name: VBM_Help
  305. //
  306. // Description:   Processes the VBM_HELP message. Sent by VB when help (F1)
  307. //                is requested for the current property, event or control.
  308. //
  309. // Parameters:    hctl - Visual Basic control handle
  310. //                hwnd - window handle
  311. //                msg  - message
  312. //                wp   - word parameter
  313. //                lp   - long parameter
  314. //
  315. // Return Code:   The result from the appropriate help function, or from the
  316. //                default control procedure if the message is not processed.
  317. //
  318. //////////////////////////////////////////////////////////////////////////////
  319.  
  320. static LONG VBM_Help
  321. (
  322.     HCTL   hctl,    // Visual Basic control handle
  323.     HWND   hwnd,    // window handle
  324.     USHORT msg,     // message
  325.     USHORT wp,      // word parameter
  326.     LONG   lp       // long parameter
  327. )
  328. {
  329.     // Process the type of help being requested...
  330.     switch (LOBYTE(wp))
  331.     {
  332.         case VBHELP_CTL:
  333.             return VBM_HelpControl(hctl, hwnd, msg, wp, lp);
  334.  
  335.         case VBHELP_EVT:
  336.             return VBM_HelpEvent(hctl, hwnd, msg, wp, lp);
  337.  
  338.         case VBHELP_PROP:
  339.             return VBM_HelpProperty(hctl, hwnd, msg, wp, lp);
  340.  
  341.         default:
  342.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  343.  
  344.     } // end switch on the type of help being requested
  345.  
  346. } // VBM_Help
  347.  
  348. //////////////////////////////////////////////////////////////////////////////
  349. //
  350. // Function Name: VBM_HelpControl
  351. //
  352. // Description:   Processes the VBM_HELP message for help on the control.
  353. //
  354. // Parameters:    hctl - Visual Basic control handle
  355. //                hwnd - window handle
  356. //                msg  - message
  357. //                wp   - word parameter
  358. //                lp   - long parameter
  359. //
  360. // Return Code:   0 to indicate success.
  361. //
  362. //////////////////////////////////////////////////////////////////////////////
  363.  
  364. static LONG VBM_HelpControl
  365. (
  366.     HCTL   hctl,    // Visual Basic control handle
  367.     HWND   hwnd,    // window handle
  368.     USHORT msg,     // message
  369.     USHORT wp,      // word parameter
  370.     LONG   lp       // long parameter
  371. )
  372. {
  373.     // TO DO: call WinHelp to display help for the control. This should result
  374.     //        in the control's help contents page being displayed. (The
  375.     //        message box below is simply used for the skeleton code.)
  376.  
  377.     MessageBox(0, "Help: contents", lpstrMsgBoxTitle, MB_OK);
  378.  
  379.     // Return 0 to indicate success.
  380.     return 0L;
  381.  
  382. } // VBM_HelpControl
  383.  
  384. //////////////////////////////////////////////////////////////////////////////
  385. //
  386. // Function Name: VBM_HelpEvent
  387. //
  388. // Description:   Processes the VBM_HELP message for help on the current
  389. //                event.
  390. //
  391. // Parameters:    hctl - Visual Basic control handle
  392. //                hwnd - window handle
  393. //                msg  - message
  394. //                wp   - word parameter
  395. //                lp   - long parameter
  396. //
  397. // Return Code:   0 if processed (i.e. a custom event); the result from the
  398. //                default control procedure otherwise.
  399. //
  400. //////////////////////////////////////////////////////////////////////////////
  401.  
  402. static LONG VBM_HelpEvent
  403. (
  404.     HCTL   hctl,    // Visual Basic control handle
  405.     HWND   hwnd,    // window handle
  406.     USHORT msg,     // message
  407.     USHORT wp,      // word parameter
  408.     LONG   lp       // long parameter
  409. )
  410. {
  411.     // TO DO: call WinHelp to display help for the current event. HIBYTE(wp)
  412.     //        will contain the event's index. Normally, let standard events
  413.     //        drop through for default processing. (The message box below is
  414.     //        simply used for the skeleton code.)
  415.  
  416.     // Process the event help is being obtained for...
  417.     switch (HIBYTE(wp))
  418.     {
  419.         case IEVENT_MYEVENT:
  420.             MessageBox(0, "Help: MyEvent", lpstrMsgBoxTitle, MB_OK);
  421.             return 0L;
  422.  
  423.         default:
  424.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  425.  
  426.     } // end switch on the event help is being obtained for
  427.  
  428. } // VBM_HelpEvent
  429.  
  430. //////////////////////////////////////////////////////////////////////////////
  431. //
  432. // Function Name: VBM_HelpProperty
  433. //
  434. // Description:   Processes the VBM_HELP message for help on the current
  435. //                event.
  436. //
  437. // Parameters:    hctl - Visual Basic control handle
  438. //                hwnd - window handle
  439. //                msg  - message
  440. //                wp   - word parameter
  441. //                lp   - long parameter
  442. //
  443. // Return Code:   0 if processed (i.e. a custom event); the result from the
  444. //                default control procedure otherwise.
  445. //
  446. //////////////////////////////////////////////////////////////////////////////
  447.  
  448. static LONG VBM_HelpProperty
  449. (
  450.     HCTL   hctl,    // Visual Basic control handle
  451.     HWND   hwnd,    // window handle
  452.     USHORT msg,     // message
  453.     USHORT wp,      // word parameter
  454.     LONG   lp       // long parameter
  455. )
  456. {
  457.     // TO DO: call WinHelp to display help for the current property.
  458.     //        HIBYTE(wp) will contain the property's index. Normally, let
  459.     //        standard properties drop through for default processing. (The
  460.     //        message boxes below are simply used for the skeleton code.) Note
  461.     //        that help on the About property should result in the control's
  462.     //        help contents page being displayed.
  463.  
  464.     // Process the property help is being obtained for...
  465.     switch (HIBYTE(wp))
  466.     {
  467.         case IPROP_ABOUT:
  468.             MessageBox(0, "Help: contents", lpstrMsgBoxTitle, MB_OK);
  469.             return 0L;
  470.  
  471.         case IPROP_MYPROP1:
  472.             MessageBox(0, "Help: MyProp1", lpstrMsgBoxTitle, MB_OK);
  473.             return 0L;
  474.  
  475.         case IPROP_MYPROP2:
  476.             MessageBox(0, "Help: MyProp2", lpstrMsgBoxTitle, MB_OK);
  477.             return 0L;
  478.  
  479.         default:
  480.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  481.  
  482.     } // end switch on the property help is being obtained for
  483.  
  484. } // VBM_HelpProperty
  485.  
  486. //////////////////////////////////////////////////////////////////////////////
  487. //
  488. // Function Name: VBM_Initialize
  489. //
  490. // Description:   Processes the VBM_INITIALIZE message. Called after the
  491. //                control structure has been allocated (nothing else will have
  492. //                been loaded or allocated).
  493. //
  494. // Parameters:    hctl - Visual Basic control handle
  495. //                hwnd - window handle
  496. //                msg  - message
  497. //                wp   - word parameter
  498. //                lp   - long parameter
  499. //
  500. // Return Code:   The result from the default control procedure.
  501. //
  502. //////////////////////////////////////////////////////////////////////////////
  503.  
  504. static LONG VBM_Initialize
  505. (
  506.     HCTL   hctl,    // Visual Basic control handle
  507.     HWND   hwnd,    // window handle
  508.     USHORT msg,     // message
  509.     USHORT wp,      // word parameter
  510.     LONG   lp       // long parameter
  511. )
  512. {
  513.     // Zero out the control structure.
  514.     _fmemset(LP_SKELETON_DEREF(hctl), 0, sizeof(SKELETON));
  515.  
  516.     // Flag the control as being "initialised".
  517.     LP_SKELETON_DEREF(hctl)->fInitialised = TRUE;
  518.  
  519.     // Return the result from the default control procedure.
  520.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  521.  
  522. } // VBM_Initialize
  523.  
  524. //////////////////////////////////////////////////////////////////////////////
  525. //
  526. // Function Name: VBM_InitPropPopup
  527. //
  528. // Description:   Processes the VBM_INITPROPPOPUP message. Sent by VB after a
  529. //                property has been selected in the property window.
  530. //
  531. // Parameters:    hctl - Visual Basic control handle
  532. //                hwnd - window handle
  533. //                msg  - message
  534. //                wp   - word parameter
  535. //                lp   - long parameter
  536. //
  537. // Return Code:   The result from the appropriate message function, or from
  538. //                the default control procedure if the message is not
  539. //                processed.
  540. //
  541. //////////////////////////////////////////////////////////////////////////////
  542.  
  543. static LONG VBM_InitPropPopup
  544. (
  545.     HCTL   hctl,    // Visual Basic control handle
  546.     HWND   hwnd,    // window handle
  547.     USHORT msg,     // message
  548.     USHORT wp,      // word parameter
  549.     LONG   lp       // long parameter
  550. )
  551. {
  552.     // Process the property that has been selected...
  553.     switch (wp)
  554.     {
  555.         case IPROP_ABOUT:
  556.             return VBM_InitPropPopup_About(hctl, hwnd, msg, wp, lp);
  557.  
  558.         default:
  559.             return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  560.  
  561.     } // end switch on the property that has been selected
  562.  
  563. }  // VBM_InitPropPopup
  564.  
  565. //////////////////////////////////////////////////////////////////////////////
  566. //
  567. // Function Name: VBM_InitPropPopup_About
  568. //
  569. // Description:   Processes the VBM_INITPROPPOPUP message for the About
  570. //                property.
  571. //
  572. // Parameters:    hctl - Visual Basic control handle
  573. //                hwnd - window handle
  574. //                msg  - message
  575. //                wp   - word parameter
  576. //                lp   - long parameter
  577. //
  578. // Return Code:   The result from CreateWindow().
  579. //
  580. //////////////////////////////////////////////////////////////////////////////
  581.  
  582. static LONG VBM_InitPropPopup_About
  583. (
  584.     HCTL   hctl,    // Visual Basic control handle
  585.     HWND   hwnd,    // window handle
  586.     USHORT msg,     // message
  587.     USHORT wp,      // word parameter
  588.     LONG   lp       // long parameter
  589. )
  590. {
  591.     // Create the about box's invisible controlling parent window, causing
  592.     // the about box to be displayed.
  593.     return CreateWindow(lpstrAboutBoxParent,    // class name
  594.                         NULL,                   // window text
  595.                         WS_POPUP,               // window style
  596.                         0,                      // horizontal position
  597.                         0,                      // vertical position
  598.                         0,                      // width
  599.                         0,                      // height
  600.                         NULL,                   // parent
  601.                         NULL,                   // child identifier
  602.                         hmodDLL,                // application instance handle
  603.                         NULL);                  // window creation data
  604.  
  605. } // VBM_InitPropPopup_About
  606.  
  607. //////////////////////////////////////////////////////////////////////////////
  608. //
  609. // Function Name: VBM_Loaded
  610. //
  611. // Description:   Processes the VBM_LOADED message. Sent by VB after ALL the
  612. //                controls on a form have been loaded.
  613. //
  614. // Parameters:    hctl - Visual Basic control handle
  615. //                hwnd - window handle
  616. //                msg  - message
  617. //                wp   - word parameter
  618. //                lp   - long parameter
  619. //
  620. // Return Code:   The result from the default control procedure.
  621. //
  622. //////////////////////////////////////////////////////////////////////////////
  623.  
  624. static LONG VBM_Loaded
  625. (
  626.     HCTL   hctl,    // Visual Basic control handle
  627.     HWND   hwnd,    // window handle
  628.     USHORT msg,     // message
  629.     USHORT wp,      // word parameter
  630.     LONG   lp       // long parameter
  631. )
  632. {
  633.     // Flag the control as being "loaded".
  634.     LP_SKELETON_DEREF(hctl)->fLoaded = TRUE;
  635.  
  636.     // Return the result from the default control procedure.
  637.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  638.  
  639. } // VBM_Loaded
  640.  
  641. //////////////////////////////////////////////////////////////////////////////
  642. //
  643. // Function Name: VBM_SetProperty
  644. //
  645. // DESCRIPTION:   Processes the VBM_SETPROPERTY message. Sent by VB to request
  646. //                that a property be set to the specified value.
  647. //
  648. // Parameters:    hctl - Visual Basic control handle
  649. //                hwnd - window handle
  650. //                msg  - message
  651. //                wp   - word parameter
  652. //                lp   - long parameter
  653. //
  654. // Return Code:   The result from the appropriate message function, or from
  655. //                the default control procedure if the message is not
  656. //                processed.
  657. //
  658. //////////////////////////////////////////////////////////////////////////////
  659.  
  660. static LONG VBM_SetProperty
  661. (
  662.     HCTL   hctl,    // Visual Basic control handle
  663.     HWND   hwnd,    // window handle
  664.     USHORT msg,     // message
  665.     USHORT wp,      // word parameter
  666.     LONG   lp       // long parameter
  667. )
  668. {
  669.     // Switch on the property whose value is being set...
  670.     switch (wp)
  671.     {
  672.         case IPROP_MYPROP2:
  673.             return VBM_SetProperty_MyProp2(hctl, hwnd, msg, wp, lp);
  674.  
  675.     } // end switch on the property being checked
  676.  
  677.     // Return the result from the default control procedure.
  678.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  679.  
  680. } // VBM_SetProperty
  681.  
  682. //////////////////////////////////////////////////////////////////////////////
  683. //
  684. // Function Name: VBM_SetProperty_MyProp2
  685. //
  686. // Description:   Processes the VBM_SETPROPERTY message for the MyProp2
  687. //                property.
  688. //
  689. // Parameters:    hctl - Visual Basic control handle
  690. //                hwnd - window handle
  691. //                msg  - message
  692. //                wp   - word parameter
  693. //                lp   - long parameter
  694. //
  695. // Return Code:   The result from the default control procedure.
  696. //
  697. //////////////////////////////////////////////////////////////////////////////
  698.  
  699. static LONG VBM_SetProperty_MyProp2
  700. (
  701.     HCTL   hctl,    // Visual Basic control handle
  702.     HWND   hwnd,    // window handle
  703.     USHORT msg,     // message
  704.     USHORT wp,      // word parameter
  705.     LONG   lp       // long parameter
  706. )
  707. {
  708.     // TO DO: cast lp to a long pointer to the appropriate type, and use it to
  709.     //        set the property's value. Then return 0L. The default control
  710.     //        procedure is just called for the purposes of the skeleton code.
  711.  
  712.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  713.  
  714. } // VBM_SetProperty_MyProp2
  715.  
  716. //////////////////////////////////////////////////////////////////////////////
  717. //
  718. // Function Name: WM_NCDestroy
  719. //
  720. // Description:   Processes the WM_NCDESTROY message. Sent by Windows when the
  721. //                control (i.e. its window) is being destroyed.
  722. //
  723. // Parameters:    hctl - Visual Basic control handle
  724. //                hwnd - window handle
  725. //                msg  - message
  726. //                wp   - word parameter
  727. //                lp   - long parameter
  728. //
  729. // Return Code:   0 to indicate that the message was processed.
  730. //
  731. //////////////////////////////////////////////////////////////////////////////
  732.  
  733. static LONG WM_NCDestroy
  734. (
  735.     HCTL       hctl,    // Visual Basic control handle
  736.     HWND       hwnd,    // window handle
  737.     USHORT, // msg,     // message
  738.     USHORT, // wp,      // word parameter
  739.     LONG    // lp       // long parameter
  740. )
  741. {
  742.     // Destroy the HSZ property(ies).
  743.     if (LP_SKELETON_DEREF(hctl)->hszMyProp1 != (HSZ)NULL)
  744.         VBDestroyHsz(LP_SKELETON_DEREF(hctl)->hszMyProp1);
  745.  
  746.     // Return 0 to indicate that the message has been processed.
  747.     return 0L;
  748.  
  749. } // WM_NCDestroy
  750.  
  751.