home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpsgpf.zip / SIM.C < prev    next >
Text File  |  1995-02-22  |  45KB  |  1,131 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 2.41
  6.  */
  7.  
  8. //*****************************************************************************
  9. //
  10. // TITLE:          Simple WPS Class
  11. //
  12. // FILE:           sim.c
  13. //
  14. // CLASS:          WPSimple
  15. //
  16. // MAJOR CHANGES:  00.00
  17. //
  18. // DESCRIPTION:    see sim.c
  19. //
  20. // (C) Copyright SES GmbH Berlin 1994.        All rights reserved.
  21. //
  22. //*****************************************************************************
  23.  
  24. //-----------------------------------------------------------------------------
  25. // PM definitions
  26. //-----------------------------------------------------------------------------
  27. #define INCL_DOSERRORS
  28. #define INCL_DOSMEMMGR
  29. #define INCL_DOSMODULEMGR
  30. #define INCL_DOSMISC
  31. #define INCL_DOSPROCESS
  32. #define INCL_WINBUTTONS
  33. #define INCL_WINDIALOGS
  34. #define INCL_WINENTRYFIELDS
  35. #define INCL_WINFRAMEMGR
  36. #define INCL_WINLISTBOXES
  37. #define INCL_WINMENUS
  38. #define INCL_WINPOINTERS
  39. #define INCL_WINSTDBOOK
  40. #define INCL_WINTIMER
  41. #define INCL_WINWINDOWMGR
  42. #define INCL_WINWORKPLACE
  43. #include <os2.h>
  44.  
  45. //-----------------------------------------------------------------------------
  46. // C definitions
  47. //-----------------------------------------------------------------------------
  48. #include <stdarg.h>
  49. #include <stdlib.h>
  50. #include <stdio.h>
  51. #include <string.h>
  52. #include <ctype.h>
  53.  
  54. //-----------------------------------------------------------------------------
  55. // Interface to other objects
  56. //-----------------------------------------------------------------------------
  57.  
  58. //-----------------------------------------------------------------------------
  59. // Object definitions
  60. //-----------------------------------------------------------------------------
  61. #define WPSimple_Class_Source
  62. #include "sim.ih"
  63.  
  64. #include "simi.h"
  65.  
  66. // Gpf header file ********************************8
  67.  
  68. #include "aaa.inc"
  69.  
  70.  
  71. //-DLL name--------------------------------------------------------------------
  72. #define DLL_NAME               "sim"
  73.  
  74. //-Simple----------------------------------------------------------------------
  75. #define ICOSTAT_DEFAULTICON1   1
  76. #define ICOSTAT_DEFAULTICON2   2
  77. #define ICOSTAT_DEFAULTICON3   3
  78. #define ICOSTAT_ICONFILE       4
  79.  
  80. //-Save & Restore--------------------------------------------------------------
  81. #define CLASS_NAME             "WPSimple"
  82. #define PERSID_ICONFILE        10
  83. #define PERSID_PLAYSTAT        11
  84. #define PERSID_ICOSTAT         12
  85.  
  86. //-Settings Pages--------------------------------------------------------------
  87.  
  88.  
  89. //-Views-----------------------------------------------------------------------
  90. #define MYOPEN_INFOVIEW        (OPEN_USER + 1)
  91. #define TITLE_INFOVIEW         "Info View"
  92. //*** #define CLSNAME_INFOVIEW       "SESINFOVIEW"
  93. #define LB_INFOVIEW            162
  94.  
  95. //-Drag & Drop-----------------------------------------------------------------
  96.  
  97. //-----------------------------------------------------------------------------
  98. // Debugging Stuff
  99. //-----------------------------------------------------------------------------
  100. #include "..\shared\debug.h"
  101.  
  102. //-----------------------------------------------------------------------------
  103. // Prototypes
  104. //-----------------------------------------------------------------------------
  105.  
  106. //-Init & Setup----------------------------------------------------------------
  107.  
  108. //-Save & Restore--------------------------------------------------------------
  109.  
  110. //-Settings Pages--------------------------------------------------------------
  111. MRESULT EXPENTRY IconFileProc (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2);
  112. VOID             UpdateIconFileDlg (HWND hwnd, WPSimple *somSelf);
  113.  
  114. //-Pop-Up----------------------------------------------------------------------
  115. MRESULT EXPENTRY PlayProc     (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2);
  116.  
  117. //-Views-----------------------------------------------------------------------
  118. VOID             UpdateInfoView    (HWND hwnd, WPSimple *somSelf);
  119.  
  120. //-Drag & Drop-----------------------------------------------------------------
  121. VOID             MyFreeDraginfo    (PDRAGINFO pdinfo);
  122.  
  123. //#############################################################################
  124. // BEGIN Instance Methods (belong to the class)
  125. //#############################################################################
  126.  
  127. //=Init & Setup================================================================
  128. //
  129. // CLASS:     WPSimple
  130. //
  131. // METHOD:    wpInitData
  132. //
  133. // PARAMETER: see Programming Reference
  134. //
  135. // RETURN:    see Programming Reference
  136. //
  137. // DESCRIPT:  see Programming Reference
  138. //
  139. //=============================================================================
  140. SOM_Scope void   SOMLINK wpInitData(WPSimple *somSelf)
  141. {
  142.     BOOL    fOK;
  143.  
  144.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  145.     SOM_TraceLevel = 0;
  146.     WPSimpleMethodDebug("WPSimple","wpInitData");
  147.  
  148.     //-Simple------------------------------------------------------------------
  149.     // Call parent first
  150.     //-------------------------------------------------------------------------
  151.     parent_wpInitData(somSelf);
  152.  
  153.     //-------------------------------------------------------------------------
  154.     // Init the instance data
  155.     //-------------------------------------------------------------------------
  156.  
  157.     //-Simple------------------------------------------------------------------
  158.     _iDummy              = 0;
  159.     _hptrDefault1        = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
  160.                                            IC_DEFAULT1);
  161.     _hptrDefault2        = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
  162.                                            IC_DEFAULT2);
  163.     _hptrDefault3        = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
  164.                                            IC_DEFAULT3);
  165.     _lIconState          = ICOSTAT_DEFAULTICON1;
  166.  
  167.     //-Settings Pages----------------------------------------------------------
  168.     _hwndIconFileView      = NULLHANDLE;
  169.     _hptrIconFile          = NULLHANDLE;
  170.     _szIconFile        [0] = '\0';
  171.     _szIconFileForUndo [0] = '\0';
  172.     _lIconStateForUndo     = ICOSTAT_DEFAULTICON1;
  173.     _fFirstNotification    = TRUE;
  174.  
  175.     //-Views-------------------------------------------------------------------
  176.     _hwndInfoView          = NULLHANDLE;
  177.     _hwndListbox           = NULLHANDLE;
  178.  
  179.  
  180.     //-Views-------------------------------------------------------------------
  181.     // Specify, which view to be opened, if the user just
  182.     //-------------------------------------------------------------------------
  183.     _wpSetDefaultView (somSelf, MYOPEN_INFOVIEW);
  184.  
  185.     //-Simple------------------------------------------------------------------
  186.     // The instance data was changed!
  187.     //-------------------------------------------------------------------------
  188.     _RefreshViews (somSelf);
  189.  
  190.     //-Simple------------------------------------------------------------------
  191.     // Allow the object to go into a dormant state
  192.     //-------------------------------------------------------------------------
  193.     fOK = _wpUnlockObject (somSelf);
  194.     hope (fOK);
  195. }
  196.  
  197. //=Init & Setup================================================================
  198. //
  199. // CLASS:     WPSimple
  200. //
  201. // METHOD:    wpUnInitData
  202. //
  203. // PARAMETER: see Programming Reference
  204. //
  205. // RETURN:    see Programming Reference
  206. //
  207. // DESCRIPT:  see Programming Reference
  208. //
  209. //=============================================================================
  210. SOM_Scope void   SOMLINK wpUnInitData(WPSimple *somSelf)
  211. {
  212.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  213.     SOM_TraceLevel = 0;
  214.     WPSimpleMethodDebug("WPSimple","wpUnInitData");
  215.  
  216.     //-Simple------------------------------------------------------------------
  217.     // We don't need the icons anymore
  218.     //-------------------------------------------------------------------------
  219.     WinDestroyPointer (_hptrDefault1); _hptrDefault1 = NULLHANDLE;
  220.     WinDestroyPointer (_hptrDefault2); _hptrDefault2 = NULLHANDLE;
  221.     WinDestroyPointer (_hptrDefault3); _hptrDefault3 = NULLHANDLE;
  222.  
  223.     //-Simple------------------------------------------------------------------
  224.     // Call parent last
  225.     //-------------------------------------------------------------------------
  226.     parent_wpUnInitData(somSelf);
  227. }
  228.  
  229. //=Init & Setup================================================================
  230. //
  231. // CLASS:     WPSimple
  232. //
  233. // METHOD:    wpSetup
  234. //
  235. // PARAMETER: see Programming Reference
  236. //
  237. // RETURN:    see Programming Reference
  238. //
  239. // DESCRIPT:  see Programming Reference
  240. //
  241. //=============================================================================
  242. SOM_Scope BOOL   SOMLINK wpSetup(WPSimple *somSelf,
  243.                 PSZ pszSetupString)
  244. {
  245.     BOOL  fOK;
  246.     BOOL  fRet;
  247.     CHAR  szValue  [100];
  248.     ULONG cbValue;
  249.     ULONG ulErrorID;
  250.  
  251.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  252.     WPSimpleMethodDebug("WPSimple","wpSetup");
  253.  
  254.     //-Simple------------------------------------------------------------------
  255.     // Call parent first
  256.     //-------------------------------------------------------------------------
  257.     fRet = parent_wpSetup(somSelf,pszSetupString);
  258.     return (fRet);
  259. }
  260.  
  261. //=Simple======================================================================
  262. //
  263. // CLASS:     WPSimple
  264. //
  265. // METHOD:    RefreshViews
  266. //
  267. // PARAMETER: <none>
  268. //
  269. // RETURN:    <none>
  270. //
  271. // DESCRIPT:  If any part of the instance data was changed, the views
  272. //            have to be updated.
  273. //
  274. //=============================================================================
  275. SOM_Scope VOID   SOMLINK RefreshViews(WPSimple *somSelf)
  276. {
  277.     PUSEITEM  pui;
  278.     PVIEWITEM pvi;
  279.  
  280.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  281.     WPSimpleMethodDebug("WPSimple","RefreshViews");
  282.  
  283.     //-------------------------------------------------------------------------
  284.     // Set the appropiate icon
  285.     //-------------------------------------------------------------------------
  286.        //-Simple---------------------------------------------------------------
  287.        if (_lIconState == ICOSTAT_DEFAULTICON1) {
  288.           _wpSetIcon (somSelf, _hptrDefault1);
  289.        } else if (_lIconState == ICOSTAT_DEFAULTICON2) {
  290.           _wpSetIcon (somSelf, _hptrDefault2);
  291.        } else if (_lIconState == ICOSTAT_DEFAULTICON3) {
  292.           _wpSetIcon (somSelf, _hptrDefault3);
  293.  
  294.        //-Settings Pages-------------------------------------------------------
  295.        } else if (_lIconState == ICOSTAT_ICONFILE) {
  296.           _SetIcon (somSelf, _szIconFile);
  297.        } else {
  298.        }
  299.  
  300.  
  301.     //-------------------------------------------------------------------------
  302.     // Find all open views
  303.     //-------------------------------------------------------------------------
  304.  
  305.     //-Settings Pages----------------------------------------------------------
  306.     if (NULLHANDLE != _hwndIconFileView) {
  307.        UpdateIconFileDlg (_hwndIconFileView, somSelf);
  308.     }
  309.  
  310.     //-Views-------------------------------------------------------------------
  311.     if (NULLHANDLE != _hwndInfoView) {
  312.        UpdateInfoView (_hwndInfoView, somSelf);
  313.     }
  314.  
  315. }
  316.  
  317. //#############################################################################
  318.  
  319. //=Save & Restore==============================================================
  320. //
  321. // CLASS:     WPSimple
  322. //
  323. // METHOD:    wpSaveState
  324. //
  325. // PARAMETER: see Programming Reference
  326. //
  327. // RETURN:    see Programming Reference
  328. //
  329. // DESCRIPT:  see Programming Reference
  330. //
  331. //=============================================================================
  332. SOM_Scope BOOL   SOMLINK wpSaveState(WPSimple *somSelf)
  333. {
  334.     BOOL fRet;
  335.  
  336.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  337.     WPSimpleMethodDebug("WPSimple","wpSaveState");
  338.  
  339.     //-Simple------------------------------------------------------------------
  340.     // Call parent first
  341.     //-------------------------------------------------------------------------
  342.     fRet = parent_wpSaveState(somSelf);
  343.  
  344.     //-------------------------------------------------------------------------
  345.     // We don't need to save _IconFileForUndo and _hptr*, but only the
  346.     // persistent part of the object state
  347.     //-------------------------------------------------------------------------
  348.  
  349.     //-Simple------------------------------------------------------------------
  350.     fRet &= _wpSaveLong   (somSelf, CLASS_NAME, PERSID_ICOSTAT,  _lIconState);
  351.  
  352.     //-Settings Pages----------------------------------------------------------
  353.     DebugBoxCond ("%08lx.Save: szIconFile = '%s'", somSelf, _szIconFile);
  354.     fRet &= _wpSaveString (somSelf, CLASS_NAME, PERSID_ICONFILE, _szIconFile);
  355.  
  356.     //-Pop-Up------------------------------------------------------------------
  357.     fRet &= _wpSaveLong   (somSelf, CLASS_NAME, PERSID_PLAYSTAT, _lPlayState);
  358.  
  359.     return (fRet);
  360. }
  361.  
  362. //=Save & Restore==============================================================
  363. //
  364. // CLASS:     WPSimple
  365. //
  366. // METHOD:    wpRestoreState
  367. //
  368. // PARAMETER: see Programming Reference
  369. //
  370. // RETURN:    see Programming Reference
  371. //
  372. // DESCRIPT:  see Programming Reference
  373. //
  374. //=============================================================================
  375. SOM_Scope BOOL   SOMLINK wpRestoreState(WPSimple *somSelf,
  376.                 ULONG ulReserved)
  377. {
  378.     BOOL fRet;
  379.     ULONG ulSize;
  380.  
  381.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  382.     WPSimpleMethodDebug("WPSimple","wpRestoreState");
  383.  
  384.     //-Simple------------------------------------------------------------------
  385.     // Call parent first
  386.     //-------------------------------------------------------------------------
  387.     fRet = parent_wpRestoreState(somSelf,ulReserved);
  388.  
  389.     //-------------------------------------------------------------------------
  390.     // Restore the persitent part of the object state
  391.     // (We don't need to restore _IconFileForUndo and _hptr*)
  392.     //-------------------------------------------------------------------------
  393.  
  394.     //-Simple------------------------------------------------------------------
  395.     fRet &= _wpRestoreLong   (somSelf, CLASS_NAME, PERSID_ICOSTAT,
  396.                               (PULONG)&_lIconState);
  397.  
  398.     //-Settings Pages----------------------------------------------------------
  399.     ulSize = CCHMAXPATH;
  400.     fRet &= _wpRestoreString (somSelf, CLASS_NAME, PERSID_ICONFILE,
  401.                               _szIconFile, &ulSize);
  402.     DebugBoxCond ("%08lx.Restored: szIconFile = '%s'", somSelf, _szIconFile);
  403.  
  404.     //-Pop-Up------------------------------------------------------------------
  405.     fRet &= _wpRestoreLong   (somSelf, CLASS_NAME, PERSID_PLAYSTAT,
  406.                               (PULONG)&_lPlayState);
  407.  
  408.     //-Simple------------------------------------------------------------------
  409.     // The instance data was changed!
  410.     //-------------------------------------------------------------------------
  411.     _RefreshViews (somSelf);
  412.  
  413.     return (fRet);
  414. }
  415.  
  416. //#############################################################################
  417.  
  418. //=Settings Pages==============================================================
  419. //
  420. // CLASS:     WPSimple
  421. //
  422. // METHOD:    wpAddSettingsPages
  423. //
  424. // PARAMETER: see Programming Reference
  425. //
  426. // RETURN:    see Programming Reference
  427. //
  428. // DESCRIPT:  see Programming Reference
  429. //
  430. //=============================================================================
  431. SOM_Scope BOOL   SOMLINK wpAddSettingsPages(WPSimple *somSelf,
  432.                 HWND hwndNotebook)
  433. {
  434.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  435.     WPSimpleMethodDebug("WPSimple","wpAddSettingsPages");
  436.  
  437.     //-Settings Pages----------------------------------------------------------
  438.     // Call parent first
  439.     // If this call is successful, call the own micro method
  440.     //-------------------------------------------------------------------------
  441.     return (parent_wpAddSettingsPages(somSelf,hwndNotebook) &&
  442.             _AddIconFilePage (somSelf, hwndNotebook));
  443. }
  444.  
  445. //=Settings Pages==============================================================
  446. //
  447. // CLASS:     WPSimple
  448. //
  449. // METHOD:    wpAddObjectGeneralPage
  450. //
  451. // PARAMETER: see Programming Reference
  452. //
  453. // RETURN:    see Programming Reference
  454. //
  455. // DESCRIPT:  see Programming Reference
  456. //
  457. //=============================================================================
  458. SOM_Scope ULONG   SOMLINK wpAddObjectGeneralPage(WPSimple *somSelf,
  459.                 HWND hwndNotebook)
  460. {
  461.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  462.     WPSimpleMethodDebug("WPSimple","wpAddObjectGeneralPage");
  463.  
  464.     //-Settings Pages----------------------------------------------------------
  465.     // Don't call the parent, since we want to remove this page
  466.     //-------------------------------------------------------------------------
  467. //    return (parent_wpAddObjectGeneralPage(somSelf,hwndNotebook));
  468.     return (SETTINGS_PAGE_REMOVED);
  469. }
  470.  
  471. //=Settings Pages==============================================================
  472. //
  473. // CLASS:     WPSimple
  474. //
  475. // METHOD:    AddIconFilePage
  476. //
  477. // PARAMETER: passed from wpAddSettingsPages
  478. //
  479. // RETURN:    BOOL fOK
  480. //
  481. // DESCRIPT:  Micro method to insert a new settings page
  482. //
  483. //=============================================================================
  484. SOM_Scope BOOL   SOMLINK AddIconFilePage(WPSimple *somSelf,
  485.                 HWND hwndNotebook)
  486. {
  487.     PAGEINFO pagei;
  488.  
  489.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  490.     WPSimpleMethodDebug("WPSimple","AddIconFilePage");
  491.  
  492.     //-Settings Pages----------------------------------------------------------
  493.     // Init the pageinfo struct
  494.     //-------------------------------------------------------------------------
  495.     pagei.cb                  = sizeof (PAGEINFO);     // ULONG
  496.     pagei.hwndPage            = 0;                     // HWND
  497.     pagei.pfnwp               = IconFileProc;          // PFNWP
  498.     pagei.resid               = get_hmod (_WPSimple);  // ULONG
  499.     pagei.dlgid               = DLG_ICONFILE;          // USHORT
  500.     pagei.pCreateParams       = somSelf;               // PVOID
  501.     pagei.usPageStyleFlags    = BKA_MAJOR;             // USHORT
  502.     pagei.usPageInsertFlags   = BKA_LAST;              // USHORT
  503.     pagei.ulPageInsertId      = 0;                     // ULONG
  504.     pagei.pszName             = "~Icon File";          // PSZ
  505.  
  506.     //-Settings Pages----------------------------------------------------------
  507.     // No help support
  508.     //-------------------------------------------------------------------------
  509.     pagei.idDefaultHelpPanel  = 0;                     // USHORT
  510.     pagei.pszHelpLibraryName  = 0;                     // PSZ
  511.     pagei.pHelpSubtable       = 0;                     // PUSHORT
  512.     pagei.hmodHelpSubtable    = 0;                     // HMODULE
  513.  
  514.     //-Settings Pages----------------------------------------------------------
  515.     // Must be  zero
  516.     //-------------------------------------------------------------------------
  517.     pagei.usReserved2         = 0;                     // USHORT
  518.  
  519.     //-Settings Pages----------------------------------------------------------
  520.     // Now insert the new settings page
  521.     //-------------------------------------------------------------------------
  522.     return _wpInsertSettingsPage (somSelf, hwndNotebook, &pagei);
  523. }
  524.  
  525. //=Settings Pages==============================================================
  526. //
  527. // CLASS:     WPSimple
  528. //
  529. // METHOD:    SetIcon
  530. //
  531. // PARAMETER: PSZ pszIconFile
  532. //
  533. // RETURN:    BOOL fOK
  534. //
  535. // DESCRIPT:  Loads and sets the icon stored in pszIconFile
  536. //
  537. //=============================================================================
  538. SOM_Scope BOOL   SOMLINK SetIcon(WPSimple *somSelf,
  539.                 PSZ pszIconFile)
  540. {
  541.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  542.     WPSimpleMethodDebug("WPSimple","SetIcon");
  543.  
  544.     //-Settings Pages----------------------------------------------------------
  545.     // Try to load the icon from the file
  546.     //-------------------------------------------------------------------------
  547.     _hptrIconFile = WinLoadFileIcon (pszIconFile, FALSE);
  548.     if (_hptrIconFile == NULLHANDLE) {
  549.        return (FALSE);
  550.     }
  551.  
  552.     //-Settings Pages----------------------------------------------------------
  553.     // Set the icon new icon
  554.     //-------------------------------------------------------------------------
  555.     _wpSetIcon (somSelf, _hptrIconFile);
  556.     return (TRUE);
  557. }
  558.  
  559. //#############################################################################
  560.  
  561. //=Pop-Up======================================================================
  562. //
  563. // CLASS:     WPSimple
  564. //
  565. // METHOD:    wpFilterPopupMenu
  566. //
  567. // PARAMETER: see Programming Reference
  568. //
  569. // RETURN:    see Programming Reference
  570. //
  571. // DESCRIPT:  see Programming Reference
  572. //
  573. //=============================================================================
  574. SOM_Scope ULONG   SOMLINK wpFilterPopupMenu(WPSimple *somSelf,
  575.                 ULONG ulFlags,
  576.                 HWND hwndCnr,
  577.                 BOOL fMultiSelect)
  578. {
  579.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  580.     WPSimpleMethodDebug("WPSimple","wpFilterPopupMenu");
  581.  
  582.     //-Pop-Up------------------------------------------------------------------
  583.     // Removing the MenuItem don't removes the capability of the object to be
  584.     // deleted
  585.     //-------------------------------------------------------------------------
  586.  //   ulFlags &= ~CTXT_DELETE;
  587.     return (parent_wpFilterPopupMenu(somSelf,ulFlags,hwndCnr,fMultiSelect));
  588. }
  589.  
  590. //=Pop-Up======================================================================
  591. //
  592. // CLASS:     WPSimple
  593. //
  594. // METHOD:    wpModifyPopupMenu
  595. //
  596. // PARAMETER: see Programming Reference
  597. //
  598. // RETURN:    see Programming Reference
  599. //
  600. // DESCRIPT:  see Programming Reference
  601. //
  602. //=============================================================================
  603. SOM_Scope BOOL   SOMLINK wpModifyPopupMenu(WPSimple *somSelf,
  604.                 HWND hwndMenu,
  605.                 HWND hwndCnr,
  606.                 ULONG iPosition)
  607. {
  608.     BOOL fRet;
  609.     MENUITEM mi;
  610.  
  611.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  612.     WPSimpleMethodDebug("WPSimple","wpModifyPopupMenu");
  613.  
  614.     //-Pop-Up------------------------------------------------------------------
  615.     // Call parent first
  616.     //-------------------------------------------------------------------------
  617.     fRet = parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition);
  618.  
  619.     //-Pop-Up------------------------------------------------------------------
  620.     // Put the stuff into the main pop-up menu
  621.     //-------------------------------------------------------------------------
  622.     fRet &= _wpInsertPopupMenuItems (somSelf,              //self
  623.                                      hwndMenu,             //hwndMenu
  624.                                      iPosition,            //ulPosition
  625.                                      get_hmod (_WPSimple), //hmod
  626.                                      MN_SIMPLE,            //ulMenuID
  627.                                      0);                   //ulSubMenuID
  628.  
  629.     //-Views-------------------------------------------------------------------
  630.     // Insert the new view menuitem to the open menu
  631.     //-------------------------------------------------------------------------
  632.     fRet &= _wpInsertPopupMenuItems (somSelf,              //self
  633.                                      hwndMenu,             //hwndMenu
  634.                                      0,                    //ulPosition
  635.                                      get_hmod (_WPSimple), //hmod
  636.                                      MN_OPEN,              //ulMenuID
  637.                                      WPMENUID_OPEN);       //ulSubMenuID
  638.  
  639.     //-Pop-Up------------------------------------------------------------------
  640.     // Ok, only if all pop-up items are successfully inserted
  641.     //-------------------------------------------------------------------------
  642.     return (fRet);
  643. }
  644.  
  645. //=Pop-Up======================================================================
  646. //
  647. // CLASS:     WPSimple
  648. //
  649. // METHOD:    wpMenuItemSelected
  650. //
  651. // PARAMETER: see Programming Reference
  652. //
  653. // RETURN:    see Programming Reference
  654. //
  655. // DESCRIPT:  see Programming Reference
  656. //
  657. //=============================================================================
  658. SOM_Scope BOOL   SOMLINK wpMenuItemSelected(WPSimple *somSelf,
  659.                 HWND hwndFrame,
  660.                 ULONG ulMenuId)
  661. {
  662.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  663.     WPSimpleMethodDebug("WPSimple","wpMenuItemSelected");
  664.  
  665.     //-Pop-Up------------------------------------------------------------------
  666.     // Which menu item is selected?
  667.     //-------------------------------------------------------------------------
  668.     switch (ulMenuId) {
  669.        //-Pop-Up---------------------------------------------------------------
  670.        // Set the icon state
  671.        //----------------------------------------------------------------------
  672.        case MN_DEFAULTICON: {
  673.           //-------------------------------------------------------------------
  674.           // Never called (This choice opens the pull down)
  675.           //-------------------------------------------------------------------
  676.           DebugBoxCond ("Selection: MN_DEFAULTICON");
  677.           break;
  678.        }
  679.        //-Pop-Up---------------------------------------------------------------
  680.        case MN_ICON1: {
  681.           DebugBoxCond ("Selection: MN_ICON1");
  682.           _lIconState = ICOSTAT_DEFAULTICON1;
  683.           _RefreshViews (somSelf);
  684.           break;
  685.        }
  686.        //-Pop-Up---------------------------------------------------------------
  687.        case MN_ICON2: {
  688.           DebugBoxCond ("Selection: MN_ICON2");
  689.           _lIconState = ICOSTAT_DEFAULTICON2;
  690.           _RefreshViews (somSelf);
  691.           break;
  692.        }
  693.        //-Pop-Up---------------------------------------------------------------
  694.        case MN_ICON3: {
  695.           DebugBoxCond ("Selection: MN_ICON3");
  696.           _lIconState = ICOSTAT_DEFAULTICON3;
  697.           _RefreshViews (somSelf);
  698.           break;
  699.        }
  700.        //-Views----------------------------------------------------------------
  701.        case MN_INFOVIEW: {
  702.           DebugBoxCond ("Selection: MN_VIEW");
  703.           //-------------------------------------------------------------------
  704.           // Open the new view
  705.           //-------------------------------------------------------------------
  706.           _wpOpen (somSelf, NULLHANDLE, MYOPEN_INFOVIEW, 0L);
  707.           break;
  708.        }
  709.        //-Pop-Up---------------------------------------------------------------
  710.        default: {
  711.           //-------------------------------------------------------------------
  712.           // Call the parent on all other menuitems
  713.           //-------------------------------------------------------------------
  714.           return (parent_wpMenuItemSelected(somSelf,hwndFrame,ulMenuId));
  715.        }
  716.     }
  717. }
  718.  
  719. //#############################################################################
  720.  
  721. //=Views=======================================================================
  722. //
  723. // CLASS:     WPSimple
  724. //
  725. // METHOD:    wpOpen
  726. //
  727. // PARAMETER: see Programming Reference
  728. //
  729. // RETURN:    see Programming Reference
  730. //
  731. // DESCRIPT:  see Programming Reference
  732. //
  733. //=============================================================================
  734. SOM_Scope HWND   SOMLINK wpOpen(WPSimple *somSelf,
  735.                 HWND hwndCnr,
  736.                 ULONG ulView,
  737.                 ULONG param)
  738. {
  739.     HWND       hwndFrame;
  740.     BOOL       fOK;
  741.     PVIEWITEM  pvi;
  742.     PUSEITEM   pui;
  743.     FRAMECDATA fcdata;
  744.     PARAMAAA   paramAAA;
  745.  
  746.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  747.     WPSimpleMethodDebug("WPSimple","wpOpen");
  748.  
  749.     //-Views-------------------------------------------------------------------
  750.     // Only if there is a request to open OUR view, we open ist
  751.     //-------------------------------------------------------------------------
  752.     if (ulView == MYOPEN_INFOVIEW) {
  753.        //-Views----------------------------------------------------------------
  754.        // If the view ist already open, we only have to redisplay the view
  755.        //----------------------------------------------------------------------
  756.        fOK = _wpSwitchTo (somSelf, ulView);
  757.        if (!fOK) {
  758.           //-Views-------------------------------------------------------------
  759.           // ... create the frame window, ...
  760.           //-------------------------------------------------------------------
  761.           InitInstanceaaa();
  762.           paramAAA.somSelf = somSelf;
  763.           paramAAA.somThis = somThis;
  764.           hwndFrame = CreateSOMView ((PVOID)¶mAAA);
  765.           WinShowWindow (hwndFrame, TRUE);
  766.           //-------------------------------------------------------------------
  767.           // Registration is done in the Gpf window 
  768.           //-------------------------------------------------------------------
  769.        }
  770.  
  771.        //-Views----------------------------------------------------------------
  772.        // It's done
  773.        //----------------------------------------------------------------------
  774.        return (hwndFrame);
  775.     }
  776.  
  777.     //-Views-------------------------------------------------------------------
  778.     // Call the parent for all other views
  779.     //-------------------------------------------------------------------------
  780.     return (parent_wpOpen(somSelf,hwndCnr,ulView,param));
  781. }
  782.  
  783. //#############################################################################
  784.  
  785.  
  786. //#############################################################################
  787. // END   Instance Methods (belong to the class)
  788. //#############################################################################
  789.  
  790. //#############################################################################
  791. // BEGIN Class Methods (belong to the metaclass)
  792. //#############################################################################
  793.  
  794. #undef SOM_CurrentClass
  795. #define SOM_CurrentClass SOMMeta
  796.  
  797. SOM_Scope MRESULT  SOMLINK wpDragOver(WPSimple *somSelf, HWND hwndCnr, 
  798.                                       PDRAGINFO pdrgInfo)
  799. {
  800.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  801.     WPSimpleMethodDebug("WPSimple","wpDragOver");
  802.  
  803.     return (WPSimple_parent_WPAbstract_wpDragOver(somSelf, hwndCnr, 
  804.                                                   pdrgInfo));
  805. }
  806.  
  807. SOM_Scope MRESULT  SOMLINK wpDrop(WPSimple *somSelf, HWND hwndCnr, 
  808.                                   PDRAGINFO pdrgInfo, PDRAGITEM pdrgItem)
  809. {
  810.     WPSimpleData *somThis = WPSimpleGetData(somSelf);
  811.     WPSimpleMethodDebug("WPSimple","wpDrop");
  812.  
  813.     return (WPSimple_parent_WPAbstract_wpDrop(somSelf, hwndCnr, 
  814.                                               pdrgInfo, pdrgItem));
  815. }
  816.  
  817. //=Init & Setup================================================================
  818. //
  819. // CLASS:     WPSimple
  820. //
  821. // METHOD:    wpclsQueryClassStyle
  822. //
  823. // PARAMETER: see Programming Reference
  824. //
  825. // RETURN:    see Programming Reference
  826. //
  827. // DESCRIPT:  see Programming Reference
  828. //            We don't want a template
  829. //
  830. //=============================================================================
  831. SOM_Scope ULONG   SOMLINK wpclswpclsQueryStyle(M_WPSimple *somSelf)
  832. {
  833.     M_WPSimpleData *somThis = M_WPSimpleGetData(somSelf);
  834.     M_WPSimpleMethodDebug("M_WPSimple","wpclswpclsQueryStyle");
  835.  
  836.     //-Simple------------------------------------------------------------------
  837.     // Deny the creation of the template
  838.     //-------------------------------------------------------------------------
  839.     return (parent_wpclsQueryStyle(somSelf) | CLSSTYLE_NEVERTEMPLATE);
  840. }
  841.  
  842. //=Init & Setup================================================================
  843. //
  844. // CLASS:     WPSimple
  845. //
  846. // METHOD:    wpclsInitData
  847. //
  848. // PARAMETER: see Programming Reference
  849. //
  850. // RETURN:    see Programming Reference
  851. //
  852. // DESCRIPT:  see Programming Reference
  853. //            All objects need the module handle, so we get it here.
  854. //
  855. //=============================================================================
  856. SOM_Scope void   SOMLINK wpclswpclsInitData(M_WPSimple *somSelf)
  857. {
  858.     APIRET  rc;
  859.  
  860.     M_WPSimpleData *somThis = M_WPSimpleGetData(somSelf);
  861.     M_WPSimpleMethodDebug("M_WPSimple","wpclswpclsInitData");
  862.  
  863.     //-Simple------------------------------------------------------------------
  864.     // Call parent first
  865.     //-------------------------------------------------------------------------
  866.     parent_wpclsInitData(somSelf);
  867.  
  868.     //-------------------------------------------------------------------------
  869.     // Some things should we do only once...
  870.     //-------------------------------------------------------------------------
  871.  
  872.     //-Simple------------------------------------------------------------------
  873.     rc = DosQueryModuleHandle (DLL_NAME, &_hmod);
  874.     if (NO_ERROR != rc) {
  875.        _hmod = NULLHANDLE;
  876.     }
  877.  
  878. }
  879.  
  880. //#############################################################################
  881. // END   Class Methods (belong to the metaclass)
  882. //#############################################################################
  883.  
  884. //#############################################################################
  885. // BEGIN Ordinary PM Stuff
  886. //#############################################################################
  887.  
  888. //=Settings Pages==============================================================
  889. //
  890. // PROCEDURE: UpdateIconFileDlg
  891. //
  892. // PARAMETER: HWND       hwnd     - handle of the icon file dialog
  893. //            WPSimple   somSelf  - handle of the object
  894. //
  895. // RETURN:    <none>
  896. //
  897. // DESCRIPT:  Change the displayed information in the icon file dialog,
  898. //            if the instance data is changed.
  899. //
  900. //=============================================================================
  901. VOID UpdateIconFileDlg (HWND hwnd, WPSimple *somSelf) {
  902.    WPSimpleData *somThis = WPSimpleGetData(somSelf);
  903.  
  904.    //-Settings Pages-----------------------------------------------------------
  905.    if (_lIconState == ICOSTAT_DEFAULTICON1) {
  906.       WinCheckButton (hwnd, RB_DEFAULTICON1, 1);
  907.       WinEnableControl (hwnd, EF_ICONFILE, FALSE);
  908.    //-Settings Pages-----------------------------------------------------------
  909.    } else if (_lIconState == ICOSTAT_DEFAULTICON2) {
  910.       WinCheckButton (hwnd, RB_DEFAULTICON2, 1);
  911.       WinEnableControl (hwnd, EF_ICONFILE, FALSE);
  912.    //-Settings Pages-----------------------------------------------------------
  913.    } else if (_lIconState == ICOSTAT_DEFAULTICON3) {
  914.       WinCheckButton (hwnd, RB_DEFAULTICON3, 1);
  915.       WinEnableControl (hwnd, EF_ICONFILE, FALSE);
  916.    //-Settings Pages-----------------------------------------------------------
  917.    } else if (_lIconState == ICOSTAT_ICONFILE) {
  918.       WinCheckButton (hwnd, RB_ICONFILE, 1);
  919.       WinEnableControl (hwnd, EF_ICONFILE, TRUE);
  920.    } else {
  921.    }
  922.    //-Settings Pages-----------------------------------------------------------
  923.    WinSetDlgItemText (hwnd, EF_ICONFILE, _szIconFile);
  924. }
  925.  
  926. //=Settings Pages==============================================================
  927. //
  928. // WINPROC:   IconFileProc
  929. //
  930. // DESCRIPT:  Dialog procedure for the icon file settings page
  931. //
  932. //=============================================================================
  933. MRESULT EXPENTRY IconFileProc (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2){
  934.    switch (ulMsg) {
  935.       //-Settings Pages--------------------------------------------------------
  936.       case WM_INITDLG: {
  937.          WPSimple *somSelf  = PVOIDFROMMP (mp2);
  938.          WPSimpleData *somThis = WPSimpleGetData(somSelf);
  939.  
  940.          //--------------------------------------------------------------------
  941.          // Store the self pointer for further use in the window words
  942.          //--------------------------------------------------------------------
  943.          WinSetWindowPtr (hwnd, QWL_USER, somSelf);
  944.  
  945.          //--------------------------------------------------------------------
  946.          // A new (part of a) view is now open and must be informed about
  947.          // changes of the instance data
  948.          //--------------------------------------------------------------------
  949.          _hwndIconFileView  = hwnd;
  950.  
  951.          //--------------------------------------------------------------------
  952.          // Perhaps the user presses the 'Undo'-button
  953.          //--------------------------------------------------------------------
  954.          _lIconStateForUndo = _lIconState;
  955.          strcpy (_szIconFileForUndo, _szIconFile);
  956.  
  957.          //--------------------------------------------------------------------
  958.          // The first notification for a control
  959.          //--------------------------------------------------------------------
  960.          _fFirstNotification = TRUE;
  961.  
  962.          //--------------------------------------------------------------------
  963.          // Delay the refresh of the view
  964.          //--------------------------------------------------------------------
  965.          WinPostMsg (hwnd, WM_SEM4, MPFROMP (NULL), MPFROMP (NULL));
  966.          break;
  967.       }
  968.  
  969.       //-----------------------------------------------------------------------
  970.       case WM_SEM4: {
  971.          WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
  972.          WPSimpleData *somThis = WPSimpleGetData(somSelf);
  973.  
  974.          //--------------------------------------------------------------------
  975.          // Now it's time to refresh the view
  976.          //--------------------------------------------------------------------
  977.          _RefreshViews (somSelf);
  978.          break;
  979.       }
  980.  
  981.       //-----------------------------------------------------------------------
  982.       case WM_COMMAND: {
  983.          USHORT usID = SHORT1FROMMP (mp1);
  984.          USHORT usSource = SHORT1FROMMP (mp2);
  985.  
  986.          //--------------------------------------------------------------------
  987.          // 'Undo'-button pressed?
  988.          //--------------------------------------------------------------------
  989.          if (usID == PB_UNDO && usSource == CMDSRC_PUSHBUTTON) {
  990.             WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
  991.             WPSimpleData *somThis = WPSimpleGetData(somSelf);
  992.  
  993.             //-----------------------------------------------------------------
  994.             // Restore the old information ...
  995.             //-----------------------------------------------------------------
  996.             _lIconState = _lIconStateForUndo;
  997.             strcpy (_szIconFile, _szIconFileForUndo);
  998.  
  999.             //-----------------------------------------------------------------
  1000.             // ... and force to redisplay it (in all views)
  1001.             //-----------------------------------------------------------------
  1002.             _RefreshViews (somSelf);
  1003.  
  1004.             return ((MRESULT)NULL);
  1005.          }
  1006.          break;
  1007.       }
  1008.  
  1009.       //-----------------------------------------------------------------------
  1010.       case WM_CONTROL: {
  1011.          USHORT usID = SHORT1FROMMP (mp1);
  1012.          USHORT usNotification = SHORT2FROMMP (mp1);
  1013.  
  1014.          //--------------------------------------------------------------------
  1015.          // Is some information changed by the user?
  1016.          //--------------------------------------------------------------------
  1017.          if ((usID == EF_ICONFILE     && usNotification == EN_KILLFOCUS)
  1018.           || (usID == RB_DEFAULTICON1 && usNotification == BN_CLICKED)
  1019.           || (usID == RB_DEFAULTICON2 && usNotification == BN_CLICKED)
  1020.           || (usID == RB_DEFAULTICON3 && usNotification == BN_CLICKED)
  1021.           || (usID == RB_ICONFILE     && usNotification == BN_CLICKED)) {
  1022.             WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
  1023.             WPSimpleData *somThis = WPSimpleGetData(somSelf);
  1024.  
  1025.             //-----------------------------------------------------------------
  1026.             // The first time it's a 'ghost' message from the system
  1027.             //-----------------------------------------------------------------
  1028.             if (_fFirstNotification) {
  1029.                _fFirstNotification = FALSE;
  1030.                break;
  1031.             }
  1032.  
  1033.             //-----------------------------------------------------------------
  1034.             // Read the changed information ...
  1035.             //-----------------------------------------------------------------
  1036.             WinQueryDlgItemText (hwnd, EF_ICONFILE, 256, _szIconFile);
  1037.             if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON1) == 1) {
  1038.                _lIconState = ICOSTAT_DEFAULTICON1;
  1039.             } else if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON2) == 1) {
  1040.                _lIconState = ICOSTAT_DEFAULTICON2;
  1041.             } else if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON3) == 1) {
  1042.                _lIconState = ICOSTAT_DEFAULTICON3;
  1043.             } else if (WinQueryButtonCheckstate (hwnd, RB_ICONFILE) == 1) {
  1044.                _lIconState = ICOSTAT_ICONFILE;
  1045.             } else {
  1046.             }
  1047.  
  1048.             //-----------------------------------------------------------------
  1049.             // ... and force to redisplay it (in all views)
  1050.             //-----------------------------------------------------------------
  1051.             _RefreshViews (somSelf);
  1052.          }
  1053.  
  1054.          break;
  1055.       }
  1056.  
  1057.       //-----------------------------------------------------------------------
  1058.       case WM_DESTROY: {
  1059.          WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
  1060.          WPSimpleData *somThis = WPSimpleGetData(somSelf);
  1061.  
  1062.          //--------------------------------------------------------------------
  1063.          // Make the user changes persistent
  1064.          //--------------------------------------------------------------------
  1065.          _wpSaveImmediate (somSelf);
  1066.  
  1067.          //--------------------------------------------------------------------
  1068.          // The (part of the) view is now closed
  1069.          //--------------------------------------------------------------------
  1070.          _hwndIconFileView = NULLHANDLE;
  1071.          break;
  1072.       }
  1073.    }
  1074.    return (WinDefDlgProc (hwnd, ulMsg, mp1, mp2));
  1075. }
  1076.  
  1077. //#############################################################################
  1078.  
  1079.  
  1080.  
  1081. //=View========================================================================
  1082. //
  1083. // PROCEDURE: UpdateInfoView
  1084. //
  1085. // PARAMETER: HWND       hwnd     - handle of the info view window
  1086. //            WPSimple   somSelf  - handle of the object
  1087. //
  1088. // DESCRIPT:  Change the displayed information in the info view,
  1089. //            if the instance data is changed.
  1090. //
  1091. //=============================================================================
  1092. VOID UpdateInfoView (HWND hwnd, WPSimple *somSelf) {
  1093.    CHAR szBuffer [100];
  1094.  
  1095.    WPSimpleData *somThis = WPSimpleGetData(somSelf);
  1096.  
  1097.    //--------------------------------------------------------------------------
  1098.    // Clear the list box
  1099.    //--------------------------------------------------------------------------
  1100.    WinSendMsg (_hwndListbox, LM_DELETEALL, MPFROMP (NULL), MPFROMP (NULL));
  1101.  
  1102.    //--------------------------------------------------------------------------
  1103.    // Enter the information line by line into the listbox
  1104.    //--------------------------------------------------------------------------
  1105.    sprintf (szBuffer, "IconState %d", _lIconState);
  1106.    WinSendMsg (_hwndListbox, LM_INSERTITEM,
  1107.                MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
  1108.  
  1109.    sprintf (szBuffer, "IconFile %s", _szIconFile);
  1110.    WinSendMsg (_hwndListbox, LM_INSERTITEM,
  1111.                MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
  1112.  
  1113.    sprintf (szBuffer, "IconFileForUndo %s", _szIconFileForUndo);
  1114.    WinSendMsg (_hwndListbox, LM_INSERTITEM,
  1115.                MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
  1116.  
  1117.    sprintf (szBuffer, "PlayState %d", _lPlayState);
  1118.    WinSendMsg (_hwndListbox, LM_INSERTITEM,
  1119.                MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
  1120.  
  1121.    sprintf (szBuffer, "PictureToDisplay %d", _lPictureToDisplay);
  1122.    WinSendMsg (_hwndListbox, LM_INSERTITEM,
  1123.                MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
  1124. }
  1125.  
  1126.  
  1127.  
  1128. //#############################################################################
  1129. // END   Ordinary PM Stuff
  1130. //#############################################################################
  1131.