home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
pendem.zip
/
BOOK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-21
|
121KB
|
3,277 lines
/* =========================================================================
* Sarka Martinez (407) 982- 5580, Pen Developer Magazine July/August '94 page 73
*
* Copyright.
*
* OCO Source Materials
*
* 5706-110 (C) Copyright IBM Corp. 1993
*
* ======================================================================== */
/* ======================================================================
* IBM CONFIDENTIAL
* ======================================================================
*
* product name.
*
* Filespec. BOOK.C
*
* Author. Sarka Martinez
*
* Date-Written. 05-04-1993
*
* Copyright. Copyright (C) IBM Corporation 1993
* LICENSED MATERIAL-PROGRAM PROPERTY OF IBM
*
* Change History.
*
* Rel Programmer Date Description
* ----- ------------- ------- --------------------------------
* 1.00 Sarka Martinez 050493 Demo Stage
*
* =================================================================== */
#define INCL_WIN // Window support
#define INCL_DOS // Dos Module Support
#define INCL_GPI // for drawing shadeing
#include <os2.h>
#include <string.h> // C-runtime String routines
#include <stdio.h> // C-Standard I/O functions
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <penpm.h>
#include <hwxentry.h>
#include "book.h"
HAB hab;
HWND hwndFrame, hwndClient, hwndNB, hwndIndex, hwndWelcome;
LONG Ypixel, Xpixel, WelcomeCardId, IndexCardId;
USHORT numRecs; // number of cards
CHAR *BookPath;
PFNWP NBSubProc, WelcomeSubProc[17], CardSubProc[14], TwoCardSubProc[28], IndexSubProc[7];
extern CARDINFO *Names;
// Main Routine
VOID main( int argc,char *argv[])
{
HMQ hmq; // Message Queue
QMSG qmsg;
ULONG flCreate1;
CHAR szFontName[20];
RECTL rectl;
BookPath = getenv("BOOK");
if (BookPath == NULL) {
DosBeep(500,100);
return;
}
hab = WinInitialize(0); // Initialize the Application
hmq = WinCreateMsgQueue(hab, 0); // Create a message Queue
WinRegisterClass(hab,"BookDemoSystem1", NoteBClientProc,
CS_SIZEREDRAW | CS_HITTEST, 0);
Ypixel = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
Xpixel = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
/* Create new standard window */
flCreate1 = (FCF_TITLEBAR | FCF_SYSMENU | FCF_MINBUTTON | FCF_ICON | FCF_TASKLIST | FCF_BORDER );
hwndFrame = (HWND)WinCreateStdWindow(HWND_DESKTOP,
WS_PARENTCLIP,
(PULONG)&flCreate1,
(PSZ)"BookDemoSystem1",
(PSZ)"Contact/2",
WS_CLIPCHILDREN,
(HMODULE)NULLHANDLE,
(ULONG)ID_BOOKWIN,
(PHWND)&hwndClient);
if (hwndFrame != NULLHANDLE) {
RedRegisterRecoCommand (ID_BOOK_EXE, ID_PENPM_BOOK, hwndClient);
// set the font for title bar
strcpy( szFontName, "10.Helv Bold Italic");
WinSetPresParam(hwndFrame, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
WinQueryWindowRect(hwndNB, &rectl);
WinSetWindowPos(hwndFrame, HWND_TOP, (SHORT)10, (SHORT)5,
(SHORT)rectl.xRight+14, (SHORT)rectl.yTop+33,
SWP_ACTIVATE | SWP_SIZE | SWP_MOVE | SWP_SHOW);
while ( WinGetMsg(hab,(PQMSG)&qmsg, (HWND)NULL,0,0))
WinDispatchMsg(hab, (PQMSG)&qmsg );
WinDestroyWindow(hwndFrame);
}
// Clean Up
WinDestroyMsgQueue(hmq); // Destroy the message Queue
WinTerminate(hab); // Terminate the Application
DosExit ( EXIT_PROCESS, 1L);
// return;
}
MRESULT APIENTRY NoteBClientProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
HPS hps;
RECTL rcl;
USHORT i;
static HBITMAP hbmp, hbmp1;
switch ( msg )
{
case WM_CREATE:
{
HWND hwndPage;
ULONG ulNBStyles, BCardId, indx=CLR_DARKRED;
SWP actCoords;
LONG letter='*', x=0;
BOOL NewIndex;
CHAR status_text[15];
CHAR strletter[2];
HPS hps;
POINTL points;
RECTL rectl;
ERRORID rc;
ulNBStyles = BKS_SPIRALBIND | BKS_POLYGONTABS | BKS_STATUSTEXTRIGHT;
hwndNB = WinCreateWindow(hwnd, WC_NOTEBOOK, (PSZ)NULL,
ulNBStyles, 5, 1, 470, 605, hwnd,
HWND_TOP, (USHORT)ID_BOOK, (PVOID)NULL,
(PVOID)NULL);
if (hwndNB == NULLHANDLE)
return (MRESULT) TRUE;
// subclass the note book so that you can see if any gesture were done
// on it...
NBSubProc = WinSubclassWindow(hwndNB, (PFNWP) NoteBookSubWndProc);
WinSendMsg (hwndNB, BKM_SETDIMENSIONS, MPFROM2SHORT(30,45),
MPFROMSHORT(BKA_MAJORTAB));
// Welcome Page
WelcomeCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)NULL,
MPFROM2SHORT(BKA_MAJOR, BKA_FIRST));
hwndWelcome = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)WelcomeDlgProc,
(HMODULE)NULLHANDLE, (ULONG)ID_WELCOME, 0L);
WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(WelcomeCardId),
MPFROMLONG(hwndWelcome));
// put the bitmap on the tab
hps = WinGetPS (hwndNB);
hbmp = GpiLoadBitmap(hps, (USHORT)NULL, IDB_WELCOME, 0L, 0L);
WinSendMsg(hwndNB, BKM_SETTABBITMAP, (MPARAM)WelcomeCardId, (MPARAM)hbmp);
WinReleasePS (hps);
BCardId = WelcomeCardId;
// set the size of the notebook relative to the size of the DLGs
// by doing this you do not have to calculate the diff sizes
// for all the diff resolutions...
WinQueryWindowRect(hwndWelcome, &rectl);
points.x = rectl.xRight+48;
points.y = rectl.yTop+3;
WinMapWindowPoints(hwndWelcome, HWND_DESKTOP, &points, (LONG)1);
WinSetWindowPos(hwndNB, NULLHANDLE, 0, 0,
points.x, points.y, SWP_SIZE | SWP_SHOW);
// set position of the welcome dlg
WinSetWindowPos(hwndWelcome, NULLHANDLE, (ULONG) 1, (ULONG) 1,
0, 0, SWP_MOVE);
// get Data Base ...
GetAllRecords(hwnd, &numRecs);
// look at entry, add page, and tab page each time you find a new last name
while (x < numRecs) {
// see if a new letter index tab is required
if ((Names[x].LName != NULL) && (Names[x].LName[0] != letter)) {
NewIndex = TRUE;
letter = Names[x].LName[0];
}
// add tab page and entries
if (NewIndex)
BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
MPFROM2SHORT(BKA_MAJOR | BKA_STATUSTEXTON, BKA_NEXT));
else
// add named entry
BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
MPFROM2SHORT(BKA_STATUSTEXTON, BKA_NEXT));
// 2 cards per page... & still on same letter of alphabet
if ((x+1 < MAXNAMES) && (Names[x+1].LName[0] == letter)) {
Names[x].CardId = BCardId;
Names[x+1].CardId = BCardId;
hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)TwoCardDlgProc,
(HMODULE)NULL, (ULONG)ID_BCARD2, (PVOID)&x);
rc = WinGetLastError(hab);
WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
MPFROMLONG(hwndPage));
x++;
} else { // only one card
Names[x].CardId = BCardId;
hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)CardDlgProc,
(HMODULE)NULL, (ULONG)ID_BCARD, &Names[x]);
WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
MPFROMLONG(hwndPage));
}
WinSetWindowPos(hwndPage, NULLHANDLE, (ULONG) 10, (ULONG) 10,
0, 0, SWP_MOVE);
if (NewIndex) {
sprintf(strletter, "%c", letter);
WinSendMsg(hwndNB, BKM_SETTABTEXT, (MPARAM)BCardId,
(MPARAM)strletter);
NewIndex=FALSE;
}
x++; // go to next name
//put info on staus line if more entries exsist under that letter
if ((Names[x].LName != NULL) && (Names[x].LName[0] == letter)) {
/* set the status line color to red */
WinSetPresParam(hwndNB, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
sprintf(status_text, "More %c's ... ", letter);
WinSendMsg(hwndNB, BKM_SETSTATUSLINETEXT, MPFROMP(BCardId),
MPFROMP(status_text));
}
} // end while
// Index Page
IndexCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)NULL,
MPFROM2SHORT(BKA_MAJOR, BKA_LAST));
hwndIndex = WinLoadDlg(hwndNB, NULLHANDLE, IndexDlgProc, (HMODULE)NULL, ID_INDEX, 0L);
WinSetWindowPos(hwndIndex, NULLHANDLE, (ULONG) 5, (ULONG) 1,
0, 0, SWP_MOVE);
WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(IndexCardId),
MPFROMLONG(hwndIndex));
// put the bitmap on the tab
hps = WinGetPS (hwndNB);
hbmp1 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_INDEX, 0L, 0L);
WinSendMsg(hwndNB, BKM_SETTABBITMAP, (MPARAM)IndexCardId, (MPARAM)hbmp1);
WinReleasePS (hps);
}
return (FALSE);
case WM_PAINT:
hps = WinBeginPaint (hwnd, (HPS)NULL, &rcl);
WinFillRect (hps, &rcl, (LONG)CLR_PALEGRAY);
WinEndPaint (hps);
return 0;
// look at gesture done ontop of the window
case WM_MY_RECO:
ProcessReco(mp1, mp2);
break;
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
case WM_COMMAND:
{
switch ( SHORT1FROMMP(mp1) )
{
default:
break;
}
}
case WM_CLOSE:
for (i=0; i < numRecs; i++) {
GpiDeleteBitmap(Names[i].hbmBitmap);
free(&Names[i]);
}
GpiDeleteBitmap(hbmp);
GpiDeleteBitmap(hbmp1);
return(WinDefWindowProc(hwnd, msg, mp1, mp2));
default:
return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) );
}
return(0L);
}
MRESULT EXPENTRY WelcomeDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
CHAR szFontName[13];
LONG indx = CLR_BLACK, i;
switch (message)
{
case WM_INITDLG:
// set the Gesture helps to black text
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set dialog box background to be white
indx = CLR_WHITE;
WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set the font
strcpy( szFontName, "10.Helv Bold");
WinSetPresParam( hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set the Gesture help text to Gray
indx = CLR_DARKGRAY;
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_PAGEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_MAILHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_ADDHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_REMOVEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_UPDATEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_HLPHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_VOICEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetPresParam( WinWindowFromID(hwnd, ID_GES_CLIPBHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// subclass all windows so that you can see if any gesture were done
// on it...
for (i = ID_IBMBMP; i <= ID_GES_HLPHLP_TXT; i++)
WelcomeSubProc[i-ID_IBMBMP] = WinSubclassWindow(WinWindowFromID(hwnd, i),
(PFNWP) NoteBookSubWndProc);
return (MRESULT)TRUE ;
// look at gesture done ontop of the window
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
break;
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDestroyWindow(hwnd);
return(WinDefWindowProc(hwnd, message, mp1, mp2));
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
MRESULT EXPENTRY CardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
CARDINFO *NameInfo;
CHAR *szFontName, *name, *Addr, *MailID;
LONG indx = CLR_BLACK, i;
switch (message)
{
case WM_INITDLG:
NameInfo = (CARDINFO *)mp2;
szFontName = (CHAR *)malloc(25);
name = (CHAR *)malloc(64);
MailID = (CHAR *)malloc(19);
Addr = (CHAR *)malloc(246);
// create a window word for this handle that carries the NameInfo struct
WinSetWindowULong(hwnd, 0, (ULONG) NameInfo);
// set to black text
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set dialog box background to be white
indx = CLR_WHITE;
WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// quickly change fonts on all text in this dlg
strcpy( szFontName, "8.Helv");
WinSetPresParam(hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
//show all info and update fonts for top part of card
strcpy( szFontName, "14.Tms Rmn Bold Italic");
WinSetPresParam( WinWindowFromID(hwnd, ID_NAME), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
if (NameInfo->Initial != NULL && NameInfo->Initial[0] != 0)
sprintf(name,"%s %s. %s", NameInfo->FName, NameInfo->Initial,
NameInfo->LName);
else
sprintf(name,"%s %s", NameInfo->FName, NameInfo->LName);
WinSetDlgItemText(hwnd, ID_NAME, name);
strcpy( szFontName, "10.Helv");
WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set company text to be blue
indx = CLR_DARKBLUE;
WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetDlgItemText(hwnd, ID_COMPANY, NameInfo->Company);
WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
WinSetDlgItemText(hwnd, ID_DEPT, NameInfo->Division);
WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
sprintf(Addr, "%s\n%s\n%s %s", NameInfo->StrAddr, NameInfo->City,
NameInfo->State, NameInfo->Zip);
WinSetDlgItemText(hwnd, ID_ADDR, Addr);
if (NameInfo->Phone != NULL && NameInfo->Phone[0] != 0)
WinSetDlgItemText(hwnd, ID_PHONE, NameInfo->Phone);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE), FALSE);
if (NameInfo->Fax != NULL && NameInfo->Fax[0] != 0)
WinSetDlgItemText(hwnd, ID_FAX, NameInfo->Fax);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX), FALSE);
if (NameInfo->PagerID != NULL && NameInfo->PagerID[0] != 0)
WinSetDlgItemText(hwnd, ID_PAGER, NameInfo->PagerID);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID), FALSE);
sprintf(MailID, "%s@%s", NameInfo->MailUserId, NameInfo->MailNodeId);
WinSetDlgItemText(hwnd, ID_MAILID, MailID);
// subclass all windows so that you can see if any gesture were done
// on it...
for (i = ID_LOGO; i <= ID_INF_PAGERID; i++)
CardSubProc[i-ID_LOGO] = WinSubclassWindow(WinWindowFromID(hwnd, i),
(PFNWP) NoteBookSubWndProc);
free(Addr);
free(MailID);
free(name);
free(szFontName);
return (MRESULT)TRUE ;
case WM_PAINT:
{
HPS hps;
RECTL rect;
CARDINFO *CInfo;
/* paint main(all of) dialog box */
hps = WinBeginPaint(hwnd, (HPS)NULL, NULL);
GpiErase(hps);
WinEndPaint(hps);
CInfo = (CARDINFO *) WinQueryWindowULong(hwnd, 0);
/* paint in the User Bitmap */
if (CInfo->hbmBitmap != NULLHANDLE) {
hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO), (HPS)NULL, NULL);
WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO), &rect);
WinDrawBitmap(hps, CInfo->hbmBitmap, NULL, (PPOINTL)&rect,
CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
WinEndPaint(hps);
}
hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM));
// paint the shadow around the card
WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM), &rect);
Paint3dLines(hps, &rect);
WinReleasePS(hps);
}
return 0;
// look at gesture done ontop of the window
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
break;
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case ID_SKETCHBTN:
{
CARDINFO *CInfo;
CInfo = (CARDINFO *) WinQueryWindowULong(hwnd, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
(HMODULE)NULL, ID_SKETCHPAD, CInfo);
}
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDestroyWindow(hwnd);
return(WinDefWindowProc(hwnd, message, mp1, mp2));
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
MRESULT EXPENTRY TwoCardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
LONG *indx, Index;
LONG clrindx = CLR_BLACK, i;
CHAR *szFontName, *name, *Addr, *MailID;
switch (message)
{
case WM_INITDLG:
indx = (LONG *)mp2;
Index = *indx;
szFontName = (CHAR *)malloc(25);
name = (CHAR *)malloc(64);
MailID = (CHAR *)malloc(19);
Addr = (CHAR *)malloc(246);
// create a window word for this handle that carries the NameInfo struct
WinSetWindowULong(hwnd, 0, (ULONG) Index);
// set to black text
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
// set dialog box background to be white
clrindx = CLR_WHITE;
WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
// quickly change fonts on all text in this dlg
strcpy( szFontName, "8.Helv");
WinSetPresParam(hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set up info and fonts
// top card
strcpy( szFontName, "14.Tms Rmn Bold Italic");
WinSetPresParam( WinWindowFromID(hwnd, ID_NAME2), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
if (Names[Index].Initial != NULL && Names[Index].Initial[0] != 0)
sprintf(name,"%s %s. %s", Names[Index].FName, Names[Index].Initial,
Names[Index].LName);
else
sprintf(name,"%s %s", Names[Index].FName, Names[Index].LName);
WinSetDlgItemText(hwnd, ID_NAME2, name);
strcpy( szFontName, "10.Helv");
WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY2), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set company text to be blue
clrindx = CLR_DARKBLUE;
WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY2), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
WinSetDlgItemText(hwnd, ID_COMPANY2, Names[Index].Company);
WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT2), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
WinSetDlgItemText(hwnd, ID_DEPT2, Names[Index].Division);
WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR2), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
sprintf(Addr, "%s\n%s\n%s %s", Names[Index].StrAddr, Names[Index].City,
Names[Index].State, Names[Index].Zip);
WinSetDlgItemText(hwnd, ID_ADDR2, Addr);
if (Names[Index].Phone != NULL && Names[Index].Phone[0] != 0)
WinSetDlgItemText(hwnd, ID_PHONE2, Names[Index].Phone);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE2), FALSE);
if (Names[Index].Fax != NULL && Names[Index].Fax[0] != 0)
WinSetDlgItemText(hwnd, ID_FAX2, Names[Index].Fax);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX2), FALSE);
if (Names[Index].PagerID != NULL && Names[Index].PagerID[0] != 0)
WinSetDlgItemText(hwnd, ID_PAGER2, Names[Index].PagerID);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID2), FALSE);
sprintf(MailID, "%s@%s", Names[Index].MailUserId, Names[Index].MailNodeId);
WinSetDlgItemText(hwnd, ID_MAILID2, MailID);
// now Load the BMP
// bottom Card
strcpy( szFontName, "14.Tms Rmn Bold Italic");
WinSetPresParam( WinWindowFromID(hwnd, ID_NAME1), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
if (Names[Index+1].Initial != NULL && Names[Index+1].Initial[0] != 0)
sprintf(name,"%s %s. %s", Names[Index+1].FName, Names[Index+1].Initial,
Names[Index+1].LName);
else
sprintf(name,"%s %s", Names[Index+1].FName, Names[Index+1].LName);
WinSetDlgItemText(hwnd, ID_NAME1, name);
strcpy( szFontName, "10.Helv");
WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY1), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set company text to be blue
clrindx = CLR_DARKBLUE;
WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY1), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
WinSetDlgItemText(hwnd, ID_COMPANY1, Names[Index+1].Company);
WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT1), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
WinSetDlgItemText(hwnd, ID_DEPT1, Names[Index+1].Division);
WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR1), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
sprintf(Addr, "%s\n%s\n%s %s", Names[Index+1].StrAddr, Names[Index+1].City,
Names[Index+1].State, Names[Index+1].Zip);
WinSetDlgItemText(hwnd, ID_ADDR1, Addr);
if (Names[Index+1].Phone != NULL && Names[Index+1].Phone[0] != 0)
WinSetDlgItemText(hwnd, ID_PHONE1, Names[Index+1].Phone);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE1), FALSE);
if (Names[Index+1].Fax != NULL && Names[Index+1].Fax[0] != 0)
WinSetDlgItemText(hwnd, ID_FAX1, Names[Index+1].Fax);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX1), FALSE);
if (Names[Index+1].PagerID != NULL && Names[Index+1].PagerID[0] != 0)
WinSetDlgItemText(hwnd, ID_PAGER1, Names[Index+1].PagerID);
else
WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID1), FALSE);
sprintf(MailID, "%s@%s", Names[Index+1].MailUserId, Names[Index+1].MailNodeId);
WinSetDlgItemText(hwnd, ID_MAILID1, MailID);
// subclass all windows so that you can see if any gestures were done
// on it...
for (i = ID_LOGO1; i <= ID_INF_PAGERID2; i++)
TwoCardSubProc[i-ID_LOGO1] = WinSubclassWindow(WinWindowFromID(hwnd, i),
(PFNWP) NoteBookSubWndProc);
free(szFontName);
free(name);
free(MailID);
free(Addr);
return (MRESULT)TRUE ;
case WM_PAINT:
{
HPS hps;
RECTL rect;
ULONG index;
/* paint main(all of) dialog box */
hps = WinBeginPaint(hwnd, (HPS)NULL, NULL);
GpiErase(hps);
WinEndPaint(hps);
index = (ULONG) WinQueryWindowULong(hwnd, 0);
/* paint in the User Bitmap */
if (Names[index].hbmBitmap != NULLHANDLE) {
hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO2), (HPS)NULL, NULL);
WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO2), &rect);
WinDrawBitmap(hps, Names[index].hbmBitmap, NULL, (PPOINTL)&rect,
CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
WinEndPaint(hps);
}
/* paint in the User Bitmap */
if (Names[index+1].hbmBitmap != NULLHANDLE) {
hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO1), (HPS)NULL, NULL);
WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO1), &rect);
WinDrawBitmap(hps, Names[index+1].hbmBitmap, NULL, (PPOINTL)&rect,
CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
WinEndPaint(hps);
}
hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM1));
// paint the shadows around the cards
WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM1), &rect);
Paint3dLines(hps, &rect);
WinReleasePS(hps);
hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM2));
WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM2), &rect);
Paint3dLines(hps, &rect);
WinReleasePS(hps);
}
return 0;
// look at gesture done ontop of the window
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
break;
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case ID_SKETCHBTN1:
{
ULONG index;
index = (ULONG) WinQueryWindowULong(hwnd, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
(HMODULE)NULL, ID_SKETCHPAD, (PVOID)&Names[index]);
}
break;
case ID_SKETCHBTN2:
{
ULONG index;
index = (ULONG) WinQueryWindowULong(hwnd, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
(HMODULE)NULL, ID_SKETCHPAD, (PVOID)&Names[index+1]);
}
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDestroyWindow(hwnd);
return(WinDefWindowProc(hwnd, message, mp1, mp2));
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
HBITMAP hbmp0000, hbmp0001, hbmp0010, hbmp0011, hbmp0100, hbmp0101, hbmp0110,
hbmp0111, hbmp1000, hbmp1001, hbmp1010, hbmp1011, hbmp1100, hbmp1101,
hbmp1110, hbmp1111;
MRESULT EXPENTRY IndexDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
LONG indx=CLR_WHITE;
CNRINFO ccinfo; /* Pointer to Container Control Info */
PFIELDINFO pFI;
CHAR szFontName[12];
POINTL points;
SHORT y, i;
HPS hps;
ULONG ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE;
static HWND hwndHWX;
static CHAR oldfilttxt[11];
switch (message)
{
case WM_INITDLG:
// hide the text string in the Filter group box til someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), FALSE);
// hide the Ok pushbutton in the Filter group box til someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), FALSE);
// set to black text
indx = CLR_BLACK;
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set the font for the container
strcpy( szFontName, "10.Helv");
WinSetPresParam( WinWindowFromID(hwnd, ID_CONTAINER), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set the font for the rest of the dialog box
strcpy( szFontName, "10.Helv");
WinSetPresParam(hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set up the container
pFI = AllocIndexFields(WinWindowFromID(hwnd, ID_CONTAINER));
ccinfo.pFieldInfoLast = pFI;
ccinfo.cb = sizeof(CNRINFO); /* structure size */
ccinfo.xVertSplitbar = 93;
ccinfo.cFields = 4;
ccinfo.flWindowAttr = CV_DETAIL | CA_DRAWBITMAP;
ccinfo.slBitmapOrIcon.cx = 75;
ccinfo.slBitmapOrIcon.cy = 20;
ccinfo.cyLineSpacing = 7;
WinSendMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_SETCNRINFO,
MPFROMP(&ccinfo),
MPFROMLONG(CMA_SLBITMAPORICON | CMA_FLWINDOWATTR | CMA_LINESPACING |
CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR));
// subclass all windows so that you can see if any gesture were done
// on it...
for (i = ID_CONTAINER; i <= ID_FILT_OK; i++)
IndexSubProc[i-ID_CONTAINER] = WinSubclassWindow(WinWindowFromID(hwnd, i),
(PFNWP) NoteBookSubWndProc);
oldfilttxt[0] = '\0';
return (MRESULT)TRUE ;
// look at gesture done ontop of the window
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
// double clicked on a name, now open to that page
case CN_ENTER:
{
PNOTIFYRECORDENTER pRecordinfo;
CARDREC *pCardRec;
pRecordinfo = (PNOTIFYRECORDENTER)mp2;
// look past recordinfo to get the user data...
pCardRec = (CARDREC *)pRecordinfo->pRecord;
// turn to the page
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(pCardRec->CardId), 0L);
}
break;
case HXN_CONTENTS_CHANGED:
{
CHAR filttxt[11];
WinQueryWindowText(hwndHWX, sizeof(filttxt), filttxt);
// now cause the container to filter out the items that don't match
// get all items from list, and set filtered attribute on any that
// dont match what was hand written...
if ((filttxt != NULL) && (filttxt[0] != 0)) {
// if user wrote over a letter that was reco'd earlier, unfilter it.
if (strlen(oldfilttxt) == strlen(filttxt)) {
if (strcmp(oldfilttxt, filttxt) != 0)
WinSendMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
}
strcpy(oldfilttxt, filttxt);
if (LOUSHORT(mp1) == ID_HWX_NAME)
WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
MPFROMP(pfnfilterName), filttxt);
else if (LOUSHORT(mp1) == ID_HWX_COMP)
WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
MPFROMP(pfnfilterComp), filttxt);
else
WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
MPFROMP(pfnfilterState), filttxt);
}
else
// unfilter the list
WinPostMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
}
break;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case ID_FILT_NAME:
{
SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
// make sure the user does not hit the button again
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
WinSetDlgItemText(hwnd, ID_FILT_TEXT, "Name:");
points.y = 157;
points.x = 10;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 9;
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_NAME,
NULL, NULL );
// show the text string in the Filter group box cause someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
// show the Ok pushbutton in the Filter group box cause someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
}
break;
case ID_FILT_COMP:
{
SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
// make sure the user does not hit the button again
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
WinSetDlgItemText(hwnd, ID_FILT_TEXT, "Company:");
points.y = 157;
points.x = 10;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 9;
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_COMP,
NULL, NULL );
// show the text string in the Filter group box cause someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
// show the Ok pushbutton in the Filter group box cause someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
}
break;
case ID_FILT_STATE:
{
SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
// make sure the user does not hit the button again
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
WinSetDlgItemText(hwnd, ID_FILT_TEXT, "State:");
points.y = 157;
points.x = 8;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 2;
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_STATE,
NULL, NULL );
// show the text string in the Filter group box til someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
// show the Ok pushbutton in the Filter group box cause someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
}
break;
case ID_FILT_OK:
// hide the text string in the Filter group box til someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), FALSE);
// hide the Ok pushbutton in the Filter group box til someone wants to filter
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),TRUE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),TRUE);
WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),TRUE);
// unfilter the list
WinPostMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
WinDestroyWindow(hwndHWX);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
// FYI: WM_CLOSE is not being called when the notebook is closed
case WM_CLOSE:
GpiDeleteBitmap(hbmp0000);
GpiDeleteBitmap(hbmp0001);
GpiDeleteBitmap(hbmp0010);
GpiDeleteBitmap(hbmp0011);
GpiDeleteBitmap(hbmp0100);
GpiDeleteBitmap(hbmp0110);
GpiDeleteBitmap(hbmp0101);
GpiDeleteBitmap(hbmp0111);
GpiDeleteBitmap(hbmp1100);
GpiDeleteBitmap(hbmp1101);
GpiDeleteBitmap(hbmp1110);
GpiDeleteBitmap(hbmp1111);
GpiDeleteBitmap(hbmp1000);
GpiDeleteBitmap(hbmp1001);
GpiDeleteBitmap(hbmp1010);
GpiDeleteBitmap(hbmp1011);
return(WinDefDlgProc(hwnd,message,mp1,mp2));
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
PFIELDINFO AllocIndexFields (HWND hwndCnr)
{
PFIELDINFO pFieldInfo, FirstFI, SplitbarFI;
ULONG NumFIs, Index=0;
FIELDINFOINSERT FieldInfoInsert;
CHAR Name[64];
CARDREC *pCardRec;
PRECORDCORE publicRecord;
RECORDINSERT RecordInsert;
HPS hps;
if (numRecs > 0) {
hps = WinGetPS (hwndCnr);
hbmp0000 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0000, 0L, 0L);
hbmp0001 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0001, 0L, 0L);
hbmp0010 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0010, 0L, 0L);
hbmp0011 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0011, 0L, 0L);
hbmp0100 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0100, 0L, 0L);
hbmp0101 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0101, 0L, 0L);
hbmp0110 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0110, 0L, 0L);
hbmp0111 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0111, 0L, 0L);
hbmp1000 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1000, 0L, 0L);
hbmp1001 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1001, 0L, 0L);
hbmp1010 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1010, 0L, 0L);
hbmp1011 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1011, 0L, 0L);
hbmp1100 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1100, 0L, 0L);
hbmp1101 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1101, 0L, 0L);
hbmp1110 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1110, 0L, 0L);
hbmp1111 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1111, 0L, 0L);
WinReleasePS (hps);
while (Index < numRecs) {
// allocate space for user info
pCardRec = (CARDREC *)WinSendMsg(hwndCnr, CM_ALLOCRECORD,
MPFROMLONG(sizeof(CARDREC)-sizeof(RECORDCORE)),
MPFROMSHORT(1));
// need to add an extra space at the end of the following strings
// this is beacuse the width of a column is calculated incorrectly when
// using the Helvetica 10 font.
if (Names[Index].Initial != NULL && Names[Index].Initial[0] != 0)
sprintf(Name,"%s, %s %s. ", Names[Index].LName, Names[Index].FName,
Names[Index].Initial);
else
sprintf(Name,"%s, %s ", Names[Index].LName, Names[Index].FName);
pCardRec->name = malloc(65);
strcpy(pCardRec->name, Name);
pCardRec->company = malloc(102);
sprintf(pCardRec->company, "%s ", Names[Index].Company);
pCardRec->state = malloc(4);
sprintf(pCardRec->state, "%s ", Names[Index].State);
pCardRec->CardId = Names[Index].CardId;
FindBmp(&Names[Index], pCardRec);
publicRecord = (PRECORDCORE)pCardRec;
publicRecord->cb = sizeof(RECORDCORE); /* structure size */
RecordInsert.pRecordOrder = (PRECORDCORE)CMA_END;
RecordInsert.zOrder = (USHORT)CMA_TOP;
RecordInsert.cRecordsInsert = (USHORT)1;
RecordInsert.fInvalidateRecord = TRUE;
RecordInsert.cb = sizeof(RECORDINSERT);
RecordInsert.pRecordParent = NULL;
WinSendMsg (hwndCnr,
CM_INSERTRECORD,
MPFROMP(publicRecord),
MPFROMP(&RecordInsert));
Index++;
}
// 1 bmp, name, company, state
pFieldInfo = (PFIELDINFO)WinSendMsg (hwndCnr,
CM_ALLOCDETAILFIELDINFO,
MPFROMSHORT(4),
NULL);
FirstFI = pFieldInfo;
// set up the columns for details view
pFieldInfo->flData = CFA_BITMAPORICON | CFA_TOP | CFA_CENTER;
pFieldInfo->offStruct = FIELDOFFSET(CARDREC, bitmap);
pFieldInfo->cb = sizeof(FIELDINFO); /* size of structure */
pFieldInfo = pFieldInfo->pNextFieldInfo;
pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT);
pFieldInfo->pUserData = pCardRec;
pFieldInfo->offStruct = FIELDOFFSET(CARDREC, name);
pFieldInfo->cb = sizeof(FIELDINFO); /* size of structure */
pFieldInfo = pFieldInfo->pNextFieldInfo;
pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT | CFA_SEPARATOR );
pFieldInfo->pUserData = pCardRec;
pFieldInfo->offStruct = FIELDOFFSET(CARDREC, company);
pFieldInfo->cb = sizeof(FIELDINFO); /* size of structure */
pFieldInfo = pFieldInfo->pNextFieldInfo;
pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT);
pFieldInfo->pUserData = pCardRec;
pFieldInfo->offStruct = FIELDOFFSET(CARDREC, state);
pFieldInfo->cb = sizeof(FIELDINFO); /* size of structure */
/**********************************************/
/* Insert the FieldInfo's into the container. */
/**********************************************/
FieldInfoInsert.pFieldInfoOrder = (PFIELDINFO)CMA_END;
FieldInfoInsert.cFieldInfoInsert = (USHORT)4;
FieldInfoInsert.cb = sizeof(FIELDINFOINSERT);
FieldInfoInsert.fInvalidateFieldInfo = TRUE;
NumFIs = (ULONG)WinSendMsg (hwndCnr,
CM_INSERTDETAILFIELDINFO,
MPFROMP(FirstFI),
MPFROMP(&FieldInfoInsert));
return (FirstFI);
}
return (NULL);
}
// used to filter the index list by name
BOOL EXPENTRY pfnfilterName(PRECORDCORE p, PVOID pStorage)
{
CARDREC *pCardRec;
USHORT i=0, j=0, tot;
CHAR *txt, test, targetchar;
pCardRec = (CARDREC *)p;
txt = (CHAR *)pStorage;
tot = strlen(txt);
while (i < tot) {
if (txt[i] == ',') {
// get to the comma
while ((pCardRec->name[j] != '\0') && (pCardRec->name[j] != ',')) {
j++;
}
if (pCardRec->name[j] == '\0')
return TRUE;
j++; // get past the comma
i++; // get past the comma
continue; // skip this one, commas
}
if (txt[i] == ' ') {
i++;
continue; // skip blanks
}
if (pCardRec->name[j] == ' ') {
j++;
continue; // skip blanks
}
// need to be case insenstitive
test = tolower(txt[i]);
targetchar = tolower(pCardRec->name[j]);
if (test != targetchar)
return FALSE; // failed the test, throw it out
else {
j++;
i++;
}
}
return TRUE; // passed all tests, keep it
}
// used to filter the index list by company
BOOL EXPENTRY pfnfilterComp(PRECORDCORE p, PVOID pStorage)
{
CARDREC *pCardRec;
USHORT i=0, j=0, tot;
CHAR *txt, test, targetchar;
pCardRec = (CARDREC *)p;
txt = (CHAR *)pStorage;
tot = strlen(txt);
while (i < tot) {
if (txt[i] == ' ') {
i++;
continue; // skip blanks
}
if (pCardRec->company[j] == ' ') {
j++;
continue; // skip blanks
}
// need to be case insenstitive
test = tolower(txt[i]);
targetchar = tolower(pCardRec->company[j]);
if (test != targetchar)
return FALSE; // failed the test, throw it out
else {
j++;
i++;
}
}
return TRUE; // passed all tests, keep it
}
// used to filter the index list by state
BOOL EXPENTRY pfnfilterState(PRECORDCORE p, PVOID pStorage)
{
CARDREC *pCardRec;
USHORT i=0, j=0, tot;
CHAR *txt, test, targetchar;
pCardRec = (CARDREC *)p;
txt = (CHAR *)pStorage;
tot = strlen(txt);
while (i < tot) {
if (txt[i] == ' ') {
i++;
continue; // skip blanks
}
if (pCardRec->state[j] == ' ') {
j++;
continue; // skip blanks
}
// need to be case insenstitive
test = tolower(txt[i]);
targetchar = tolower(pCardRec->state[j]);
if (test != targetchar)
return FALSE; // failed the test, throw it out
else {
j++;
i++;
}
}
return TRUE; // passed all tests, keep it
}
MRESULT EXPENTRY EditBCardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
CHAR szFontName[13], bmp_file[16], MailID[19], Addr[70], name[32];
LONG indx = CLR_BLACK;
POINTL points;
SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX, ID;
USHORT bmp_length=0;
INT hf;
ULONG ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE, Index;
HWND hwndDlg, hwndHWX;
static HWND hwnd2;
static CARDINFO *CardInfo=NULL;
switch (message)
{
case WM_INITDLG:
// set the to black text
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set the font
strcpy( szFontName, "10.Helv");
WinSetPresParam( hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set the font
strcpy( szFontName, "8.Helv");
WinSetPresParam(WinWindowFromID(hwnd, ID_MORE), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// create hwnadwriting controls
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
// x and y pos from dlg coords to win coords
points.x = 45;
points.y = 207;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 10;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_FNAME, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 45;
points.y = 187;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 10;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_LNAME, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 45;
points.y = 167;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 1;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_INIT, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 45;
points.y = 127;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_DIV, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 45;
points.y = 147;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_COMP, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 25;
points.y = 87;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (2*(CharBoxDY + BaseLineDY)) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_STREET, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 25;
points.y = 67;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_CITY, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 25;
points.y = 47;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 2;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_STATE, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 25;
points.y = 27;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 10;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_ZIP, NULL, NULL );
// if empty then its an update
if (mp2 != 0L) {
CardInfo = (CARDINFO *)mp2;
// show the info already stored
WinSetDlgItemText(hwnd, ID_HWX_FNAME, CardInfo->FName);
WinSetDlgItemText(hwnd, ID_HWX_LNAME, CardInfo->LName);
WinSetDlgItemText(hwnd, ID_HWX_INIT, CardInfo->Initial);
WinSetDlgItemText(hwnd, ID_HWX_COMP, CardInfo->Company);
WinSetDlgItemText(hwnd, ID_HWX_DIV, CardInfo->Division);
WinSetDlgItemText(hwnd, ID_HWX_STREET, CardInfo->StrAddr);
WinSetDlgItemText(hwnd, ID_HWX_CITY, CardInfo->City);
WinSetDlgItemText(hwnd, ID_HWX_ZIP, CardInfo->Zip);
WinSetDlgItemText(hwnd, ID_HWX_STATE, CardInfo->State);
// create page2
hwnd2 = WinLoadDlg(HWND_DESKTOP, hwnd, (PFNWP)EditBCard2DlgProc, (HMODULE)NULL, ID_BEDIT2, CardInfo);
}
else
// create page2
hwnd2 = WinLoadDlg(HWND_DESKTOP, hwnd, (PFNWP)EditBCard2DlgProc, (HMODULE)NULL, ID_BEDIT2, 0L);
WinSetFocus(HWND_DESKTOP, hwnd);
return (MRESULT)TRUE ;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case ID_MORE:
WinSetWindowPos(hwnd, HWND_TOP, 0, 0, (SHORT)0, (SHORT)0, SWP_SIZE);
WinSetWindowPos(hwnd2, HWND_TOP, 15, 10, (SHORT)0,
(SHORT)0, SWP_MOVE | SWP_ACTIVATE | SWP_SHOW);
break;
case DID_CANCEL:
WinSendMsg(hwnd2, WM_CLOSE, 0L, 0L);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case DID_OK:
// allocate memory for the new card
// if (CardInfo == NULL)
// CardInfo = (CARDINFO *)malloc(sizeof(CARDINFO);
// save the info
WinQueryDlgItemText(hwnd, ID_HWX_FNAME, 10, CardInfo->FName);
WinQueryDlgItemText(hwnd, ID_HWX_LNAME, 10, CardInfo->LName);
WinQueryDlgItemText(hwnd, ID_HWX_INIT, 1, CardInfo->Initial);
WinQueryDlgItemText(hwnd, ID_HWX_COMP, 15, CardInfo->Company);
WinQueryDlgItemText(hwnd, ID_HWX_DIV, 15, CardInfo->Division);
WinQueryDlgItemText(hwnd, ID_HWX_STREET, 30, CardInfo->StrAddr);
WinQueryDlgItemText(hwnd, ID_HWX_CITY, 15, CardInfo->City);
WinQueryDlgItemText(hwnd, ID_HWX_ZIP, 10, CardInfo->Zip);
WinQueryDlgItemText(hwnd, ID_HWX_STATE, 2, CardInfo->State);
// call page 2 and see what info was set ...
WinSendMsg(hwnd2, WM_COMMAND, MPFROMSHORT(DID_OKPAGE2), (MPARAM)CardInfo);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDismissDlg(hwnd, TRUE);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
MRESULT EXPENTRY EditBCard2DlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
CHAR szFontName[13], bmp_file[16], MailID[19], Addr[70], name[32];
LONG indx = CLR_BLACK;
POINTL points;
SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX, ID;
USHORT bmp_length=0;
INT hf;
ULONG ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE, Index;
HWND hwndDlg, hwndHWX;
PRECORDCORE pRecord; /* Pointer to RECORDCORE structure */
CARDREC *pCardRec;
BOOL Found = FALSE;
static CARDINFO *CardInfo=NULL;
switch (message)
{
case WM_INITDLG:
// set the to black text
WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
// set the font
strcpy( szFontName, "10.Helv");
WinSetPresParam( hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set the font
strcpy( szFontName, "8.Helv");
WinSetPresParam(WinWindowFromID(hwnd, ID_MORE), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// create hwnadwriting controls
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 127;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_PHONE, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 107;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_FAX, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 87;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 8;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_PAGER, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 67;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 8;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_USERID, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 47;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 8;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_NODEID, NULL, NULL );
// x and y pos from dlg coords to win coords
points.x = 40;
points.y = 27;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 15;
ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_BITMAP, NULL, NULL );
// if empty then its an update
if (mp2 != 0L) {
CardInfo = (CARDINFO *)mp2;
// show the info already stored
WinSetDlgItemText(hwnd, ID_HWX_PHONE, CardInfo->Phone);
WinSetDlgItemText(hwnd, ID_HWX_FAX, CardInfo->Fax);
WinSetDlgItemText(hwnd, ID_HWX_PAGER, CardInfo->PagerID);
WinSetDlgItemText(hwnd, ID_HWX_USERID, CardInfo->MailUserId);
WinSetDlgItemText(hwnd, ID_HWX_NODEID, CardInfo->MailNodeId);
}
return (MRESULT)TRUE ;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case ID_MORE:
WinShowWindow(hwnd, FALSE);
// x and y pos from dlg coords to win coords
points.x = 310;
points.y = 245;
WinMapDlgPoints(WinQueryWindow( hwnd, QW_OWNER), &points, 1L, TRUE);
WinSetWindowPos(WinQueryWindow( hwnd, QW_OWNER), HWND_TOP, 0, 0,
(SHORT)points.x, (SHORT)points.y, SWP_ACTIVATE | SWP_SIZE);
break;
case DID_CANCEL:
WinSendMsg(WinQueryWindow( hwnd, QW_OWNER), WM_CLOSE, 0L, 0L);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case DID_OK:
WinSendMsg(WinQueryWindow( hwnd, QW_OWNER), WM_COMMAND,
(MPARAM)DID_OK, 0L);
break;
case DID_OKPAGE2:
CardInfo = (CARDINFO *)mp2;
// save the info
WinQueryDlgItemText(hwnd, ID_HWX_PHONE, 15, CardInfo->Phone);
WinQueryDlgItemText(hwnd, ID_HWX_FAX, 15, CardInfo->Fax);
WinQueryDlgItemText(hwnd, ID_HWX_PAGER, 8, CardInfo->PagerID);
WinQueryDlgItemText(hwnd, ID_HWX_USERID, 8, CardInfo->MailUserId);
WinQueryDlgItemText(hwnd, ID_HWX_NODEID, 8, CardInfo->MailNodeId);
WinQueryDlgItemText(hwnd, ID_HWX_BITMAP, 15, bmp_file);
/* read the bitmap file */
if (bmp_file[0] != 0) {
hf = open(bmp_file, O_RDONLY | O_BINARY);
if (hf != -1 && hf != 0) {
bmp_length = read(hf, bmp_file, FILE_MAXSIZE);
close(hf);
}
}
if (CardInfo != NULL) {
// update the data Base
// PrepUpdRec(CardInfo, bmp_file, bmp_length);
// find out which card to update
hwndDlg = (HWND)WinSendMsg(hwndNB, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(CardInfo->CardId), 0L);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
// on a single card page
if (ID == ID_BCARD) {
// update the data on the Business Card
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
WinSetDlgItemText(hwndDlg, ID_NAME, name);
WinSetDlgItemText(hwndDlg, ID_COMPANY, CardInfo->Company);
WinSetDlgItemText(hwndDlg, ID_DEPT, CardInfo->Division);
sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
CardInfo->State, CardInfo->Zip);
WinSetDlgItemText(hwndDlg, ID_ADDR, Addr);
WinSetDlgItemText(hwndDlg, ID_PHONE, CardInfo->Phone);
WinSetDlgItemText(hwndDlg, ID_FAX, CardInfo->Fax);
WinSetDlgItemText(hwndDlg, ID_PAGER, CardInfo->PagerID);
sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
WinSetDlgItemText(hwndDlg, ID_MAILID, MailID);
}
// on a double card page
else {
Index = (ULONG)WinQueryWindowULong(hwndDlg, 0);
// find out which card
if (CardInfo->RecId == Names[Index].RecId) {
// update the data on the Business Card
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
WinSetDlgItemText(hwndDlg, ID_NAME2, name);
WinSetDlgItemText(hwndDlg, ID_COMPANY2, CardInfo->Company);
WinSetDlgItemText(hwndDlg, ID_DEPT2, CardInfo->Division);
sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
CardInfo->State, CardInfo->Zip);
WinSetDlgItemText(hwndDlg, ID_ADDR2, Addr);
WinSetDlgItemText(hwndDlg, ID_PHONE2, CardInfo->Phone);
WinSetDlgItemText(hwndDlg, ID_FAX2, CardInfo->Fax);
WinSetDlgItemText(hwndDlg, ID_PAGER2, CardInfo->PagerID);
sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
WinSetDlgItemText(hwndDlg, ID_MAILID2, MailID);
}
else {
// update the data on the Business Card
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
WinSetDlgItemText(hwndDlg, ID_NAME1, name);
WinSetDlgItemText(hwndDlg, ID_COMPANY1, CardInfo->Company);
WinSetDlgItemText(hwndDlg, ID_DEPT1, CardInfo->Division);
sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
CardInfo->State, CardInfo->Zip);
WinSetDlgItemText(hwndDlg, ID_ADDR1, Addr);
WinSetDlgItemText(hwndDlg, ID_PHONE1, CardInfo->Phone);
WinSetDlgItemText(hwndDlg, ID_FAX1, CardInfo->Fax);
WinSetDlgItemText(hwndDlg, ID_PAGER1, CardInfo->PagerID);
sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
WinSetDlgItemText(hwndDlg, ID_MAILID1, MailID);
}
}
// Update the Index page container info
pRecord = WinSendMsg (WinWindowFromID(hwndIndex, ID_CONTAINER),
CM_QUERYRECORD, 0L,
MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
while ((pRecord != NULL) && (Found == FALSE)) {
pCardRec = (CARDREC *) pRecord;
if (pCardRec->CardId == CardInfo->CardId) {
strcpy(pCardRec->name, name);
strcpy(pCardRec->company, CardInfo->Company);
strcpy(pCardRec->state, CardInfo->State);
FindBmp(CardInfo, pCardRec);
WinSendMsg(WinWindowFromID(hwndIndex, ID_CONTAINER),
CM_INVALIDATEDETAILFIELDINFO, 0L, 0L);
Found = TRUE; // jump out of while loop;
}
else
pRecord = WinSendMsg (WinWindowFromID(hwndIndex, ID_CONTAINER),
CM_QUERYRECORD, MPFROMP(pRecord),
MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
}
}
// add a new entry
// else {
// PrepAddToRec(CardInfo, bmp_file, bmp_length)
// Add a page
// BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
// MPFROM2SHORT(BKA_STATUSTEXTON, BKA_NEXT));
// Names[x].CardId = BCardId;
// hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)CardDlgProc,
// (HMODULE)NULL, (ULONG)ID_BCARD, &Names[x]);
// WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
// MPFROMLONG(hwndPage));
// WinSetWindowPos(hwndPage, NULLHANDLE, (ULONG) 10, (ULONG) 10,
// 0, 0, SWP_MOVE);
// }
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDestroyWindow(hwnd);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
VOID ProcessReco(MPARAM mp1, MPARAM mp2)
{
RECODATA *recodata;
HWND hwnd, hwndDlg;
CARDINFO *CardInfo;
CHAR txt[140], tmpBuff[606];
PVOID buff;
ULONG ID, index, PageID, i, rc;
RECTL rect;
CHAR ProgName[9];
RESULTCODES rcs;
RESULTCODES far *rcsptr = &rcs;
CHAR buffer[200], string1[45];
char far *Argptr = string1;
recodata = (RECODATA *) mp2;
hwnd = (HWND) mp1;
// some one drew a letter gesture
if (recodata->virtual_id == VE_LETTERGESTURE) {
// user wants to play back a greeting
if (recodata->char_code == 'V') {
// find file name, == recid
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
// do dos exec to play back the sound
strcpy( ProgName, "MPPM.EXE");
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
// WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
// call API to playback the sound
sprintf(string1, "%s %s\\%s.WAV /SC ", ProgName, BookPath, CardInfo->RecId);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
// WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
// call API to playback the sound
sprintf(string1, "%s %s\\%s.WAV /SC ", ProgName, BookPath, Names[index+1].RecId);
else
// WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
// call API to playback the sound
sprintf(string1, "%s %s\\%s.WAV /SC ", ProgName, BookPath, Names[index].RecId);
}
}
else { // Welcome sounds
// call API to playback the sound
sprintf(string1,"%s", ProgName);
sprintf(string1, "%s %s\\welcome.WAV /SC", string1, BookPath);
}
for (i = strlen(string1); i--; )
if (string1[i] == '')
string1[i] = 0;
rc = DosExecPgm( buffer, sizeof(buffer), 1, Argptr, 0, rcsptr, ProgName);
if (rc) {
DosBeep(500,500);
DosBeep(800,500);
}
}
// user wants to send a Pager transmittion
else if (recodata->char_code == 'P') {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, CardInfo);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, (PVOID)&Names[index+1]);
else
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, (PVOID)&Names[index]);
}
}
}
// user wants to send Mail
else if (recodata->char_code == 'M') {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, CardInfo);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, (PVOID)&Names[index+1]);
else
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, (PVOID)&Names[index]);
}
}
}
// user wants Add to the book
else if (recodata->char_code == 'A') {
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, 0L);
}
// user wants Remove an entry from the book
else if (recodata->char_code == 'R') {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
sprintf(txt, "Are you sure that you want to delete the %s %s card?",
CardInfo->FName, CardInfo->LName);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
sprintf(txt, "Are you sure that you want to delete the %s %s card?",
Names[index+1].FName, Names[index+1].LName);
else
sprintf(txt, "Are you sure that you want to delete the %s %s card?",
Names[index].FName, Names[index].LName);
}
WinMessageBox ( HWND_DESKTOP, hwndNB,
txt, "Contact/2", 0,
MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL | MB_MOVEABLE);
}
}
// user wants to Update an entry in the book
else if (recodata->char_code == 'U') {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, CardInfo);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, (PVOID)&Names[index+1]);
else
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, (PVOID)&Names[index]);
}
}
}
// user wants to Add an entry in the book to the clipboard
else if (recodata->char_code == 'C') {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
// if it is the top level window (DLGBOX)
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
sprintf(txt, "The card named %s %s has been copied to the clipboard.",
CardInfo->FName, CardInfo->LName);
sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
CardInfo->FName, CardInfo->Initial, CardInfo->LName,
CardInfo->Company, CardInfo->Division, CardInfo->StrAddr,
CardInfo->City, CardInfo->State, CardInfo->Zip,
CardInfo->Phone, CardInfo->Fax, CardInfo->PagerID,
CardInfo->MailUserId, CardInfo->MailNodeId);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
sprintf(txt, "The card named %s %s has been copied to the clipboard.",
Names[index+1].FName, Names[index+1].LName);
sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
Names[index+1].FName, Names[index+1].Initial, Names[index+1].LName,
Names[index+1].Company, Names[index+1].Division, Names[index+1].StrAddr,
Names[index+1].City, Names[index+1].State, Names[index+1].Zip,
Names[index+1].Phone, Names[index+1].Fax, Names[index+1].PagerID,
Names[index+1].MailUserId, Names[index+1].MailNodeId);
}
else {
sprintf(txt, "The card named %s %s has been copied to the clipboard.",
Names[index].FName, Names[index].LName);
sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
Names[index].FName, Names[index].Initial, Names[index].LName,
Names[index].Company, Names[index].Division, Names[index].StrAddr,
Names[index].City, Names[index].State, Names[index].Zip,
Names[index].Phone, Names[index].Fax, Names[index].PagerID,
Names[index].MailUserId, Names[index].MailNodeId);
}
}
// copy it to the clipboard
DosAllocSharedMem(&buff, NULL, sizeof(tmpBuff), OBJ_GIVEABLE |
PAG_COMMIT | PAG_READ | PAG_WRITE);
strcpy(buff, tmpBuff);
WinOpenClipbrd(hab);
WinSetClipbrdData(hab, (ULONG)buff, CF_TEXT, CFI_POINTER);
WinCloseClipbrd(hab);
WinMessageBox ( HWND_DESKTOP, hwndNB,
txt, "Contact/2", 0,
MB_OK | MB_INFORMATION | MB_APPLMODAL | MB_MOVEABLE);
}
}
}
// bring up help
else if (recodata->virtual_id == VE_HELP)
WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)HelpDlgProc, (HMODULE)NULL, ID_HELP, 0L);
// turn back a page
else if (recodata->virtual_id == VE_SCROLLLEFT) {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
// turn to the index page
if (hwndDlg == hwndWelcome)
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(IndexCardId), 0L);
else if (hwndDlg == hwndIndex) {
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(IndexCardId),
MPFROM2SHORT(BKA_PREV, BKA_MAJOR));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
else if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
// turn back a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(CardInfo->CardId),
MPFROM2SHORT(BKA_PREV, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
// turn back a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(Names[index+1].CardId),
MPFROM2SHORT(BKA_PREV, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
else {
// turn back a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(Names[index].CardId),
MPFROM2SHORT(BKA_PREV, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
}
}
// turn forward a page
else if (recodata->virtual_id == VE_SCROLLRIGHT) {
ID = WinQueryWindowUShort(hwnd, QWS_ID);
if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
(ID == ID_BCARD) || (ID == ID_BCARD2))
hwndDlg = hwnd;
else {
hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
}
// turn to the first page
if (hwndDlg == hwndWelcome) {
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(WelcomeCardId),
MPFROM2SHORT(BKA_NEXT, BKA_MAJOR));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
// turn to the welcome page
else if (hwndDlg == hwndIndex)
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(WelcomeCardId), 0L);
else if (ID == ID_BCARD) {
CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
// turn forward a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(CardInfo->CardId),
MPFROM2SHORT(BKA_NEXT, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
else {
index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
// find out which card the gesture was done on
WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
WinQueryWindowRect(hwndDlg, &rect);
if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
// turn forward a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(Names[index+1].CardId),
MPFROM2SHORT(BKA_NEXT, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
else {
// turn forward a page
PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
MPFROMLONG(Names[index].CardId),
MPFROM2SHORT(BKA_NEXT, 0));
WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
}
}
}
}
MRESULT EXPENTRY NoteBookSubWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
ULONG ID;
switch (msg) {
case WM_RECO:
WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
return (MRESULT)TRUE;
} // end switch
ID = WinQueryWindowUShort(hwnd, QWS_ID);
if (ID > ID_BCARD2)
return((*TwoCardSubProc[ID-ID_LOGO1])(hwnd,msg,mp1,mp2));
else if (ID > ID_INDEX)
return((*IndexSubProc[ID-ID_CONTAINER])(hwnd,msg,mp1,mp2));
else if (ID > ID_WELCOME)
return((*WelcomeSubProc[ID-ID_IBMBMP])(hwnd,msg,mp1,mp2));
else if (ID > ID_BCARD)
return((*CardSubProc[ID-ID_LOGO])(hwnd,msg,mp1,mp2));
else
return((*NBSubProc)(hwnd,msg,mp1,mp2));
}
MRESULT EXPENTRY SketchDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
static CARDINFO *CardInfo;
HWND hwndOwner;
CHAR name[80];
switch (message)
{
case WM_INITDLG:
CardInfo = (CARDINFO *)mp2;
// grab the name for the title
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"Clip-a-Sketch: %s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"Clip-a-Sketch: %s %s", CardInfo->FName, CardInfo->LName);
WinSetWindowText(hwnd, name);
WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_SET_CTL_INK_COLOR,
MPFROMSHORT(CLR_BLUE), 0L);
ReadAndDisplaySketch(hwnd, CardInfo->RecId);
WinSetFocus(HWND_DESKTOP, hwnd);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
// add the stroke to the controls 'data base'
case SKN_STROKE_ADD:
return 0L;
// clear entire control
case SKN_CONTROL_CLEARED:
return 0L;
// undo last stroke
case SKN_STROKE_UNDO:
return 0L;
default:
break;
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case DID_OK:
SaveSketch(hwnd, CardInfo->RecId);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case DID_CANCEL:
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case ID_CLEAR:
WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_DELETE_ALL_STROKES, 0L, 0L);
break;
case ID_UNDO:
WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_UNDO_LAST_STROKE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinSetFocus(HWND_DESKTOP, hwndClient);
WinDismissDlg(hwnd, TRUE);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
USHORT SaveSketch(HWND hwndDlg, CHAR *RecId)
{
APIRET rc; /* return code */
ULONG ulStrokeCount; /* Total Strokes in signat */
ULONG ulSaveIndex;
ULONG ulSignatureSize;
CHAR filename[45];
HFILE hf; /* Address of file handle */
ULONG ulBytesRead;
ULONG ulBytesWritten;
ULONG ulAction;
PSKETCHSTROKEDEF pStrokeData = NULL;
ULONG ulNewPtr; /* file pointer */
ULONG *ulEachStrokeLength; /* array of stroke lengths */
sprintf(filename, "%s\\%s.skt", BookPath, RecId);
/****************************************************/
/* Get the total count of strokes in the signature. */
/****************************************************/
ulStrokeCount =
(ULONG) WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
SKM_QUERY_CTL_STROKE_COUNT,
NULL, NULL);
// if ther is nothing in the sketch control erase the file
if (ulStrokeCount < 1) {
unlink(filename);
return TRUE;
}
/**************************************************************************/
/* Next, Open file to save Application Record, if first time - create it. */
/**************************************************************************/
rc = DosOpen(filename,
&hf,
&ulAction,
0,
FILE_NORMAL,
FILE_OPEN | FILE_CREATE,
(ULONG)OPEN_ACCESS_READWRITE |
OPEN_SHARE_DENYREADWRITE |
OPEN_FLAGS_FAIL_ON_ERROR,
(PEAOP2)NULL);
if (rc) /* Error opening the file */
{
DosBeep(500,200);
return FALSE;
}
ulSignatureSize = ulStrokeCount * sizeof(ULONG); /* bytes in file */
/*******************************************************/
/* Malloc enough to save the lengths of each stroke. */
/*******************************************************/
ulEachStrokeLength = (ULONG *) calloc(ulStrokeCount, sizeof(ULONG) );
/*************************************************************/
/* First stroke to the last stroke - */
/* Save each strokes' length in the array which was malloced */
/*************************************************************/
for (ulSaveIndex = 0; ulSaveIndex < ulStrokeCount; ulSaveIndex++)
{
ulEachStrokeLength[ulSaveIndex] =
(ULONG) WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
SKM_QUERY_STROKE_LENGTH,
MPFROMLONG(ulSaveIndex + 1), /* actual stroke number */
NULL);
ulSignatureSize += ulEachStrokeLength[ulSaveIndex];
}
/************************************************************************/
/* Write HEADER containing Stroke count and Sketch size. */
/************************************************************************/
DosWrite(hf,
&ulSignatureSize,
sizeof(ULONG),
&ulBytesWritten);
DosWrite(hf,
&ulStrokeCount,
sizeof(ULONG),
&ulBytesWritten);
if ( ulBytesWritten != (sizeof(ULONG)) )
{
DosBeep(500,200);
free(ulEachStrokeLength);
DosClose(hf);
return(FALSE);
}
/*******************************************************/
/* Write ALL of the stroke's lengths to the file. */
/*******************************************************/
DosWrite(hf,
ulEachStrokeLength,
sizeof(ULONG) * ulStrokeCount,
&ulBytesWritten);
if ( ulBytesWritten != ( sizeof(ULONG) * ulStrokeCount) )
{
DosBeep(200,500);
free(ulEachStrokeLength);
DosClose(hf);
return(FALSE);
}
/**************************************/
/* First stroke to the last stroke - */
/* Write each stroke to the file. */
/**************************************/
for (ulSaveIndex = 0; ulSaveIndex < ulStrokeCount; ulSaveIndex++)
{
/*******************************************************/
/* Allocate a buffer (non-shared) based on that size. */
/*******************************************************/
pStrokeData = malloc(ulEachStrokeLength[ulSaveIndex]);
if (!pStrokeData)
{
DosBeep(500,200);
free(ulEachStrokeLength);
DosClose(hf);
return(FALSE);
}
/*******************************/
/* Get the Stroke information. */
/*******************************/
WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
SKM_QUERY_STROKE_DATA,
MPFROMLONG(ulSaveIndex + 1), /* actual stroke number */
MPFROMP(pStrokeData) );
/**********************************/
/* Write the Stroke to file. */
/**********************************/
DosWrite(hf,
pStrokeData,
ulEachStrokeLength[ulSaveIndex],
&ulBytesWritten);
if ( ulBytesWritten != ulEachStrokeLength[ulSaveIndex])
{
DosBeep(500,200);
free(ulEachStrokeLength);
free(pStrokeData);
DosClose(hf);
return(FALSE);
}
free(pStrokeData);
}
DosClose(hf);
free(ulEachStrokeLength);
return TRUE;
} /* SaveApp */
VOID SaveMailFile(CHAR *txt)
{
CHAR filename[45];
LONG pos=0;
HFILE hf; /* Address of file handle */
ULONG ulBytesWritten;
ULONG ulAction;
APIRET rc; /* return code */
sprintf(filename, "%s\\penmail.txt", BookPath);
rc = DosOpen(filename,
&hf,
&ulAction,
0,
FILE_NORMAL,
FILE_OPEN | FILE_CREATE,
(ULONG)OPEN_ACCESS_READWRITE |
OPEN_SHARE_DENYREADWRITE |
OPEN_FLAGS_FAIL_ON_ERROR,
(PEAOP2)NULL);
if (rc) /* Error opening the file */
DosBeep(500,200);
lseek(hf, 0L, SEEK_SET);
DosWrite(hf,
txt,
strlen(txt),
&ulBytesWritten);
if ( ulBytesWritten != ( strlen(txt)) )
{
DosBeep(200,500);
DosClose(hf);
}
/* force and End of File */
pos = tell(hf);
chsize(hf, pos);
DosClose(hf);
} /* SaveApp */
USHORT ReadAndDisplaySketch(HWND hwndDlg, CHAR *RecId)
{
ULONG ulStrokeCount; /* Total Strokes in signat */
ULONG ulStrokeIndex; /* stroke indexer */
BOOL rc;
ULONG ulSignatureSize;
HFILE hf; /* Address of file handle */
ULONG ulBytesRead;
ULONG ulBytesWritten;
ULONG ulAction;
PSKETCHSTROKEDEF pStrokeData = NULL;
CHAR filename[45];
ULONG *ulEachStrokeLength; /* array of stroke lengths */
sprintf(filename, "%s\\%s.skt", BookPath, RecId);
rc = DosOpen(filename,
&hf,
&ulAction,
0,
FILE_NORMAL,
FILE_OPEN,
(ULONG)OPEN_ACCESS_READWRITE |
OPEN_SHARE_DENYREADWRITE |
OPEN_FLAGS_FAIL_ON_ERROR,
(PEAOP2)NULL);
if (rc) // error or none exists
{
return FALSE;
}
DosRead(hf, &ulSignatureSize, sizeof(ULONG), &ulBytesRead);
DosRead(hf, &ulStrokeCount, sizeof(ULONG), &ulBytesRead);
if (ulBytesRead != sizeof(ULONG) ) {
DosBeep(500,200);
DosClose(hf);
return FALSE;
}
/*********************************************************/
/* Malloc enough to retrieve the lengths of each stroke. */
/*********************************************************/
ulEachStrokeLength = (ULONG *) calloc(ulStrokeCount, sizeof(ULONG) );
/**************************************************/
/* Read All stroke lengths into array of lengths. */
/**************************************************/
DosRead(hf, (VOID *) ulEachStrokeLength, (sizeof(ULONG) * ulStrokeCount), &ulBytesRead);
if ( ulBytesRead != (sizeof(ULONG) * ulStrokeCount) )
{
DosBeep(500,200);
DosClose(hf);
free(ulEachStrokeLength);
return(FALSE);
}
/**************************************/
/* First stroke to the last stroke - */
/* Read each stroke from the file. */
/**************************************/
for (ulStrokeIndex = 0; ulStrokeIndex < ulStrokeCount; ulStrokeIndex++)
{
/*******************************************************/
/* Allocate a buffer (non-shared) based on that size. */
/*******************************************************/
pStrokeData = malloc(ulEachStrokeLength[ulStrokeIndex]);
if (!pStrokeData)
{
DosBeep(500,200);
DosClose(hf);
free(ulEachStrokeLength);
return(FALSE);
}
memset(pStrokeData , '\0',ulEachStrokeLength[ulStrokeIndex]); /* Zap, Zap, Zap */
/**************************************************/
/* Read the stroke from the file into the buffer. */
/**************************************************/
DosRead(hf,
pStrokeData,
ulEachStrokeLength[ulStrokeIndex],
&ulBytesRead);
/**********************************************/
/* The following code is necessary for Stroke */
/* Data pointer fix ups after each read. */
/**********************************************/
pStrokeData->pStroke = (PSTROKEDATA) ( (PBYTE) pStrokeData + sizeof( SKETCHSTROKEDEF ));
pStrokeData->pStroke->pXY = (PPOINTL) ( (PBYTE) pStrokeData + sizeof( SKETCHSTROKEDEF ) + sizeof( STROKEDATA ));
if (pStrokeData->pStroke->pAuxInfo)
{
pStrokeData->pStroke->pAuxInfo = (PAUXDATAINFO)
( (PBYTE) pStrokeData->pStroke->pXY
+ pStrokeData->pStroke->ulNumPoints * sizeof( POINTL ));
}
if (pStrokeData->pStroke->pAuxData)
{
pStrokeData->pStroke->pAuxData = (PAUXSTROKEDATA)
( (PBYTE) pStrokeData->pStroke->pAuxInfo
+ sizeof( AUXDATAINFO )
+ sizeof( AUXDATADESC )
* ( pStrokeData->pStroke->pAuxInfo->ulNumElements - 1 )
+ pStrokeData->pStroke->ulNumPoints
* pStrokeData->pStroke->pAuxInfo->ulAuxSize);
}
if ( ulBytesRead != ulEachStrokeLength[ulStrokeIndex])
{
DosBeep(500,200);
free(ulEachStrokeLength);
free(pStrokeData);
DosClose(hf);
return(FALSE);
}
/*******************************************/
/* Put the Stroke into the Sketch Control. */
/*******************************************/
rc = (BOOL)WinSendMsg( WinWindowFromID( hwndDlg, ID_SKETCH),
SKM_ADD_STROKE,
NULL,
MPFROMP(pStrokeData) );
if (rc == FALSE)
{
DosBeep(500,200);
free(ulEachStrokeLength);
free(pStrokeData);
DosClose(hf);
return(FALSE);
}
free(pStrokeData);
} /* end for loop - completed reading all strokes */
/**************************************************/
/* Free the array of stroke lengths. */
/**************************************************/
free(ulEachStrokeLength);
DosClose(hf);
return TRUE;
} /* ReadandDisplaySignature */
MRESULT EXPENTRY PagerDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
static CARDINFO *CardInfo;
static BOOL Paging=FALSE;
HWND hwndOwner;
CHAR name[80];
SHORT Rows, Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
POINTL points;
ULONG ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE | HX_3DBORDER;
static PDDESTRUCT pddeData;
switch (message)
{
case WM_INITDLG:
CardInfo = (CARDINFO *)mp2;
// grab the name for the title
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"Call-a-Pager: %s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"Call-a-Pager: %s %s", CardInfo->FName, CardInfo->LName);
WinSetWindowText(hwnd, name);
points.y = 20;
points.x = 3;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 11;
Rows = 4;
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
ControlDY = (Rows * (CharBoxDY + BaseLineDY)) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_PAGERTXT, NULL, NULL );
WinShowWindow(WinWindowFromID(hwnd, ID_SRVPAGE), FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_PAGEING), FALSE);
WinSetFocus(HWND_DESKTOP, hwnd);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case DID_OK:
{
CONVCONTEXT Context;
CHAR txt[41], app[7]="SkySrv", name[7]="System";
WinQueryDlgItemText(hwnd, ID_HWX_PAGERTXT, 40, txt);
// no text so dont send anything
if (txt[0] == 0) {
WinMessageBox ( HWND_DESKTOP, hwndNB,
"There is no text to send. The Pager will not be called.", "Contact/2", 0,
MB_OK | MB_INFORMATION | MB_SYSTEMMODAL);
break;
}
// show that page is being que'd
WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_SRVPAGE), TRUE);
DosSleep(500);
Context.cb = sizeof(CONVCONTEXT);
Context.fsContext = DDECTXT_CASESENSITIVE;
Context.idCountry = DDE_COUNTRY;
Context.usCodepage = DDE_CODEPAGE;
Context.usLangID = 0L;
Context.usSubLangID = 0L;
// app is SkySrv topic is System
// send the page message
WinDdeInitiate(hwnd, app, name, &Context);
}
break;
case DID_CANCEL:
WinSetFocus(HWND_DESKTOP, hwnd);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_DDE_INITIATEACK:
{
CHAR txt[41], msg[70];
PID DestPID;
TID DestTID;
PDDEINIT pData;
pData = (PDDEINIT)mp2;
if ((pData != NULL) && (strcmp(pData->pszAppName, "SkySrv") == 0)) {
DosAllocSharedMem((PPVOID)&pddeData, NULL, sizeof(DDESTRUCT)+70,
PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE |
OBJ_GIVEABLE | OBJ_GETTABLE );
Paging = TRUE;
pddeData->cbData = sizeof(DDESTRUCT)+70;
pddeData->fsStatus = DDE_FACKREQ;
pddeData->usFormat = DDEFMT_TEXT;
pddeData->offszItemName = sizeof(DDESTRUCT);
// there is no item name
strcpy((BYTE *)pddeData + pddeData->offszItemName, "");
// of set to begining of data
pddeData->offabData = sizeof(DDESTRUCT)+1;
// get data, from handwriting pad
WinQueryDlgItemText(hwnd, ID_HWX_PAGERTXT, 40, txt);
sprintf(msg, "[SndMsg('%s',0,'%s')]", CardInfo->PagerID, txt);
strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
// give the data to the server app.
WinQueryWindowProcess((HWND)mp1, &DestPID, &DestTID );
if( !DosGiveSharedMem(&pddeData, DestPID, PAG_WRITE )) {
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
DosFreeMem(pData);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
}
// app is SkySrv topic is System
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
}
DosFreeMem(pData);
}
break;
case WM_DDE_ACK:
// show if sent or not...
WinShowWindow(WinWindowFromID(hwnd, ID_PAGEING), TRUE);
DosSleep(1200);
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
break;
case WM_DDE_TERMINATE:
DosFreeMem(pddeData);
Paging = FALSE;
// now shut down the dialog box
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case WM_CLOSE:
if (Paging == TRUE) {
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
DosFreeMem(pddeData);
Paging = FALSE;
}
WinDismissDlg(hwnd, TRUE);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
MRESULT EXPENTRY MailDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
static CARDINFO *CardInfo;
static BOOL Mailing=FALSE;
static USHORT Step;
HWND hwndOwner;
CHAR name[84];
SHORT Rows, Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
POINTL points;
ULONG ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE | HX_3DBORDER;
static PDDESTRUCT pddeData;
switch (message)
{
case WM_INITDLG:
CardInfo = (CARDINFO *)mp2;
// grab the name for the title
if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
sprintf(name,"Send cc: Mail to %s %s. %s", CardInfo->FName, CardInfo->Initial,
CardInfo->LName);
else
sprintf(name,"Send cc: Mail to %s %s", CardInfo->FName, CardInfo->LName);
WinSetWindowText(hwnd, name);
points.y = 20;
points.x = 5;
WinMapDlgPoints(hwnd, &points, 1L, TRUE);
// find optimal size for handwriting comb
Cols = 13;
Rows = 6;
CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
BaseLineDY = CharBoxDY / 3;
ControlDY = (Rows * (CharBoxDY + BaseLineDY)) + BaseLineDY;
ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
points.x, points.y, ControlDX, ControlDY,
hwnd, HWND_TOP, ID_HWX_MAILTXT, NULL, NULL );
WinShowWindow(WinWindowFromID(hwnd, ID_SRVMAIL), FALSE);
WinShowWindow(WinWindowFromID(hwnd, ID_MAILING), FALSE);
WinSetFocus(HWND_DESKTOP, hwnd);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case DID_OK:
{
CONVCONTEXT Context;
CHAR txt[66], app[6]="wmail", name[9]="SendMail";
WinQueryDlgItemText(hwnd, ID_HWX_MAILTXT, sizeof(txt), txt);
// no text so dont send anything
if (txt[0] == 0) {
WinMessageBox ( HWND_DESKTOP, hwndNB,
"There is no text to send.", "Contact/2", 0,
MB_OK | MB_INFORMATION | MB_SYSTEMMODAL);
break;
}
else { // save to a file
WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
// show that mail is being que'd
WinShowWindow(WinWindowFromID(hwnd, ID_SRVMAIL), TRUE);
SaveMailFile(txt);
}
Context.cb = sizeof(CONVCONTEXT);
Context.fsContext = DDECTXT_CASESENSITIVE;
Context.idCountry = DDE_COUNTRY;
Context.usCodepage = DDE_CODEPAGE;
Context.usLangID = 0L;
Context.usSubLangID = 0L;
Step = 0;
// app is SkySrv topic is System
// send the mail message
WinDdeInitiate(hwnd, app, name, &Context);
}
break;
case DID_CANCEL:
WinSetFocus(HWND_DESKTOP, hwnd);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_DDE_INITIATEACK:
{
CHAR msg[50];
PID DestPID;
TID DestTID;
PDDEINIT pData;
pData = (PDDEINIT)mp2;
if ((pData != NULL) && (strcmp(pData->pszAppName, "wmail") == 0)) {
DosAllocSharedMem((PPVOID)&pddeData, NULL, sizeof(DDESTRUCT)+70,
PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE |
OBJ_GIVEABLE | OBJ_GETTABLE );
Mailing = TRUE;
pddeData->cbData = sizeof(DDESTRUCT)+70;
pddeData->fsStatus = DDE_FACKREQ;
pddeData->usFormat = DDEFMT_TEXT;
pddeData->offszItemName = sizeof(DDESTRUCT);
// there is no item name
strcpy((BYTE *)pddeData + pddeData->offszItemName, "");
// of set to begining of data
pddeData->offabData = sizeof(DDESTRUCT)+1;
strcpy(msg, "NewMessage");
strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
// give the data to the server app.
WinQueryWindowProcess((HWND)mp1, &DestPID, &DestTID );
if( !DosGiveSharedMem(&pddeData, DestPID, PAG_WRITE | PAG_READ)) {
DosBeep(1000,500);
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
DosFreeMem(pData);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
return (MRESULT) TRUE;
}
Step++;
// app is SkySrv topic is System
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
}
DosFreeMem(pData);
}
break;
case WM_DDE_ACK:
{
PID DestPID;
TID DestTID;
CHAR msg[50];
if ( Step == 1) {
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
sprintf(msg, "AttachFile %s\\penmail.txt", BookPath);
}
else if (Step == 2) {
sprintf(msg, "To %s", CardInfo->MailUserId);
}
else if (Step == 3) {
strcpy(msg, "Send");
WinShowWindow(WinWindowFromID(hwnd, ID_MAILING), TRUE);
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
}
else {
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
return (MRESULT) TRUE;
}
pddeData->fsStatus = DDE_FACKREQ;
strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
Step++;
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
}
break;
case WM_DDE_TERMINATE:
DosFreeMem(pddeData);
Mailing = FALSE;
// now shut down the dialog box
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
case WM_CLOSE:
if (Mailing == TRUE) {
WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
Mailing = FALSE;
DosFreeMem(pddeData);
}
WinDismissDlg(hwnd, TRUE);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}
BOOL Paint3dLines(HPS hps, PRECTL pRectl)
{ //
POINTL p; //
POINTL pRt[4], pBot[4];
RECTL rClient; //
SHORT i;
//
rClient = *pRectl; // Get a copy of the rect
//
//
GpiSetColor( hps, CLR_DARKGRAY); // Color for right vert and bot horz
// right side
pRt[0].x =rClient.xRight+5;
pRt[0].y =rClient.yTop-8;
pRt[1].x =rClient.xRight+5;
pRt[1].y =rClient.yBottom-6;
pRt[2].x =rClient.xRight;
pRt[2].y =rClient.yBottom;
pRt[3].x =rClient.xRight;
pRt[3].y =rClient.yTop-8;
// bottom side
pBot[0].x =rClient.xLeft+8;
pBot[0].y =rClient.yBottom-6;
pBot[1].x =rClient.xRight+5;
pBot[1].y =rClient.yBottom-6;
pBot[2].x =rClient.xRight;
pBot[2].y =rClient.yBottom-1;
pBot[3].x =rClient.xLeft+8;
pBot[3].y =rClient.yBottom-1;
GpiSetDrawingMode(hps, DM_DRAWANDRETAIN);
GpiBeginPath(hps,1L); //
GpiMove( hps, &pBot[3] ); // Move
GpiPolyLine(hps,4L ,&pBot[0]); //
GpiEndPath(hps);
GpiFillPath(hps, 1L, FPATH_ALTERNATE);
GpiBeginPath(hps,1L); //
GpiMove( hps, &pRt[3] ); // Move
GpiPolyLine(hps,4L ,&pRt[0]); //
GpiEndPath(hps);
GpiFillPath(hps, 1L, FPATH_ALTERNATE);
GpiSetColor( hps, CLR_BLACK); // Color for right vert and bot horz
GpiSetLineWidth(hps, LINEWIDTH_THICK);
p.x =rClient.xRight;
p.y =rClient.yTop;
GpiMove( hps, &p ); // Move
p.x =rClient.xRight;
p.y =rClient.yBottom+1;
GpiLine( hps, &p ); // Draw it
p.x =rClient.xLeft;
p.y =rClient.yBottom+1;
GpiLine( hps, &p ); // Draw it
//
return( TRUE ); //
} //
VOID FindBmp(CARDINFO *Name, CARDREC *CardRec)
{
// phone=1000, fax=0100, pager=0010, mail=0001
ULONG flags=0x0000;
if (Name->Phone[0] != 0)
flags |= 0x1000;
if (Name->Fax[0] != 0)
flags |= 0x0100;
if (Name->PagerID[0] != 0)
flags |= 0x0010;
if (Name->MailUserId[0] != 0)
flags |= 0x0001;
if (flags == 0x0001)
CardRec->bitmap = hbmp0001;
else if (flags == 0x0010)
CardRec->bitmap = hbmp0010;
else if (flags == 0x0011)
CardRec->bitmap = hbmp0011;
else if (flags == 0x0100)
CardRec->bitmap = hbmp0100;
else if (flags == 0x0101)
CardRec->bitmap = hbmp0101;
else if (flags == 0x0110)
CardRec->bitmap = hbmp0110;
else if (flags == 0x0111)
CardRec->bitmap = hbmp0111;
else if (flags == 0x1000)
CardRec->bitmap = hbmp1000;
else if (flags == 0x1001)
CardRec->bitmap = hbmp1001;
else if (flags == 0x1010)
CardRec->bitmap |= hbmp1010;
else if (flags == 0x1011)
CardRec->bitmap = hbmp1011;
else if (flags == 0x1100)
CardRec->bitmap = hbmp1100;
else if (flags == 0x1101)
CardRec->bitmap = hbmp1101;
else if (flags == 0x1110)
CardRec->bitmap = hbmp1110;
else if (flags == 0x1111)
CardRec->bitmap = hbmp1111;
else // no method of communication 0x0000
CardRec->bitmap = hbmp0000;
}
MRESULT EXPENTRY HelpDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
{
CHAR *msg;
CHAR szFontName[23];
ULONG indx=CLR_RED;
switch (message)
{
case WM_INITDLG:
msg = (CHAR *)malloc(475);
sprintf(msg, "%s %s %s", STRTXT1, STRTXT2, STRTXT3);
WinSetDlgItemText(hwnd, ID_TEXT2, msg);
free(msg);
strcpy( szFontName, "10.Helvetica");
WinSetPresParam( hwnd, PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
// set up different font and color for my name
strcpy( szFontName, "12.Tms Rmn Bold Italic");
WinSetPresParam( WinWindowFromID(hwnd, ID_TEXT4), PP_FONTNAMESIZE,
(LONG)strlen( szFontName ) + 1L,
(PVOID)szFontName );
WinSetPresParam(WinWindowFromID(hwnd, ID_TEXT4), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
WinSetFocus(HWND_DESKTOP, hwnd);
return (MRESULT)TRUE;
case WM_CONTROL:
switch (HIUSHORT(mp1))
{
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return (MRESULT)TRUE ;
case WM_COMMAND:
switch (LOUSHORT(mp1))
{
case DID_CANCEL:
WinSetFocus(HWND_DESKTOP, hwnd);
WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
default:
return WinDefWindowProc(hwnd, message, mp1, mp2);
}
break;
case WM_CLOSE:
WinDismissDlg(hwnd, TRUE);
return (MRESULT) TRUE;
default:
return(WinDefDlgProc(hwnd,message,mp1,mp2));
}
return(0L);
}