home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnradv.zip / cnradv.H < prev    next >
C/C++ Source or Header  |  1993-07-19  |  13KB  |  269 lines

  1. /*********************************************************************
  2.  *                                                                   *
  3.  * MODULE NAME :  cnradv.h               AUTHOR:  Rick Fishman       *
  4.  * DATE WRITTEN:  11-30-92                                           *
  5.  *                                                                   *
  6.  * DESCRIPTION:                                                      *
  7.  *                                                                   *
  8.  *  Common definitions and function prototypes for CNRADV.EXE        *
  9.  *                                                                   *
  10.  * HISTORY:                                                          *
  11.  *                                                                   *
  12.  *  11-30-92 - Source copied from CNRMENU.EXE sample.                *
  13.  *             Added SelectionType submenu ids.                      *
  14.  *             Added new View submenu ids.                           *
  15.  *             Added fMiniIcons to INSTANCE structure.               *
  16.  *             Added ID_ICON_FOLDER definition for def folder icon.  *
  17.  *             Added global variable hptrFolder.                     *
  18.  *  12-05-92   Added drag.c function prototypes/definitions.         *
  19.  *             Added definition of ID_BMP_BACKGROUND.                *
  20.  *             Added pfnwpDefCnr to INSTANCE structure.              *
  21.  *             Added draw.c function prototypes/definitions.         *
  22.  *             Added Background submenu and item ids.                *
  23.  *             Added clrBackground to INSTANCE structure.            *
  24.  *             Added global variable hbmBackground.                  *
  25.  *             Added flCurrentView to INSTANCE structure.            *
  26.  *  01-01-93   Took out pszFileName and hptrIcon from CNRITEM -      *
  27.  *               will use the fields in the MINIRECORDCORE struct.   *
  28.  *             Added fTrue to satisfy new C Set/2++ compiler in      *
  29.  *               while( fTrue ) statements. The new compiler does    *
  30.  *               not allow while( TRUE ) or for( ; ; ) statements.   *
  31.  *  01-31-93   Added CCS_MINIICONS define per IBM.                   *
  32.  *  06-06-93   Added STYLES macro.                                   *
  33.  *             Added IDM_AUTOPOSITION to top-level menu.             *
  34.  *             Added IDM_ values for new TargetEmphasis submenu.     *
  35.  *             Added flTargetEmphasis to INSTANCE structure.         *
  36.  *  06-30-93   Added IDM_FILTERDIRS menu item id.                    *
  37.  *             Added fFilterDirs to INSTANCE structure.              *
  38.  *  07-06-93   Added pSavedDragInfo and cDragItems to INSTANCE.      *
  39.  *  07-19-93   Took out the global hptrFolder. It isn't needed as    *
  40.  *             OS/2 2.1 fixed the WinLoadFileIcon bug that didn't    *
  41.  *             use the folder icon for directories.                  *
  42.  *                                                                   *
  43.  *  Rick Fishman                                                     *
  44.  *  Code Blazers, Inc.                                               *
  45.  *  4113 Apricot                                                     *
  46.  *  Irvine, CA. 92720                                                *
  47.  *  CIS ID: 72251,750                                                *
  48.  *                                                                   *
  49.  *********************************************************************/
  50.  
  51. /*********************************************************************/
  52. /*------------------- APPLICATION DEFINITIONS -----------------------*/
  53. /*********************************************************************/
  54.  
  55. #define ID_FIRST_DIRWINDOW   1         // Id of first Directory frame window
  56.  
  57. #define ID_RESOURCES         1         // Id of frame wnd resources in .RC file
  58.  
  59. #define CNR_DIRECTORY        30        // The start of our show
  60.  
  61. #define ID_BMP_BACKGROUND    200       // Container background bitmap
  62.  
  63. #define ID_CONTEXT_MENU      1000      // Id of the context menu
  64. #define IDM_VIEW_SUBMENU     1100      // View Submenu id
  65. #define IDM_VIEW_ICON        1101      // View Submenu item ids
  66. #define IDM_VIEW_NAME        1102
  67. #define IDM_VIEW_NAMEFLOWED  1103
  68. #define IDM_VIEW_TREEICON    1104
  69. #define IDM_VIEW_TREENAME    1105
  70. #define IDM_VIEW_TREETEXT    1106
  71. #define IDM_VIEW_DETAILS     1107
  72. #define IDM_VIEW_TEXT        1108
  73. #define IDM_VIEW_TEXTFLOWED  1109
  74. #define IDM_VIEW_MINI        1110
  75. #define IDM_SORT_SUBMENU     1200      // Sort Submenu id
  76. #define IDM_SORT_NAME        1201      // Sort Submenu item ids
  77. #define IDM_SORT_DATETIME    1202
  78. #define IDM_SORT_DIRORDER    1203
  79. #define IDM_OTHERWIN_SUBMENU 1300      // "Other Window" Submenu
  80. #define IDM_OTHERWIN_ITEM1   1301      // ID of first "Other Window" menu item
  81. #define IDM_OTHERWIN_LASTITEM 1399     // ID of last "Other Window" menu item
  82. #define IDM_CREATE_NEWWIN    1400      // CreateNewWindow menu item
  83. #define IDM_ARRANGE          1500      // Arrange menu item
  84. #define IDM_SEL_TYPE         1600      // Selection Type submenu
  85. #define IDM_SEL_SINGLE       1601      // Selection type item ids
  86. #define IDM_SEL_EXTENDED     1602
  87. #define IDM_SEL_MULTIPLE     1603
  88. #define IDM_BKGD_TYPE        1700      // Background Type submenu
  89. #define IDM_BKGD_RED         1701      // Background type item ids
  90. #define IDM_BKGD_WHITE       1702
  91. #define IDM_BKGD_YELLOW      1703
  92. #define IDM_BKGD_BLUE        1704
  93. #define IDM_BKGD_GREY        1705
  94. #define IDM_BKGD_BITMAP      1706
  95. #define IDM_AUTOPOSITION     1800      // AutoPosition menu item
  96. #define IDM_TARGEMPH_SUBMENU 1900      // TargetEmphasis submenu
  97. #define IDM_TARGEMPH_DEF     1901      // TargetEmphasis item ids
  98. #define IDM_TARGEMPH_ORDERED 1902
  99. #define IDM_TARGEMPH_MIXED   1903
  100. #define IDM_FILTERDIRS       1950      // Filter directories menu item
  101.  
  102. #define ICON_COLUMN          1         // DetailsView column identifiers
  103. #define FILENAME_COLUMN      2         //   (these are placed in the
  104. #define FILESIZE_COLUMN      3         //    pUserData field of the FIELDINFO
  105. #define DATE_COLUMN          4         //    struct and are used by this
  106. #define TIME_COLUMN          5         //    application to identify which
  107. #define FILEATTR_COLUMN      6         //    column we are in during ownerdraw)
  108.  
  109. #define UM_CONTAINER_FILLED  WM_USER   // Posted by Fill thread to primary thrd
  110.  
  111. #define DEBUG_FILENAME       "cnradv.dbg"
  112.  
  113. #define DIRECTORY_WINCLASS   "CnrAdvancedSample"
  114.  
  115. #define PROGRAM_TITLE        "CNRADV"
  116.  
  117. #define HABERR( hab )        (ERRORIDERROR( WinGetLastError( hab ) ))
  118.  
  119. #define ANCHOR( hwnd )       (WinQueryAnchorBlock( hwnd ))
  120.  
  121. #define HWNDERR( hwnd )       \
  122.             (ERRORIDERROR( WinGetLastError( WinQueryAnchorBlock( hwnd ) ) ))
  123.  
  124. #define INSTDATA( hwnd )      (WinQueryWindowPtr( hwnd, 0 ))
  125.  
  126. #define PARENT( hwnd )        (WinQueryWindow( hwnd, QW_PARENT ))
  127.  
  128. #define OWNER( hwnd )         (WinQueryWindow( hwnd, QW_OWNER ))
  129.  
  130. #define GRANDPARENT( hwnd )   (WinQueryWindow( WinQueryWindow(hwnd, QW_PARENT)))
  131.  
  132. #define STYLES( hwnd )        (WinQueryWindowULong( hwnd, QWL_STYLE ))
  133.  
  134. #ifndef CRA_SOURCE            // As of 10/30/92, CRA_SOURCE not in toolkit hdrs
  135. #  define CRA_SOURCE          0x00004000L
  136. #endif
  137.  
  138. #ifndef CCS_MINIICONS         // As of 01/31/93, CCS_MINIICONS not in headers
  139. #  define CCS_MINIICONS       0x800
  140. #endif
  141.  
  142. /**********************************************************************/
  143. /*---------------------------- STRUCTURES ----------------------------*/
  144. /**********************************************************************/
  145.  
  146. typedef struct _CNRITEM               // CONTAINER RECORD STRUCTURE
  147. {
  148.   MINIRECORDCORE rc;                  // Base information
  149.   CDATE          date;                // Date of file
  150.   CTIME          time;                // Time of file
  151.   ULONG          cbFile;              // File size
  152.   ULONG          attrFile;            // Attributes of this file
  153.   INT            iDirPosition;        // Relative position in directory
  154.   BOOL           fSelected;           // Does this record have source emphasis
  155.   CHAR           szFileName[CCHMAXPATH + 1]; // File name
  156.  
  157. } CNRITEM, *PCNRITEM;
  158.  
  159. #define EXTRA_RECORD_BYTES (sizeof( CNRITEM ) - sizeof( MINIRECORDCORE ))
  160.  
  161.  
  162. typedef struct _INSTANCE              // CONTAINER'S CLIENT WINDOW INSTANCE DATA
  163. {
  164.     BOOL fShutdown;                     // Main thread wants to shut down
  165.     BOOL fContainerFilled;              // Fill thread has completed
  166.     PCNRITEM pciSelected;               // Item selected under context menu
  167.     BOOL fDirSelected;                  // One of the selected recs is a dir
  168.     BOOL fFilterDirs;                   // Are we filtering directories?
  169.     BOOL fMiniIcons;                    // Are we using mini icons?
  170.     PFNWP pfnwpDefCnr;                  // Default container window procedure
  171.     COLOR clrBackground;                // Cnr background color (0 for bitmap)
  172.     ULONG flCurrentView;                // Current major view type (CV_?)
  173.     ULONG flTargetEmphasis;             // CA_*TARGETEMPH selected by user
  174.     PDRAGINFO pSavedDragInfo;           // Saved for use by DM_ENDCONVERSATION
  175.     ULONG cDragItems;                   // Saved for use by DM_ENDCONVERSATION
  176.  
  177.     // Used to keep track of frame windows associated with OtherWindow menuitems
  178.     HWND hwndFrame[ IDM_OTHERWIN_LASTITEM - IDM_OTHERWIN_ITEM1 + 1 ];
  179.  
  180.     CHAR szCnrTitle[ CCHMAXPATH + 20 ]; // Container title
  181.     CHAR szDirectory[ CCHMAXPATH + 1 ]; // Directory being displayed
  182.     CHAR achWorkBuf[ CCHMAXPATH + 1 ];  // Instance work buffer
  183.  
  184. } INSTANCE, *PINSTANCE;
  185.  
  186.  
  187. typedef struct _THREADPARMS          // PARAMETERS TO PASS TO SECONDARY THREAD
  188. {
  189.     HWND hwndClient;                 // Client window handle
  190.     HWND hwndCnrShare;               // Container hwnd whose recs will be shared
  191.     PCNRITEM pciParent;              // Ptr to parent CNRITEM if using shr recs
  192.  
  193. } THREADPARMS, *PTHREADPARMS;
  194.  
  195.  
  196. typedef struct _WINCREATE            // PARAMETERS TO PASS TO WINDOW ON CREATION
  197. {
  198.     PSZ szDirectory;                 // Pointer to directory name
  199.     HWND hwndCnrShare;               // Container hwnd whose recs will be shared
  200.     PCNRITEM pciParent;              // Ptr to parent CNRITEM if using shr recs
  201.  
  202. } WINCREATE, *PWINCREATE;
  203.  
  204. /**********************************************************************/
  205. /*----------------------- FUNCTION PROTOTYPES ------------------------*/
  206. /**********************************************************************/
  207.  
  208. // In common.c
  209.  
  210. VOID SetWindowTitle( HWND hwndClient, PSZ szFormat, ... );
  211. VOID Msg( PSZ szFormat, ... );
  212. VOID FullyQualify( PSZ szDirectory, HWND hwndCnr, PCNRITEM pci );
  213.  
  214. // In create.c
  215.  
  216. HWND CreateDirectoryWin( PSZ szDirectory, HWND hwndCnr, PCNRITEM pciFirst );
  217. HWND CreateContainer( HWND hwndClient, PSZ szDirectory, HWND hwndCnrShare,
  218.                       PCNRITEM pciFirst );
  219.  
  220. // In populate.c
  221.  
  222. VOID PopulateContainer( PVOID pThreadParms );
  223.  
  224. // In ctxtmenu.c
  225.  
  226. VOID CtxtmenuCreate( HWND hwndClient, PCNRITEM pciSelected );
  227. VOID CtxtmenuCommand( HWND hwndClient, ULONG idCommand, ULONG ulCmdSrc );
  228. VOID CtxtmenuSetView( HWND hwndClient, ULONG ulViewType );
  229. VOID CtxtmenuEnd( HWND hwndClient );
  230.  
  231. // In edit.c
  232.  
  233. VOID EditBegin( HWND hwndClient, PCNREDITDATA pced );
  234. VOID EditEnd( HWND hwndClient, PCNREDITDATA pced );
  235.  
  236. // In sort.c
  237.  
  238. VOID SortContainer( HWND hwndClient, ULONG ulSortType );
  239.  
  240. // In drag.c
  241.  
  242. MRESULT DragMessage( HWND hwndClient, ULONG msg, MPARAM mp1, MPARAM mp2 );
  243. VOID    DragInit( HWND hwndClient, PCNRDRAGINIT pcdi );
  244. MRESULT DragOver( HWND hwndClient, PCNRDRAGINFO pcdi );
  245. VOID    DragDrop( HWND hwndClient, PCNRDRAGINFO pcdi );
  246.  
  247. // In draw.c
  248.  
  249. VOID    DrawSubclassCnr( HWND hwndClient );
  250. MRESULT DrawItem( HWND hwndClient, POWNERITEM poi );
  251.  
  252. /**********************************************************************/
  253. /*------------------------ GLOBAL VARIABLES --------------------------*/
  254. /**********************************************************************/
  255.  
  256. #ifdef GLOBALS_DEFINED
  257. #  define DATADEF
  258. #else
  259. #  define DATADEF extern
  260. #endif
  261.  
  262. DATADEF INT iWinCount;           // Number of directory windows created
  263. DATADEF HBITMAP hbmBackground;   // Bitmap to display on container background
  264. DATADEF BOOL fTrue;              // Used for while( fTrue ) to satisfy CSet2++
  265.  
  266. /***********************************************************************
  267.  *                   E N D     O F     S O U R C E                     *
  268.  **********************************************************************/
  269.