home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
CNRMNU.ZIP
/
CNRMENU.DOC
< prev
next >
Wrap
Text File
|
1993-03-27
|
6KB
|
122 lines
CNRMENU.EXE is a sample program for container controls that builds on the
CNRBASE.EXE sample program.
CNRBASE.EXE and its source code is downloadable from Compuserve (OS2DF1 forum,
PM section) as CNRBAS.ZIP. It is a sample program that demonstrates setting up
a container control and not much else.
CNRMENU takes CNRBASE a little further by demonstrating context menus, multiple
instances of CNRBASE' directory window, multiple container controls sharing
the same records, source emphasis, container sorting, and direct editing.
CNRMENU creates a standard window with a container as a child of the client
window. Once created, the files found in a directory are inserted into the
container and any subdirectories are traversed and inserted into the container
in a tree format. This directory can be specified on the command line (i.e.
'CNRMENU path'). If not specified it defaults to the current directory.
A secondary thread is employed to fill the container since filling it could
take a while depending on what directory was specified. This allows the user
to interact with the container while it is being filled.
The Directory window uses DosFindFirst/DosFindNext to get a directory listing
in order to populate the container. By using the context menu while over a
subdirectory's icon or doubleclicking on a subdirectory's icon you can create
another directory window that represents that subdirectory. When that window
is created, its container uses the records from the first one so it doesn't
need to do the FindFirst/FindNext. This is a capability of the container
control (shared records). It substantially reduces memory requirements in a
program that has multiple views of the same container or does something similar
to CNRMENU.
The context menu changes depending on whether the mouse pointer is over a
directory when the right mouse button is pressed.
This sample is not meant to demonstrate drag/drop, deltas, or ownerdraw. I do
plan on uploading a program that demonstrates these (by building on CNRMENU) at
a later date.
My coding style uses extensive error-checking. This, combined with the fact
that this program gets rather involved, makes this a relatively difficult
sample program to follow. I've tried to include as many comments as possible
but admittedly you still may have problems following it. Please get ahold of
me on Compuserve if you have questions.
CNRMENU.EXE is built from 7 source modules:
CNRMENU.C - base code and client window procedure
COMMON.C - functions common to all modules
CREATE.C - code related to creating the directory windows
CTXTMENU.C - code related to context menus
EDIT.C - code related to direct editing
POPULATE.C - code related to populating the containers (separate thread)
SORT.C - code related to container sorting
The following displays the initialization of the container as it relates to
the 4 source modules that make up CNRMENU.EXE initialization. The extern
functions in the source modules are shown.
PRIMARY THREAD SECONDARY THREAD
┌────────────────────┐ ┌─────────────────────────────┐
│ ┌────────┤ │ │
│ CNRMENU.C │ │ (4) │ POPULATE.C │
│ │ │ │ <─UM_CONTAINER_FILLED─────────── │
││ │ │ │WinProc │ │ │
││ │ │ │ │ │ ┌─> PopulateContainer() │
││ │ │ │ │ │ │ │
└│──│──│────┴────────┘ └──│──────────│───────────────┘
│ │ │ │ │
│ │ (1) │ │
│ │ │ │ │
│ (2) │ │ │
│ │ │ │ │
┌│──│──│────────────────────────┐ │ │
││ │ │ │ _beginthread() │
││ │ │ CREATE.C │ │ │
││ │ │ │ │ │
││ │ │ │ │ │
││ │ └─> CreateDirectoryWin() │ │ │
││ │ │ │ │
││ └─> CreateContainer() ────────────(3)────┘ │
││ │ │
└│──────────────────────│───────┘ │
│ │ │
│ ┌──│───────────────────────────────│───┐
│ │ v v │
│ │ │
│ │ COMMON.C │
└──────────────────────> │
│ │
│ SetWindowTitle() │
│ Msg() │
│ FullyQualify() │
│ │
└──────────────────────────────────────┘
(1) - Create the frame/client window.
(2) - Create the container window as a child of the client.
(3) - Start a thread that will fill the container with records.
(4) - When the thread has filled the container, it posts a UM_CONTAINER_FILLED
message to the client window.
Hope this sample program helps someone.
===============================================================================
GLOBAL HISTORY (KEPT SINCE 1/31/93 - Before that, kept on a per-module basis)
3-27-93 - Changed PSZ szArg[] to char *argv[] in cnrmenu.c because of 3/93
compiler bug.
===============================================================================
Rick Fishman
Code Blazers, Inc.
4113 Apricot
Irvine, CA 92720
CIS ID: 72251,750