home *** CD-ROM | disk | FTP | other *** search
- /* ----------------------------------------------------------------------
-
- CNFTEST sample for Microsoft ActiveX Conferencing
-
- Unpublished work.
- Copyright (c) 1996, Microsoft Corporation
- All rights reserved.
-
- msg.c
-
- Main message handlers.
- ---------------------------------------------------------------------- */
-
- #include "main.h"
-
- // Main window message table definition.
- static MSD _rgmsdMain[] =
- {
- {WM_COMMAND, MsgCmdMain},
- {WM_NOTIFY, MsgNotify},
- {WM_CREATE, MsgCreate},
- {WM_DESTROY, MsgDestroy},
- {WM_CLOSE, MsgClose},
- {WM_SIZE, MsgSize},
- {WM_MENUSELECT, MsgMenuSelect},
- {WM_GETMINMAXINFO, MsgGetMinMax},
- {WM_DRAWITEM, MsgDrawItem},
-
- {0, (PFNMSG) DefWindowProc}
- };
-
-
- /* W N D P R O C */
- /*-------------------------------------------------------------------------
- %%Function: WndProc
-
- Main Window proc
- -------------------------------------------------------------------------*/
- LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
- {
- return DispatchMsg(_rgmsdMain, hwnd, uMsg, wparam, lparam);
- }
-
-
- /* M S G D E S T R O Y */
- /*-------------------------------------------------------------------------
- %%Function: MsgDestroy
-
- Handle a WM_DESTROY message
- -------------------------------------------------------------------------*/
- LRESULT MsgDestroy(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lParam)
- {
- PostQuitMessage(0);
- return 0;
- }
-
-
- /* M S G C R E A T E */
- /*----------------------------------------------------------------------------
- %%Function: MsgCreate
-
- ----------------------------------------------------------------------------*/
- LRESULT MsgCreate(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lParam)
- {
- return 0;
- }
-
-
-
- /* M S G C L O S E */
- /*-------------------------------------------------------------------------
- %%Function: MsgClose
-
- Handle a WM_CLOSE message
- -------------------------------------------------------------------------*/
- LRESULT MsgClose(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
- {
- WritePref();
- DestroyWindow(hwnd);
-
- if (ghInstDll != NULL)
- FreeLibrary(ghInstDll);
-
- return 0;
- }
-
- /* _ S I Z E S T A T U S */
- /*----------------------------------------------------------------------------
- %%Function: _SizeStatus
-
- ----------------------------------------------------------------------------*/
- VOID _SizeStatus(int dxClient, int dy)
- {
- int rgdxp[3];
-
- rgdxp[2] = dxClient;
- dxClient -= 100;
- rgdxp[1] = dxClient;
- dxClient -= 100;
- rgdxp[0] = dxClient;
- SendMessage(ghwndSbar, SB_SETPARTS, (WPARAM) 3, (LPARAM) rgdxp);
- }
-
- /* _ S I Z E M S G W I N D O W */
- /*----------------------------------------------------------------------------
- %%Function: _SizeMsgWindow
-
- ----------------------------------------------------------------------------*/
- VOID _SizeMsgWindow(int dx, int dy)
- {
- RECT rc;
- int xLeft;
- int yTop;
- int d;
-
- xLeft = 0;
- yTop = 3;
- dy -= 3;
-
- if (gPref.fSbar)
- {
- // adjust for status bar
- GetClientRect(ghwndSbar, &rc);
- d = (rc.bottom - rc.top);
- dy -= d;
- }
-
- MoveWindow(ghwndMsg, xLeft, yTop, dx, dy, fTrue);
- }
-
- /* R E C A L C M S G W I N D O W */
- /*----------------------------------------------------------------------------
- %%Function: RecalcMsgWindow
-
- ----------------------------------------------------------------------------*/
- VOID RecalcMsgWindow(void)
- {
- RECT rc;
-
- GetClientRect(ghwndMain, &rc);
- _SizeMsgWindow(rc.right, rc.bottom);
- }
-
-
- /* M S G S I Z E */
- /*-------------------------------------------------------------------------
- %%Function: MsgSize
-
- Handle a WM_SIZE message
- -------------------------------------------------------------------------*/
- LRESULT MsgSize(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
- {
- int dxClient = LOWORD(lparam); // width of client area
- int dyClient = HIWORD(lparam); // height of client area
-
- _SizeMsgWindow(dxClient, dyClient);
- _SizeStatus(dxClient, 0);
- SendMessage(ghwndSbar, uMsg, wparam, lparam);
-
- return 0;
- }
-
-
- /* M S G G E T M I N M A X */
- /*-------------------------------------------------------------------------
- %%Function: MsgGetMinMax
-
- Handle a WM_GETMINMAXINFO message
- -------------------------------------------------------------------------*/
- LRESULT MsgGetMinMax(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
- {
- LPMINMAXINFO lpminmax = (LPMINMAXINFO) lparam;
-
- if (gdxWndMin == 0 || gdyWndMin == 0)
- return 0;
-
- lpminmax->ptMinTrackSize.x = gdxWndMin;
- lpminmax->ptMinTrackSize.y = gdyWndMin;
-
- return 0;
- }
-
- /* M S G D R A W I T E M */
- /*----------------------------------------------------------------------------
- %%Function: MsgDrawItem
-
- ----------------------------------------------------------------------------*/
- LRESULT MsgDrawItem(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (wParam)
- {
- case IDW_MSG:
- {
- COLORREF cv;
-
- LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
- char sz[MAX_PATH];
-
- cv = SendMessage(ghwndMsg, LB_GETITEMDATA, (WPARAM)lpdi->itemID, (LPARAM)0);
- SetTextColor(lpdi->hDC, cv);
-
- SendMessage(ghwndMsg, LB_GETTEXT, (WPARAM)lpdi->itemID, (LPARAM)sz);
- DrawText( lpdi->hDC, sz, -1, &lpdi->rcItem, DT_LEFT | DT_SINGLELINE);
- }
- break;
- default:
- break;
- } /* switch */
-
- return 0;
- }
-