home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / utils / wpprg / wpprgext.csc < prev    next >
Encoding:
Text File  |  1993-12-28  |  11.0 KB  |  381 lines

  1. /******************************************************************************
  2. *
  3. *  Module Name : WPPRGEXT
  4. *
  5. *  Description : OS/2 Workplace Shell WPProgram Object Extension.
  6. *                This extension adds the option to close the folder
  7. *                to which the launching program belongs.
  8. *
  9. *  Programmer  : Yong D. Lee
  10. *  Date        : Nov 21, 1993
  11. *
  12. *  Disclaimer of warranties:
  13. *      The code is provided "AS IS", without warranty of any kind.  I shall 
  14. *      not be liable for any damages arising out of your use of this code.
  15. *
  16. ******************************************************************************/
  17.  
  18. #******************************************************************************
  19. #   Include the class definition file for the parent class
  20. #******************************************************************************
  21.  
  22. include <wppgm.sc>
  23.  
  24. #******************************************************************************
  25. #   Define the new class
  26. #******************************************************************************
  27.  
  28. class: WPPrgExt,
  29.        external stem   = wpprgext,
  30.        local,
  31.        external prefix = wpprgext_,
  32.        classprefix     = wpprgextM_,
  33.        major version   = 1,
  34.        minor version   = 8;
  35.  
  36. --
  37. -- CLASS: WPPrgExt
  38. --
  39. -- DESCRIPTION:
  40. --
  41. --    This is a descendent object class for WPProgram object class. It can be
  42. --    replaced for WPProgram object class.
  43. --
  44.  
  45. #******************************************************************************
  46. #   Specify the parent class
  47. #******************************************************************************
  48.  
  49. parent: WPProgram;
  50.  
  51. #******************************************************************************
  52. #   Specify the release order of new methods.  
  53. #******************************************************************************
  54.  
  55. release order:
  56.               QueryFolderClose,
  57.               SetFolderClose,
  58.               AddFolderOptionPage,
  59.               AddFolderKeyPage,
  60.               FindKeyFromScancode,
  61.               FindScancodeFromKey,
  62.               clsQueryModuleHandle;
  63.  
  64. #******************************************************************************
  65. #   Passthru PRIVATE definitions to the .ph file
  66. #******************************************************************************
  67.  
  68. passthru: C.ph;
  69.  
  70.    /*
  71.     * Window data for the folder option dialog (settings page)
  72.     */
  73.    typedef struct _FOLDEROPTION
  74.    {
  75.       USHORT   cb;              /* size of this structure                   */
  76.       WPPrgExt *somSelf;        /* pointer to this instance                 */
  77.       ULONG    closeFolder;     /* indicates whether to close folder or not */
  78.    } FOLDEROPTION;
  79.  
  80.    typedef FOLDEROPTION *PFOLDEROPTION;
  81.  
  82.    /*
  83.     * Window data for the folder close key dialog (settings page)
  84.     */
  85.    typedef struct _FOLDERKEY
  86.    {
  87.       USHORT   cb;              /* size of this structure                   */
  88.       WPPrgExt *somSelf;        /* pointer to this instance                 */
  89.    } FOLDERKEY;
  90.  
  91.    typedef FOLDERKEY *PFOLDERKEY;
  92.  
  93. endpassthru;   /* C.ph */
  94.  
  95. #******************************************************************************
  96. #   Passthru IMPLEMENTATION definitions to the .ih file
  97. #******************************************************************************
  98.  
  99. passthru: C.ih;
  100.  
  101.    #define INCL_WIN
  102.    #define INCL_DOS
  103.    #define INCL_GPIBITMAPS
  104.    #include <os2.h>
  105.  
  106.    #define INCL_WPFOLDER
  107.    #define INCL_WINWORKPLACE
  108.    #define WPCLASS
  109.  
  110.    #include <pmwp.h>
  111.  
  112. /*
  113.  * IDs for string table
  114.  */
  115.    #define MAXKEY               13
  116.    #define ID_TITLE             100
  117.    #define IDSC_SHIFT           101
  118.    #define IDSC_F1              102
  119.    #define IDSC_F2              103
  120.    #define IDSC_F3              104
  121.    #define IDSC_F4              105
  122.    #define IDSC_F5              106
  123.    #define IDSC_F6              107
  124.    #define IDSC_F7              108
  125.    #define IDSC_F8              109
  126.    #define IDSC_F9              110
  127.    #define IDSC_F10             111
  128.    #define IDSC_F11             112
  129.    #define IDSC_F12             113
  130.  
  131. /*
  132.  * IDs of dialog items in WPPRGEXT.RC
  133.  */
  134.    #define IDD_FOLDER                  200
  135.    #define IDGROUP_FOLDERCLOSE         201
  136.    #define IDCHECK_CLOSENOTEBOOK       202
  137.    #define IDCHECK_CLOSEPROGRAM        203
  138.  
  139.    #define IDD_FOLDERKEY                300
  140.  
  141.    #define IDGROUP_KEYSELECTION         301
  142.    #define IDTEXT_LINE1                 302
  143.    #define IDTEXT_LINE2                 303
  144.    #define IDTEXT_LINE3                 304
  145.    #define IDTEXT_KEYSELECTION          305
  146.    #define IDCOMBO_KEYSELECTION         306
  147.  
  148.  
  149. /*
  150.  * IDs for folderClose
  151.  */
  152.    #define DONOTCLOSE           0x00
  153.    #define CLOSENOTEBOOK        0x01
  154.    #define CLOSEPROGRAM         0x02
  155.  
  156. /*
  157.  * Key for save-restore method
  158.  */
  159.     #define IDKEY_FOLDER 1
  160.  
  161. endpassthru;   /* .ih */
  162.  
  163. #******************************************************************************
  164. #   Passthru PUBLIC definitions to the .h file
  165. #******************************************************************************
  166.  
  167. passthru: C.h, after;
  168.  
  169.  
  170. endpassthru;   /* C.h */
  171.  
  172. #******************************************************************************
  173. #   Define instance data
  174. #******************************************************************************
  175.  
  176. data:
  177.  
  178.    ULONG folderClose;                     /* indicates if to close folder */
  179.  
  180. #******************************************************************************
  181. #   Define methods
  182. #******************************************************************************
  183.  
  184. methods:
  185.  
  186. ULONG QueryFolderClose();
  187. --
  188. -- METHOD: QueryFolderClose                               ( ) PRIVATE
  189. --                                                        (X) PUBLIC
  190. -- DESCRIPTION:
  191. --
  192. --   Query state of folder close flag
  193. --
  194. -- RETURN:
  195. --
  196. --   ULONG - folder closing option
  197. --
  198.  
  199. VOID SetFolderClose(ULONG flag);
  200. --
  201. -- METHOD: SetFolderClose                                 ( ) PRIVATE
  202. --                                                        (X) PUBLIC
  203. -- DESCRIPTION:
  204. --
  205. --   Set state of folder close flag
  206. --
  207. --
  208.  
  209. ULONG AddFolderOptionPage(HWND hwndNotebook);
  210. --
  211. -- METHOD: AddFolderOptionPage                            ( ) PRIVATE
  212. --                                                        (X) PUBLIC
  213. -- DESCRIPTION:
  214. --
  215. --   Add the folder page to the settings notebook
  216. --
  217. -- RETURN:
  218. --
  219. --   0              Unsuccessful
  220. --   ulPageId       Identifier for the inserted page
  221. --
  222.  
  223. ULONG AddFolderKeyPage(HWND hwndNotebook);
  224. --
  225. -- METHOD: AddFolderKeyPage                               ( ) PRIVATE
  226. --                                                        (X) PUBLIC
  227. -- DESCRIPTION:
  228. --
  229. --   Add the folder key selection page to the settings notebook
  230. --
  231. -- RETURN:
  232. --
  233. --   0              Unsuccessful
  234. --   ulPageId       Identifier for the inserted page
  235. --
  236.  
  237. VOID FindKeyFromScancode(LONG scanCode, CHAR *str);
  238. --
  239. -- METHOD: FindKeyFromScancode                            ( ) PRIVATE
  240. --                                                        (X) PUBLIC
  241. -- DESCRIPTION:
  242. --
  243. --   Find key name from scancode
  244. --
  245.  
  246. ULONG FindScancodeFromKey(CHAR *str);
  247. --
  248. -- METHOD: FindScancodeFromKey                            ( ) PRIVATE
  249. --                                                        (X) PUBLIC
  250. -- DESCRIPTION:
  251. --
  252. --   Find scancode from key name
  253. --
  254. -- RETURN:
  255. --
  256. --   key scancode
  257. --
  258.  
  259. #******************************************************************************
  260. #   Specify methods being overridden
  261. #******************************************************************************
  262.  
  263. -----------------------------------------------------------------------------
  264. --   Methods from the WPObject class
  265. -----------------------------------------------------------------------------
  266.  
  267. override wpInitData;
  268. --
  269. -- OVERRIDE: wpInitData                                   ( ) PRIVATE
  270. --                                                        (X) PUBLIC
  271. -- DESCRIPTION:
  272. --
  273. --   Initialize the state variables and allocate any extra memory
  274. --   that might be needed
  275. --
  276.  
  277. override wpUnInitData;
  278. --
  279. -- OVERRIDE: wpUnInitData                                 ( ) PRIVATE
  280. --                                                        (X) PUBLIC
  281. -- DESCRIPTION:
  282. --
  283. --   Clear up memory that was allocated on wpInitData
  284. --
  285.  
  286. override wpSaveState;
  287. --
  288. -- OVERRIDE: wpSaveState                                  ( ) PRIVATE
  289. --                                                        (X) PUBLIC
  290. -- DESCRIPTION:
  291. --
  292. --   Save state variable (folder close flag)
  293. --
  294.  
  295. override wpRestoreState;
  296. --
  297. -- OVERRIDE: wpRestoreState                               ( ) PRIVATE
  298. --                                                        (X) PUBLIC
  299. -- DESCRIPTION:
  300. --
  301. --   Restore saved state variable
  302. --
  303.  
  304. override wpAddSettingsPages;
  305. --
  306. -- OVERRIDE: wpAddSettingsPages                           ( ) PRIVATE
  307. --                                                        (X) PUBLIC
  308. -- DESCRIPTION:
  309. --
  310. --   Add folder settings page to let the user alter the flag
  311. --
  312.  
  313. override wpOpen;
  314. --
  315. --  METHOD: wpOpen                                        ( ) PRIVATE
  316. --                                                        (X) PUBLIC
  317. --  DESCRIPTION:
  318. --
  319. --    Opens the program object window. Close folder upon openning 
  320. --    according to folderClose flag
  321. --
  322.  
  323. override wpSetup;
  324. --
  325. -- OVERRIDE: wpSetup                                      ( ) PRIVATE
  326. --                                                        (X) PUBLIC
  327. -- DESCRIPTION:
  328. --
  329. --   Specift setup strings and do some initialization
  330. --
  331.  
  332. #******************************************************************************
  333. #   Define class methods
  334. #******************************************************************************
  335.  
  336. HMODULE clsQueryModuleHandle (), class;
  337. --
  338. -- METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  339. --                                                        (X) PUBLIC
  340. -- DESCRIPTION:
  341. --
  342. --   This method returns the module handle of this class.
  343. --
  344. -- RETURN:
  345. --
  346. --   0          Unsuccessful
  347. --   non-zero   Module handle
  348. --
  349.  
  350. #******************************************************************************
  351. #   Specify class methods being overridden
  352. #******************************************************************************
  353.  
  354. override wpclsInitData, class;
  355. --
  356. -- METHOD: wpclsInitData                                  ( ) PRIVATE
  357. --                                                        (X) PUBLIC
  358. -- DESCRIPTION:
  359. --
  360. --   Initialize the class data
  361. --
  362.  
  363. override wpclsUnInitData, class;
  364. --
  365. -- METHOD: wpclsUnInitData                                ( ) PRIVATE
  366. --                                                        (X) PUBLIC
  367. -- DESCRIPTION:
  368. --
  369. --   Free any class data
  370. --
  371.  
  372. override wpclsQueryTitle, class;
  373. --
  374. -- METHOD: wpclsQueryTitle                                ( ) PRIVATE
  375. --                                                        (X) PUBLIC
  376. -- DESCRIPTION:
  377. --
  378. --   Return the string "Extended Program".
  379. --
  380.  
  381.