コード例 #1
0
MRESULT MainSize(HWND hwnd,      /* handle to the main client window */
                 SHORT sTotalMsgs,
                 MPARAM mp1,     /* first parameter of WM_SIZE message */
                 MPARAM mp2)     /* second parameter of WM_SIZE message */
{

   cxClient = SHORT1FROMMP (mp2) ;
   cyClient = SHORT2FROMMP (mp2) ;

   sHscrollMax = max (0, cxTextTotal - cxClient) ;
   sHscrollPos = min (sHscrollPos, sHscrollMax) ;

   WinSendMsg (hwndHscroll, SBM_SETSCROLLBAR,
                            MPFROM2SHORT (sHscrollPos, 0),
                            MPFROM2SHORT (0, sHscrollMax)) ;

   WinEnableWindow (hwndHscroll, (BOOL)((sHscrollMax != 0) ? TRUE : FALSE)) ;

   sVscrollMax = max (0, sTotalMsgs - cyClient / cyChar) ;
   sVscrollPos = min (sVscrollPos, sVscrollMax) ;

   WinSendMsg (hwndVscroll, SBM_SETSCROLLBAR,
                            MPFROM2SHORT (sVscrollPos, 0),
                            MPFROM2SHORT (0, sVscrollMax)) ;

   WinEnableWindow (hwndVscroll, (BOOL)((sVscrollMax != 0) ? TRUE : FALSE)) ;

   return (MRFROMLONG(0));
}
コード例 #2
0
VOID AdjustSaveTypeButtons (BOOL f)
{
    HWND   hwndClient = WinWindowFromID (hwndFrame, FID_CLIENT);

    // FIXME um, em, global variables :-$
    WinEnableWindow (WinWindowFromID (hwndClient, WID_RB_CLIPBOARD), !f);
    WinEnableWindow (WinWindowFromID (hwndClient, WID_RB_FILE), !f);
}
コード例 #3
0
ファイル: clbx.c プロジェクト: OS2World/UTIL-WPS-Styler_2
MRESULT clbSetCheck(PCLBOX pclb, BOOL fl) {
   if (!(pclb->fl & CLBXS_CHECK)) return (MRESULT)0;
   pclb->is.chkon = (fl != 0);
   WinEnableWindow(pclb->hlbx, pclb->is.chkon);
   WinEnableWindow(pclb->hentry, pclb->is.chkon);
   WinEnableWindow(pclb->hadd, pclb->is.chkon & pclb->is.addon);
   WinEnableWindow(pclb->hrem, pclb->is.chkon & pclb->is.remon);
   WinEnableWindow(pclb->hfind, pclb->is.chkon);
   return pclb->pfbtn(pclb->hchk, BM_SETCHECK, (MPARAM)pclb->is.chkon, MPVOID);
}
コード例 #4
0
ファイル: dlg.c プロジェクト: komh/hanedit2
void dlgFind_SetFound(HWND hwnd,int found)
{
HWND hwndBtnReplace = WinWindowFromID(hwnd,IDB_REPLACE);
HWND hwndBtnReplaceFind = WinWindowFromID(hwnd,IDB_REPLACEFIND);
HWND hwndBtnReplaceAll = WinWindowFromID(hwnd,IDB_REPLACEALL);

    WinEnableWindow(hwndBtnReplace,found);
    WinEnableWindow(hwndBtnReplaceFind,found);
    WinEnableWindow(hwndBtnReplaceAll,found);
    dlgFind_found = found;
}
コード例 #5
0
void DConfirmDlg::OnAllBoxClick()
{
	// Check to see if this is turned off/on enable or disable other 3 options
	// accordingly.
	int rc = IsDlgButtonChecked(IDC_CONFIRM_ALL);
	{
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_DELETE), !rc);
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_REPLACE), !rc);
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_COPY), !rc);
	}

}
コード例 #6
0
ファイル: progress.c プロジェクト: OS2World/UTIL-WPS-Styler_2
BOOL APIENTRY WprogressBar(HWND hParent, HWND hOwner, PPROGRESSDLG ppd) {
   QMSG  qmsg;
   HWND hwnd;
   PPRGSAPPDATA pad;
   BOOL rc = FALSE;
   
   // allocate storage for application data
   if (!(pad = (PPRGSAPPDATA)malloc(sizeof(PRGSAPPDATA)))) return FALSE;
   memset(pad, 0, sizeof(PRGSAPPDATA));
   pad->ppd = ppd;
   // ottiene tempo di inizio
   pad->start = WinGetCurrentTime(pad->hab = WinQueryAnchorBlock(hOwner))
                / 1000;
   // window handles
   if (ppd->fl & PRGSS_BITMAP) {
      SIZEL szl;
      WqueryBitmapSize(pad->ppd->hbmp, &szl);
      pad->cxbmp = szl.cx;
   } /* endif */
   if (NULLHANDLE != (hwnd = WinLoadDlg(hParent, hOwner, ProgressDlgProc,
                                     hmod, DLG_PROGRESS, pad))) {
      if (!ppd->pszPrgrss) ppd->pszPrgrss = SZ_PROGRESS;
      if (!ppd->pszTime) ppd->pszTime = SZ_ELAPSTIME;
      if (ppd->pszStop) WinSetDlgItemText(hwnd, BTN_STOP, ppd->pszStop);
      pad->hOwner = WinQueryWindow(hwnd, QW_OWNER);
      WinEnableWindow(pad->hOwner, FALSE);
      for(;;) {
         if (WinGetMsg(pad->hab, &qmsg, NULLHANDLE, 0, 0)) {    // loop standard
            if (qmsg.msg == PRGSM_END && qmsg.hwnd == hwnd) {
               if (pad->qQuit.msg)
                  WinPostMsg(pad->qQuit.hwnd, pad->qQuit.msg,
                             pad->qQuit.mp1, pad->qQuit.mp2);
               break;
            } // end if   
            WinDispatchMsg(pad->hab, &qmsg);
         } else {                   // WM_QUIT
            pad->qQuit = qmsg;
            if(qmsg.hwnd == NULLHANDLE)                       // SHUTDOWN
               WinPostMsg(hwnd, WM_CLOSE, MPFROMLONG(TRUE), NULL);
            else if(qmsg.hwnd == HWNDFROMMP(qmsg.mp2))        // TASKLIST
               WinPostMsg(hwnd, WM_CLOSE, 0L, 0L);
            else                            // chiusura regolare: termina
               break;
         } // end if
      } // end forever
      WinSetFocus(HWND_DESKTOP, hOwner);
      WinDestroyWindow(hwnd);
      WinEnableWindow(pad->hOwner, TRUE);
      rc = TRUE;
   } // end if
   free(pad);
   return rc;
}
コード例 #7
0
MRESULT EXPENTRY PrefGeneralDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
 ULONG h, m, s;

 switch (msg)
      {

       case WM_INITDLG:
         WinSendDlgItemMsg(hwnd, DID_COMMENT_STRN, EM_SETTEXTLIMIT,
                           MPFROMSHORT(COMMENT_MAXLEN), NULL);
         WinSendDlgItemMsg(hwnd, DID_SEND_KEYSRV_STRN, EM_SETTEXTLIMIT,
                           MPFROMSHORT(CCHMAXPATH), NULL);
         WinSendDlgItemMsg(hwnd, DID_EDITOR_STRN, EM_SETTEXTLIMIT,
                           MPFROMSHORT(CCHMAXPATH), NULL);
         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_HOUR, SPBM_SETLIMITS,
                           (MPARAM) 100, (MPARAM) 0);
         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_MIN, SPBM_SETLIMITS,
                           (MPARAM) 59, (MPARAM) 0);
         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_SEC, SPBM_SETLIMITS,
                           (MPARAM) 59, (MPARAM) 0);
         h = ProfileData.Flags.CacheTime / 3600;
         m = (ProfileData.Flags.CacheTime % 3600) / 60;
         s = (ProfileData.Flags.CacheTime % 3600) % 60;

         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_HOUR, SPBM_SPINUP,
                           (MPARAM) h, NULL);
         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_MIN, SPBM_SPINUP,
                           (MPARAM) m, NULL);
         WinSendDlgItemMsg(hwnd, DID_CACHE_SPIN_SEC, SPBM_SPINUP,
                           (MPARAM) s, NULL);
         WinSetWindowText(WinWindowFromID(hwnd, DID_COMMENT_STRN),
                          TempData.ASCIIComment);
         WinSetWindowText(WinWindowFromID(hwnd, DID_SEND_KEYSRV_STRN),
                          TempData.SendKeyServer);
         WinSetWindowText(WinWindowFromID(hwnd, DID_EDITOR_STRN),
                          TempData.EditorFile);
         WinCheckButton(hwnd, DID_ENCRYPT_TO_SELF, TempData.Flags.PgpEncryptToSelf);
         WinCheckButton(hwnd, DID_ALWAYS_ON_TOP, TempData.Flags.AlwaysOnTop);
         WinCheckButton(hwnd, DID_SHOW_HINT_WINDOW, !TempData.Flags.SuppressHint);
         WinCheckButton(hwnd, DID_SMALL_ICONS, TempData.Flags.SmallIcons);
         if (!PGPKeysToolExists)
         {
           WinEnableWindow(WinWindowFromID(hwnd, DID_SEND_KEYSRV_GRP), FALSE);
           WinEnableWindow(WinWindowFromID(hwnd, DID_SEND_KEYSRV_STRN), FALSE);
         }
        break;

       default:
        return WinDefDlgProc (hwnd, msg, mp1, mp2);
      }

 return (MRESULT)FALSE;
}
static void enableArchiveCntrls(HWND hwnd, BOOL bEnable)
{

  /* Use archive bit */
  WinEnableWindow(WinWindowFromID(hwnd,IDCB_USEARCHIVEBIT),bEnable);

  /* Reset archive bit */
  WinEnableWindow(WinWindowFromID(hwnd, IDCB_RESETARCHIVEBIT),bEnable);

  /* Reset now push button */
  WinEnableWindow(WinWindowFromID(hwnd, IDPB_RESETNOW),bEnable);

}
コード例 #9
0
ファイル: clbx.c プロジェクト: OS2World/UTIL-WPS-Styler_2
MRESULT clbEnable(PCLBOX pclb, BOOL fl) {
   if (pclb) {
      pclb->is.enbl = fl? 1: 0;
      WinEnableWindow(pclb->hlbx, fl & pclb->is.chkon);
      WinEnableWindow(pclb->hentry, fl & pclb->is.chkon);
      WinEnableWindow(pclb->hadd, fl & pclb->is.chkon & pclb->is.addon);
      WinEnableWindow(pclb->hrem, fl & pclb->is.chkon & pclb->is.remon);
      WinEnableWindow(pclb->hfind, fl & pclb->is.chkon);
      WinRefreshWin(pclb->hwnd);
      if (pclb->hchk) WinRefreshWin(pclb->hchk);
   } /* endif */
   return (MRESULT)FALSE;
}
コード例 #10
0
ファイル: clbx.c プロジェクト: OS2World/UTIL-WPS-Styler_2
MRESULT clbControl(PCLBOX pclb, MPARAM mp1, PUSERBUTTON pub) {
   switch (SHORT1FROMMP(mp1)) {
      case FID_CAPTION:
         // click sulla checkbox cambia stato abilitazione altri componenti
         if ((pclb->fl & CLBXS_CHECK) &&
             (SHORT2FROMMP(mp1) == BN_CLICKED ||
              SHORT2FROMMP(mp1) == BN_DBLCLICKED)) {
            pclb->is.chkon = ((BOOL)pclb->pfbtn(pclb->hchk, BM_QUERYCHECK,
                                                MPVOID, MPVOID))? 1: 0;
            WinEnableWindow(pclb->hlbx, pclb->is.chkon);
            WinEnableWindow(pclb->hentry, pclb->is.chkon);
            WinEnableWindow(pclb->hadd, pclb->is.chkon & pclb->is.addon);
            WinEnableWindow(pclb->hrem, pclb->is.chkon & pclb->is.remon);
            WinEnableWindow(pclb->hfind, pclb->is.chkon);
            WinSendMsg(WinQueryWindow(pclb->hwnd, QW_OWNER), WM_CONTROL,
                 MPFROM2SHORT(pclb->id, CLBXN_CHECK), (MPARAM)pclb->is.chkon);
         } /* endif */
         break;
      case FID_LIST:
         clbControlLboxMsg(pclb, SHORT2FROMMP(mp1));
         break;
      case FID_ENTRY:
         clbControlEntryMsg(pclb, SHORT2FROMMP(mp1)); 
         break;
      case FID_ADD:
         if (SHORT2FROMMP(mp1) == BN_PAINT) {
            WdrawBtnBkgnd(pub, pclb->csdbtn, pclb->csdbtn, pclb->lbkgnd);
            drawAdd(pub, pclb->csdbtn);
            if (pub->fsState & BDS_DISABLED)
               drawDisBtn(pub, pclb->csdbtn, pclb->lbkgnd);
         } /* endif */
         break;
      case FID_REMOVE:
         if (SHORT2FROMMP(mp1) == BN_PAINT) {
            WdrawBtnBkgnd(pub, pclb->csdbtn, pclb->csdbtn, pclb->lbkgnd);
            drawRem(pub, pclb->csdbtn);
            if (pub->fsState & BDS_DISABLED)
               drawDisBtn(pub, pclb->csdbtn, pclb->lbkgnd);
         } /* endif */
         break;
      case FID_FIND:
         if (SHORT2FROMMP(mp1) == BN_PAINT) {
            WdrawBtnBkgnd(pub, pclb->csdbtn, pclb->csdbtn, pclb->lbkgnd);
            drawFind(pub, pclb->csdbtn);
            if (pub->fsState & BDS_DISABLED)
               drawDisBtn(pub, pclb->csdbtn, pclb->lbkgnd);
         } /* endif */
         break;
   } /* endswitch */
   return (MRESULT)FALSE;
}
コード例 #11
0
ファイル: mouseopt.c プロジェクト: OS2World/UTIL-WPS-Styler_2
// undo
static
VOID MouseOptUndo(HWND hwnd) {
   p->pd[p->idxPage].undo = 0;     // disabilita undo
   WinEnableWindow(p->swpCtls[4].hwnd, FALSE);
   // opzioni autofocus
   p->po->mou.focusAuto = p->ocur.mou.focusAuto = p->ou.mou.focusAuto;
   p->po->mou.focusDelay = p->ocur.mou.focusDelay = p->ou.mou.focusDelay;
   p->po->mou.focusNoDesk = p->ocur.mou.focusNoDesk = p->ou.mou.focusNoDesk;
   p->po->mou.focusNoTop = p->ocur.mou.focusNoTop = p->ou.mou.focusNoTop;
   p->po->mou.focusNoNew = p->ocur.mou.focusNoNew = p->ou.mou.focusNoNew;
   // opzioni pointer hiding
   p->po->mou.hide = p->ocur.mou.hide = p->ou.mou.hide;
   p->po->mou.hideDelay = p->ocur.mou.hideDelay = p->ou.mou.hideDelay;
   p->po->mou.hideNotOnMenu = p->ocur.mou.hideNotOnMenu = p->ou.mou.hideNotOnMenu;
   p->po->mou.hideNotOnBtn = p->ocur.mou.hideNotOnBtn = p->ou.mou.hideNotOnBtn;
   // opzione remap tasto 3 mouse
   p->po->mou.btn3dblClk = p->ocur.mou.btn3dblClk = p->ou.mou.btn3dblClk;
   p->po->mou.btn3title = p->ocur.mou.btn3title = p->ou.mou.btn3title;
   // opzione mode to the focus window
   p->po->mou.moveToFocus = p->ocur.mou.moveToFocus = p->ou.mou.moveToFocus;
   p->po->mou.moveToNew = p->ocur.mou.moveToNew = p->ou.mou.moveToNew;
   p->po->mou.moveToDlg = p->ocur.mou.moveToDlg = p->ou.mou.moveToDlg;
   p->po->mou.moveNotBtnles = p->ocur.mou.moveNotBtnles = p->ou.mou.moveNotBtnles;
   p->po->mou.moveSteps = p->ocur.mou.moveSteps = p->ou.mou.moveSteps;
   // aggiorna controlli dialogo
   MouseOptInit(hwnd, &p->ocur);
}
コード例 #12
0
/*--------------------------------------------------
 * Enables the window to accept keyboard and mouse
 * input
 *-------------------------------------------------*/
PMWindow& PMWindow::enable( BOOL state )
{
  if( !WinEnableWindow( handle(), state ))
    PM_THROW_GUIERROR();

  return *this;
}
コード例 #13
0
MRESULT _System DrvEjectAllDlg( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 
{
    switch (msg) {

        case WM_INITDLG:
            DrvInitEjectAllDlg( hwnd, mp2);
            return (0);

        case WM_SAVEAPPLICATION:
            WinStoreWindowPos( CAMINI_APP, CAMINI_EJECTPOS, hwnd);
            return (0);

        case WM_SYSCOMMAND:
            if (SHORT1FROMMP( mp1) == SC_CLOSE)
                return (WinSendMsg( hwnd, WM_COMMAND, (MP)IDC_NO, 0));
            break;

        case WM_COMMAND:
            if (mp1 == (MP)IDC_YES) {
                WinEnableWindow( WinWindowFromID( hwnd, IDC_YES), FALSE);
                WinEnableWindow( WinWindowFromID( hwnd, IDC_NO), FALSE);
                LoadDlgItemString( hwnd, IDC_TEXT1, MSG_Ejecting);
                LoadDlgItemString( hwnd, IDC_TEXT4, MSG_ThisMayTake);
                DrvEjectAllDrives( hwnd);
            }
            WindowClosed( WinQueryWindowUShort( hwnd, QWS_ID));
            WinDestroyWindow( hwnd);
            return (0);

        case WM_FOCUSCHANGE:
            if (SHORT1FROMMP(mp2) && !WinIsWindowEnabled( hwnd)) {
                WinPostMsg( WinQueryWindow( hwnd, QW_OWNER),
                            CAMMSG_FOCUSCHANGE, 0, 0);
                return (0);
            }
            break;

        case WM_DESTROY:
            WinPostMsg( WinQueryWindow( hwnd, QW_OWNER), CAMMSG_EXIT,
                        (MP)TRUE, 0);
            break;

    }

    return (WinDefDlgProc( hwnd, msg, mp1, mp2));
}
コード例 #14
0
ULONG clbEnableAdd(PCLBOX pclb) {
   BOOL notempty = WinQueryWindowTextLength(pclb->hentry)? 1: 0;
   if (notempty != pclb->is.addon) {
      pclb->is.addon = notempty;
      WinEnableWindow(pclb->hadd, pclb->is.addon);
   } // end if
   return CLBXN_ENCHANGE;
}
コード例 #15
0
ファイル: dlg.c プロジェクト: komh/hanedit2
int dlgFind_SetButtonFocus(HWND hwnd)
{
HWND hwndBtnFind = WinWindowFromID(hwnd,IDB_FIND);
HWND hwndBtnReplace = WinWindowFromID(hwnd,IDB_REPLACE);
HWND hwndBtnReplaceFind = WinWindowFromID(hwnd,IDB_REPLACEFIND);
HWND hwndBtnReplaceAll = WinWindowFromID(hwnd,IDB_REPLACEALL);
HWND hwndBtnClose = WinWindowFromID(hwnd,DID_OK);
HWND hwndFocus;

HWND hwndFind = WinWindowFromID(hwnd,IDHEF_FIND);
int findLen=0;
char *findStr = NULL;

    findLen = WinQueryWindowTextLength(hwndFind);
//  findLen = (int)WinSendMsg(hwndFind,HEM_QUERYTEXTLENGTH,0,0);
    findStr = malloc(findLen+1);
#ifdef DEBUG
    assert(findStr!=NULL);
#endif
    if (findStr==NULL) return 0;
    WinQueryWindowText(hwndFind,findLen+1,findStr);
//  WinSendMsg(hwndFind,HEM_QUERYTEXT,findStr,0);

    hwndFocus = WinQueryFocus(HWND_DESKTOP);
    if ((hwndFocus!=hwndBtnFind)&&
        (hwndFocus!=hwndBtnReplace)&&
        (hwndFocus!=hwndBtnReplaceFind)&&
        (hwndFocus!=hwndBtnReplaceAll)&&
        (hwndFocus!=hwndBtnClose))
        {
        if (strlen(findStr)>0)
            {
            WinEnableWindow(hwndBtnFind,TRUE);
            WinSendMsg(hwndBtnFind,BM_SETDEFAULT,MPFROMLONG(TRUE),0);
            WinSendMsg(hwndBtnClose,BM_SETDEFAULT,MPFROMLONG(FALSE),0);
            } else {
            WinEnableWindow(hwndBtnFind,FALSE);
            dlgFind_SetFound(hwnd,FALSE);
            WinSendMsg(hwndBtnFind,BM_SETDEFAULT,MPFROMLONG(FALSE),0);
            WinSendMsg(hwndBtnClose,BM_SETDEFAULT,MPFROMLONG(TRUE),0);
            }
        return TRUE;
        }
    return FALSE;
}
コード例 #16
0
void OCL::disableDialogItem(HWND hwnd, ULONG usDialogIDs[], ULONG usItemCount, ULONG ulStyle)
{
    ULONG  usTemp;

    if(ulStyle&WS_DISABLED)
        for(usTemp=0; usTemp<usItemCount; usTemp++)
            WinEnableWindow(WinWindowFromID(hwnd, usDialogIDs[usTemp]), FALSE);
    else
        for(usTemp=0; usTemp<usItemCount; usTemp++)
            WinEnableWindow(WinWindowFromID(hwnd, usDialogIDs[usTemp]), TRUE);
    if(ulStyle&WS_VISIBLE)
        for(usTemp=0; usTemp<usItemCount; usTemp++)
            WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_SHOW);
    else
        for(usTemp=0; usTemp<usItemCount; usTemp++)
            WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_HIDE);
    return;
}
コード例 #17
0
VOID clbControlLboxMsg(PCLBOX pclb, ULONG nmsg) {
   SHORT item;
   switch (nmsg) {
      // doppio click su item listbox
      case LN_ENTER:
         nmsg = CLBXN_LNENTER;
         if (pclb->fl & CLBXS_ENTRREM) {          // rimuove item
            item = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYSELECTION,
                                             (MPARAM)LIT_FIRST, MPVOID);
            pclb->pflbx(pclb->hlbx, LM_DELETEITEM, (MPARAM)item, MPVOID);
            pclb->is.remon = 0;
            WinEnableWindow(pclb->hrem, FALSE);
         } else if (pclb->fl & CLBXS_ENTREDIT) {  // edita item
            SHORT cb;
            PSZ psz = NULL;
            item = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYSELECTION,
                                             (MPARAM)LIT_FIRST, MPVOID);
            cb = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYITEMTEXTLENGTH,
                                    (MPARAM)item, MPVOID);
            if (cb != LIT_ERROR &&
                NULL != (psz = (PSZ)malloc(++cb)) &&
                0 != (cb = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYITEMTEXT,
                               MPFROM2SHORT(item, cb), (MPARAM)psz)))
               WinSetWindowText(pclb->hentry, psz);
            free(psz);
         } /* endif */
         break;
      // selezione item listbox
      case LN_SELECT:
         nmsg = CLBXN_LNSELECT;
         pclb->is.remon = (LIT_NONE == (item =
                         (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYSELECTION,
                                     (MPARAM)LIT_FIRST, MPVOID)))? 0: 1;
         WinEnableWindow(pclb->hrem, pclb->is.remon);
         break;
      // case LN_SETFOCUS: nmsg = CLBXN_LNSETFCS; break;
      // case LN_KILLFOCUS: nmsg = CLBXN_LNLOSEFCS; break;
      // case LN_SCROLL: nmsg = CLBXN_LNSCROLL; break;
      default: nmsg = 0;
   } /* endswitch */
   if (nmsg)
      WinSendMsg(WinQueryWindow(pclb->hwnd, QW_OWNER), WM_CONTROL,
                 MPFROM2SHORT(pclb->id, nmsg), (MPARAM)pclb->hwnd);
}
コード例 #18
0
static  void    setOptions(HWND hwndDlg)
{
    UCHAR   title[256] ;

    sprintf(title, "Session Options for <%s>", SessServerName) ;
    WinSetWindowText(hwndDlg, title) ;

    setFormat(hwndDlg) ;
    setEncode(hwndDlg) ;

    setButton(hwndDlg, IDD_OPT_SHARED, SessOptShared)    ;
    setButton(hwndDlg, IDD_OPT_VONLY,  SessOptViewonly)  ;
    setButton(hwndDlg, IDD_OPT_DEICON, SessOptDeiconify) ;

    if (! initialSetup) {
        WinEnableWindow(WinWindowFromID(hwndDlg, IDD_OPT_FORMAT), FALSE) ;
        WinEnableWindow(WinWindowFromID(hwndDlg, IDD_OPT_SHARED), FALSE) ;
    }
}
コード例 #19
0
ファイル: clbx.c プロジェクト: OS2World/UTIL-WPS-Styler_2
MRESULT clbCommand(PCLBOX pclb, ULONG id) {
   HWND hOwner = WinQueryWindow(pclb->hwnd, QW_OWNER);
   SHORT i = 0;
   PSZ psz;
   switch (id) {
      case FID_ADD:
         // alloca buffer per testo entryfield
         if (!(psz = (PSZ)malloc(pclb->cchef + 1))) break;
         WinQueryWindowText(pclb->hentry, pclb->cchef + 1, psz);
         if (!WinSendMsg(hOwner, WM_CONTROL,
                         MPFROM2SHORT(pclb->id, CLBXN_ADD), (MPARAM)psz)) {
            SHORT ins;
            // controlla che la stringa non sia gi… presente
            if (pclb->fl & CLBXS_NODUP &&
                LIT_NONE != (SHORT)pclb->pflbx(pclb->hlbx, LM_SEARCHSTRING,
                                               MPFROM2SHORT(0, LIT_FIRST),
                                               (MPARAM)psz)) {
               free(psz);                         
               break;
            } // end if
            // se stile lo richiede converte stringa in uppercase
            if (pclb->fl & CLBXS_INSUPPER) WinUpper(pclb->hab, 0, 0, psz);
            // setta flag inserzione secondo stile
            if (pclb->fl & CLBXS_INSSORTUP) i = LIT_SORTASCENDING;
            else if (pclb->fl & CLBXS_INSSORTDN) i = LIT_SORTDESCENDING;
            else if (pclb->fl & CLBXS_INSEND) i = LIT_END;
            ins = (SHORT)pclb->pflbx(pclb->hlbx, LM_INSERTITEM,
                                     (MPARAM)i, (MPARAM)psz);
            WinSetWindowText(pclb->hentry, "");
            WinSendMsg(hOwner, WM_CONTROL,
                       MPFROM2SHORT(pclb->id, CLBXN_ADDED), (MPARAM)ins);
         } // end if
         free(psz);
         break;
      case FID_REMOVE:
         i = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYSELECTION,
                                (MPARAM)LIT_FIRST, MPVOID);
         if (!WinSendMsg(hOwner, WM_CONTROL, MPFROM2SHORT(pclb->id, CLBXN_REM),
                         (MPARAM)i)) {
            while (i >= 0) {
               pclb->pflbx(pclb->hlbx, LM_DELETEITEM, (MPARAM)i, MPVOID);
               i = (SHORT)pclb->pflbx(pclb->hlbx, LM_QUERYSELECTION,
                                      (MPARAM)LIT_FIRST, MPVOID);
            } /* end while */
         } /* end if */
         pclb->is.remon = 0;
         WinEnableWindow(pclb->hrem, FALSE);
         break;
      case FID_FIND:
         WinSendMsg(hOwner, WM_CONTROL, MPFROM2SHORT(pclb->id, CLBXN_FIND),
                    (MPARAM)pclb->hwnd);
         break;
   } /* endswitch */
   return (MRESULT)FALSE;
}
コード例 #20
0
/*
 *  Empty Client window of messages
 */
VOID MainPurgeWindow()
{

   sVscrollMax = 0;
   sVscrollPos = 0;
   WinSendMsg (hwndVscroll, SBM_SETSCROLLBAR,
                            MPFROM2SHORT (sVscrollPos, 0),
                            MPFROM2SHORT (0, sVscrollMax)) ;

   WinEnableWindow (hwndVscroll, FALSE) ;
   WinInvalidateRect(hwndMain, NULL, FALSE);
}
コード例 #21
0
void DConfirmDlg::SetupWindow()
{
	TDialog::SetupWindow();

	// If confirm all, then other checkboxes are disabled.

	if(bOldConfirmAll)
	{
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_DELETE), 0);
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_REPLACE), 0);
		WinEnableWindow(GetDlgItem(IDC_CONFIRM_COPY), 0);

		CheckDlgButton(IDC_CONFIRM_ALL, TRUE);
	}
	else
	{
		CheckDlgButton(IDC_CONFIRM_DELETE, bOldConfirmDelete);
		CheckDlgButton(IDC_CONFIRM_COPY, bOldConfirmCopy);
		CheckDlgButton(IDC_CONFIRM_REPLACE, bOldConfirmReplace);
	}
}
コード例 #22
0
BOOL SaveBedPrf(PAPPDATA pad) {
   PBEDFILE pbf;
   ULONG i, cbfndrepl, cbfiles, cstrings, cfiles;
   PSZ pszerr = NULL;
   PSZ pflist;
   HWND hlfile = WinWindowFromID(pad->hMain, LB_FILE);
   HWND hlstr = WinWindowFromID(pad->hMain, LB_STRINGS);
   pad->is.working = 1;
   WinEnableWindow(pad->hMain, FALSE);
   // calcola allocazione approssimativa per la lista di sostituzioni
   cstrings = wLboxQueryItemCount(hlstr);
   cbfndrepl = cbFndReplList(hlstr, cstrings);
   // calcola dimensione lista file (aggiunge 1 x flag ricorsivit… e 1 per term
   cfiles = wLboxQueryItemCount(hlfile);
   for (i = cbfiles = 0; i < cfiles; ++i)
      cbfiles += WLboxQueryItemTextLength(hlfile, i) + 2;
   cbfiles++;  // la lista viene terminata con un doppio zero
   // alloca la memoria necessaria
   if (!(pbf = malloc(cbfndrepl + cbfiles + 8)))
      {pszerr = SZERR_ALLOC; goto end;}
   pbf->sign = BEDPRFID1;      // setta ID file
   // inizializza lista di sostituzioni
   if (!(cbfndrepl = getFndReplData(hlstr, pad, &pbf->frl, cstrings)))
      {pszerr = SZERR_ALLOC; goto end;}
   pbf->offset = 8 + cbfndrepl;
   // inizializza lista file
   getFileListData(hlfile, (PSZ)((PBYTE)pbf + pbf->offset), cfiles);
   if (!ioPsz2f(pad->achload, (PSZ)pbf, cbfndrepl + cbfiles + 8))
      {pszerr = SZERR_SAVEPRF; goto end;}
end:
   if (pszerr) Wprint(pad->hMain, pszerr, 0);
   if (pbf) {free(pbf);}
   WinEnableWindow(pad->hMain, TRUE);
   pad->is.working = 0;
   return TRUE;
}
コード例 #23
0
ファイル: dlgwin.c プロジェクト: OS2World/UTIL-WPS-Styler_2
VOID MainWinUndo(HWND hwnd) {
   p->pd[p->idxPage].undo = 0;     // disabilita undo
   WinEnableWindow(p->swpCtls[4].hwnd, FALSE);
   // Use Smart Windows Font
   p->po->dlg.font = p->ocur.dlg.font = p->ou.dlg.font;
   // Override PresParms
   p->po->dlg.ovrPP = p->ocur.dlg.ovrPP = p->ou.dlg.ovrPP;
   // Selected Font
   strcpy(p->po->dlg.achFont, p->ou.dlg.achFont);
   strcpy(p->ocur.dlg.achFont, p->ou.dlg.achFont);
   p->po->dlg.cbFont = strlen(p->po->dlg.achFont) + 1;
   // aggiorna controlli dialogo
   MainWinInit(hwnd, &p->ocur);
   _stlrMsgPostAll(STLR_SETFRAMEFONT, 0);
}
コード例 #24
0
 static void control(HWND hwnd, USHORT id, USHORT notify, MPARAM mp2)
 {
    HWND h = WinWindowFromID(hwnd,id);

    id -= DLG_ELEMENT_ID;

    switch(id)
    {
    case MSGID_HISTORY:
       containerAction(hwnd,notify,(void *) mp2);
       break;

    case MSGID_EDITBOX:
       if(notify == MLN_CHANGE)
          WinEnableWindow(CHILD_WINDOW(hwnd,MSGID_SENDBUTTON), (WinQueryWindowTextLength(h) > 0) );
       break;
    }
 }
コード例 #25
0
VOID MainUpdateMsg(HWND hwnd,
                   CHAR PipeMsgs[MAX_MESSAGES][MESSAGE_LEN],
                   unsigned int index,
                   SHORT sTotalMsgs)
{
   RECTL rclInvalid;

   /* if it will fit in the window */
   if (sTotalMsgs <= cyClient/cyChar + sVscrollPos + 1)
   {
      rclInvalid.yBottom = max(0, cyClient - sTotalMsgs * cyChar);
      rclInvalid.yTop = (cyClient - (sTotalMsgs - sVscrollPos - 1) * cyChar);
      rclInvalid.xLeft = 0;
      rclInvalid.xRight = cxClient;
      WinInvalidateRect(hwnd, &rclInvalid, FALSE);
      MainPaint(hwnd, PipeMsgs, index, sTotalMsgs);
   }

   /* if lines exceed window */
   if (sTotalMsgs > cyClient/cyChar)
   {
      WinEnableWindow (hwndVscroll, TRUE) ;
      sVscrollMax = sTotalMsgs - cyClient / cyChar;
      sVscrollPos = min (sVscrollPos, sVscrollMax) ;

      WinSendMsg (hwndVscroll, SBM_SETSCROLLBAR,
                               MPFROM2SHORT (sVscrollPos, 0),
                               MPFROM2SHORT (0, sVscrollMax)) ;

      /* if new msg is just off screen */
      if (sTotalMsgs == cyClient/cyChar + sVscrollPos + 1)
      {
         MainVertScroll(hwnd, MPFROM2SHORT(0, SB_LINEDOWN));
      }

      /* tell user message was received */
      else
      {
         DosBeep(1000, 100);
      }
   }
}
コード例 #26
0
ファイル: dlg.c プロジェクト: komh/hanedit2
void dlgFind_wmInitDlg(HWND hwnd)
{
HWND hwndBtnFind = WinWindowFromID(hwnd,IDB_FIND);
HWND hwndFind = WinWindowFromID(hwnd,IDHEF_FIND);
HWND hwndReplace = WinWindowFromID(hwnd,IDHEF_REPLACE);
ULONG han_type = (ULONG)WinSendMsg(hwndHMLE,HMLM_QUERYHANTYPE,0,0);

#ifdef DEBUG
//  WinSendMsg(hwndFind,HEM_DUMP,(MPARAM)stderr,0);
//  WinSendMsg(hwndHMLE,HMLM_DUMP,(MPARAM)stderr,0);
#endif

    WinSendMsg(hwndFind,HEM_SETHIA,MPFROMLONG(hwndHIA),0);
    WinSendMsg(hwndReplace,HEM_SETHIA,MPFROMLONG(hwndHIA),0);

    WinSendMsg(hwndFind,HEM_SETHANTYPE,MPFROMLONG(han_type),0);
    WinSendMsg(hwndReplace,HEM_SETHANTYPE,MPFROMLONG(han_type),0);

    WinEnableWindow(hwndBtnFind,FALSE);
    dlgFind_SetFound(hwnd,FALSE);
}
コード例 #27
0
ファイル: dlg-fileio.c プロジェクト: bobsummerwill/VICE
static void FillSBox(HWND hwnd, int item)
{
    const HWND sbox = WinWindowFromID(hwnd, DID_SUBACTION_CB);
    const int nentry = WinDlgLboxSelectedItem(hwnd, DID_ACTION_CB);

    const FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER);
    const action_t *action = fdlg->fl & FDS_OPEN_DIALOG ? LoadAction : SaveAction;
    const subaction_t *subact = action[nentry].subact;

    int i = 0;

    //
    // fill entries in comboboxes and select starting point
    //
    WinLboxEmpty(sbox);

    while (subact[i].action) {
        WinInsertLboxItem(sbox, LIT_END, subact[i++].action);
    }
    WinSendMsg(sbox, LM_SELECTITEM, (MPARAM)item, (MPARAM)TRUE);

    WinEnableWindow(sbox, action[nentry].enabled);
}
コード例 #28
0
/*------------------------------------------------------------------------*/
void CanvScrollBar(WINDOWINFO *pwi, BOOL bSetForm)
{

   if (bSetScrollbars)
      return;

   bSetScrollbars = TRUE;

   view.sVscrollMax = max (0, pwi->cyClient - view.cyCanvas);
   view.sVscrollPos = min (view.sVscrollPos, view.sVscrollMax);

   WinSendMsg (view.hwndVscroll, SBM_SETSCROLLBAR,
               MPFROM2SHORT (view.sVscrollPos,0),
               MPFROM2SHORT (0,view.sVscrollMax));

   WinSendMsg(view.hwndVscroll, SBM_SETTHUMBSIZE,
              MPFROM2SHORT(view.cyCanvas,pwi->cyClient), 0);

   view.sHscrollMax  = max ( 0, pwi->cxClient - view.cxCanvas);
   view.sHscrollPos  = min (view.sHscrollPos, view.sHscrollMax);

   WinSendMsg (view.hwndHscroll, SBM_SETSCROLLBAR,
               MPFROM2SHORT (view.sHscrollPos,0),
               MPFROM2SHORT (0,view.sHscrollMax));


   WinSendMsg(view.hwndHscroll, SBM_SETTHUMBSIZE,
              MPFROM2SHORT(view.cxCanvas,pwi->cxClient), 0);

   WinEnableWindow (view.hwndHscroll, view.sHscrollMax ? TRUE : FALSE);

   if (bSetForm )
   {
      positionWindowInViewPort(pwi);
   }
   bSetScrollbars = FALSE;
}
コード例 #29
0
ファイル: progress.c プロジェクト: OS2World/UTIL-WPS-Styler_2
MRESULT EXPENTRY ProgressDlgProc(HWND hwnd,
                                 ULONG msg,
                                 MPARAM mp1,
                                 MPARAM mp2) {
   switch (msg) {
   // init -----------------------------------------------------------------
      case WM_INITDLG: {
         PPRGSAPPDATA pad = (PPRGSAPPDATA)mp2;
         ULONG ul;
         POINTL aptl[] = {{1, 36}, {220, 24}}; 
         WinSetWindowPtr(hwnd, 0L, (PVOID)mp2);
         WinSetWindowText(hwnd, pad->ppd->pszTitle);
         // dimensioni-coordinate varie
         pad->cyTitle = uGetSval(SV_CYTITLEBAR);
         pad->hButton = WinWindowFromID(hwnd, BTN_STOP);
         WinQueryWindowPos(pad->hButton, &pad->swp);
         WinQueryWindowRect(hwnd, &pad->rcl);
         WinMapDlgPoints(hwnd, aptl, 2, TRUE);
         pad->sldd.cbSize = sizeof(SLDCDATA);
         pad->sldd.usScale1Increments = 11;
         pad->sldd.usScale1Spacing = (pad->rcl.xRight - 2 * pad->cyTitle) / 10 - 1;
         pad->hProgress = WinCreateWindow(hwnd, WC_SLIDER, (PSZ)NULL,
                                          SLS_BOTTOM | SLS_OWNERDRAW |
                                          SLS_READONLY | SLS_RIBBONSTRIP |
                                          WS_VISIBLE, 3, aptl[0].y,
                                          pad->rcl.xRight - 6, aptl[1].y,
                                          hwnd, HWND_TOP, SLDR_PROGRESS,
                                          (PVOID)&pad->sldd, NULL);
         // controlla versione S.O. e setta font slider e bottone
         DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR,
                         &ul, sizeof(ULONG));
         if (ul < 40) {
            WinSetPresParam(pad->hProgress, PP_FONTNAMESIZE, 7, "8.Helv");
            WinSetPresParam(pad->hButton, PP_FONTNAMESIZE, 7, "8.Helv");
         } else {
            WinSetPresParam(pad->hProgress, PP_FONTNAMESIZE, 11, "9.WarpSans");
         } /* endif */
         // rileva larghezza progress bar
         pad->cxPrgs = LOUSHORT((ULONG)WinSendMsg(pad->hProgress,
                                                 SLM_QUERYSLIDERINFO,
                                         MPFROM2SHORT(SMA_SHAFTDIMENSIONS, 0),
                                         MPVOID)) - 6;
         // setta altezza barra pari a altezza barra titolo
         WinSendMsg(pad->hProgress, SLM_SETSLIDERINFO,
                    MPFROM2SHORT(SMA_SHAFTDIMENSIONS, 0), (MPARAM)pad->cyTitle);
         // setta testo e altezza barra graduata
         WinSendMsg(pad->hProgress, SLM_SETTICKSIZE,
                    MPFROM2SHORT(SMA_SETALLTICKS, pad->cyTitle / 3), MPVOID);
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)0, (MPARAM)"0%");
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)5, (MPARAM)"50%");
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)10, (MPARAM)"100%");
         // testo iniziale progesso e elapsed time:
         sprintf(pad->achElapsed, "%s: 00:00:00", pad->ppd->pszTime);
         WinSetDlgItemText(hwnd, TXT_TIME, pad->achElapsed);
         sprintf(pad->achCurPrg, "%s:   0%%", pad->ppd->pszPrgrss);
         WinSetDlgItemText(hwnd, TXT_PERCENT, pad->achCurPrg);
         // se specificato setta nuovo font dialogo
         if (pad->ppd->fl & PRGSS_FONT)
            WsetDlgFonts(hwnd, NULLHANDLE, pad->ppd->FontNameSize);
         // posiziona finestra al centro Parent window
         if (pad->ppd->fl & PRGSS_CENTER) {
            WcenterInWindow(hwnd, pad->ppd->hPos);
         } else {
            SWP swp;
            swp.hwnd = pad->ppd->hPos;
            swp.x = pad->ppd->ptl.x;
            swp.y = pad->ppd->ptl.y;
            swp.cx = swp.cy = 0;
            swp.fl = SWP_MOVE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER;
            swp.hwndInsertBehind = HWND_TOP;
            WsetRelativePos(hwnd, &swp);
         } // end if
         // notifica creazione dialogo
         WinPostMsg(pad->ppd->hNotify, WM_PRGRSREADY, (MPARAM)hwnd, (MPARAM)0);
         break;
      } // end case WM_INITDLG
      case WM_DRAWITEM:
         if (((POWNERITEM)mp2)->idItem == SDA_RIBBONSTRIP) {
            PPRGSAPPDATA pad = GetData(hwnd);
            if (pad->ppd->fl & PRGSS_BITMAP) {   // se deve disegnare la bitmap
               RECTL rcl = {0, 0, ((POWNERITEM)mp2)->rclItem.xRight -
                            ((POWNERITEM)mp2)->rclItem.xLeft, pad->cyTitle};
               POINTL ptl = {((POWNERITEM)mp2)->rclItem.xLeft,
                             ((POWNERITEM)mp2)->rclItem.yBottom};
               while (ptl.x < ((POWNERITEM)mp2)->rclItem.xRight) {
                  WinDrawBitmap(((POWNERITEM)mp2)->hps, pad->ppd->hbmp, &rcl,
                                &ptl, 0L, 0L, DBM_NORMAL);
                  ptl.x += pad->cxbmp;
                  rcl.xRight = ((POWNERITEM)mp2)->rclItem.xRight - ptl.x;
               } /* endwhile */
            } else {                       // colore
               GpiCreateLogColorTable(((POWNERITEM)mp2)->hps,
                                      0, LCOLF_RGB, 0, 0, NULL);
               WinFillRect(((POWNERITEM)mp2)->hps,
                           &((POWNERITEM)mp2)->rclItem, pad->ppd->color);
            } /* endif */
            return (MRESULT)TRUE;
         } // end if
         break;
      case PRGSM_INCREMENT: { // notifica incremento
         PPRGSAPPDATA pad = GetData(hwnd);
         ULONG ul;
         pad->incr = (ULONG)mp1;
         WinSendMsg(pad->hProgress,
                    SLM_SETSLIDERINFO,
                    MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                    (MPARAM)((pad->incr * pad->cxPrgs) / 1000));
         ul = WinGetCurrentTime(pad->hab) / 1000;
         if (pad->current != ul) {
            pad->current = ul;
            pad->elapsed = pad->current - pad->start;
            sprintf(pad->achElapsed, "%s: %02d:%02d:%02d", pad->ppd->pszTime,
                    pad->elapsed / 3600, (pad->elapsed % 3600) / 60,
                    pad->elapsed % 60);
            WinSetDlgItemText(hwnd, TXT_TIME, pad->achElapsed);
         } // end if
         if (pad->ulCurPrg != (ul = (ULONG)mp1 / 10)) {
            pad->ulCurPrg = ul;
            sprintf(pad->achCurPrg, "%s: %3d %%",
                    pad->ppd->pszPrgrss, pad->ulCurPrg);
            WinSetDlgItemText(hwnd, TXT_PERCENT, pad->achCurPrg);
         } // end if
         return (MRESULT)pad->flStop;
      } // end case PRGSM_INCREMENT
      case PRGSM_MSG:
         return (MRESULT)Wprint(hwnd, (PSZ)mp1, (ULONG)mp2);
      case WM_COMMAND:
         if ((ULONG)mp1 == BTN_STOP) {
            PPRGSAPPDATA pad = GetData(hwnd);
            pad->flStop = TRUE;
            WinEnableWindow(pad->hButton, FALSE);
         } /* endif */
         break;
      case WM_CLOSE: {
         PPRGSAPPDATA pad = GetData(hwnd);
         // se elaborazione ancora in corso mostra messaggio
         if (pad->incr > 0 && pad->incr < 1000) {
            PSZ psz;
            if (!(psz = (PSZ)malloc(1024)) ||
            // se la notify window restituisce NULL
                (BOOL)WinSendMsg(pad->ppd->hNotify, WM_PRGRSQUIT,
                                 (MPARAM)psz, MPVOID) ||
            // o se la chiusura Š confermata
                Wprint(hwnd, psz, PMPRNT_QUERY)) {
               WinPostMsg(hwnd, PRGSM_END, MPVOID, MPVOID);
               WinPostMsg(pad->hOwner, WM_CLOSE, MPVOID, MPVOID);
            // se nel frattempo Š terminato
            } else {
               pad->qQuit.msg = 0;
               if (!pad->incr || pad->incr >= 1000) {
                  WinPostMsg(hwnd, PRGSM_END, MPVOID, MPVOID);
               } else if ((BOOL)mp1) {
                  WinCancelShutdown((HMQ)WinQueryWindowULong(hwnd, QWL_HMQ),
                                    FALSE);
               } // end if
            } // end if
            free (psz);
         } /* endif */
      }  break;
      default:
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
   } /* endswitch */
   return (MRESULT)FALSE;
}
/*************************************************************************
 *
 * Name       : WinProc(hwnd, msg, mp1, mp2)
 *
 * Description: Processes the messages sent to the main client
 *              window.  This routine processes the basic
 *              messages all client windows should process.
 *
 * Concepts   : This procedure provides service routines for the general
 *              PM events (messages) that PM sends to the window, as well
 *              as the user initiated events (messages) that are generated
 *              when the user selects the action bar and pulldown menu
 *              controls or the corresponding keyboard accelerators.
 *
 *              The switch statement shown below distributes the window
 *              messages to the respective message service routines, which
 *              are set apart by the case statements.  The window
 *              procedures must provide an appropriate service routine for
 *              its end user initiated messages, as well as the general PM
 *              messages (like the WM_CLOSE message). If a message is sent
 *              to this procedure for which there is no programmed case
 *              clause (i.e., no service routine), the message is defaulted
 *              function WinDefWindowProc, where it is disposed of by PM.
 *
 *              Time-consuming tasks are posted to the object window where
 *              they can be performed without the 1/10 second turnaround
 *              time imposed on the client window. When the object window
 *              is busy, the client window is usually disabled. The object
 *              window then posts an acknowledgement
 *              back to the client when the lengthy task is completed.
 *
 *              Cases under the big switch appear in alphabetical order.
 *
 *  API's     :   WinLoadString
 *                WinMessageBox
 *                WinQueryWindowULong
 *                WinSendMsg
 *                WinPostMsg
 *                WinIsWindowEnabled
 *                WinSetPointer
 *                WinQuerySysPointer
 *                WinBeginPaint
 *                WinQueryWindowRect
 *                WinFillRect
 *                WinEndPaint
 *                WinInvalidateRect
 *                WinSetWindowText
 *                GpiDrawChain
 *                GpiConvert
 *                GpiSetDefaultViewMatrix
 *                GpiAssociate
 *                GpiDestroyPS
 *                GpiDeleteBitmap
 *                GpiDeleteMetafile
 *
 * Parameters : HWND         window handle
 *              ULONG        message
 *              MPARAM       message parameter 1
 *              MPARAM       message parameter 2
 *
 * Result     : MRESULT      message result
 *
 *************************************************************************/
MRESULT EXPENTRY WinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   BOOL                bOK;
   PMAIN_PARM       pmp;
   HPS                 hps;
   RECTL              rectl;
   PSZ                 psz;
   CHAR               szWork[ LEN_WORKSTRING ];
   SHORT              sStep;
   ULONG              ulWork;
   SHORT              sNewPos;
   ULONG              rc;

   switch(msg)
   {
   case WM_CLOSE:
      /* obtain the main parameter pointer from window words */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
#ifdef OSA_AWARE
      /* Do OSA termination */
      TerminateOSA(hwnd);
#endif
      if( pmp->fBusy )
      {
         /* OK to close when object window is busy?  */
         WinLoadString( pmp->hab, (HMODULE)NULLHANDLE,
                   ERRMSG_CLOSE_QUESTION, LEN_WORKSTRING, szWork );
         ulWork = WinMessageBox( HWND_DESKTOP,
                                 pmp->hwndFrame,
                                 szWork,
                                 pmp->pszTitle,
                                 (USHORT)0,
                                 MB_YESNOCANCEL | MB_MOVEABLE |
                                 MB_CUANOTIFICATION | MB_APPLMODAL);

         if( ulWork == MBID_YES )
         {
            /* close down the application in spite of being busy */
            pmp->fCancel = TRUE;
            /* disable client during exit */
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0 , (MPARAM)0  );
            /* start a watchdog timer to ensure a timely death */
            WinStartTimer( pmp->hab, hwnd, ID_DEATH_TIMER, LEN_DEATH_TIMER );
            /* Tell object window to close, quit, and post me a WM_QUIT */
            WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 );
         }
      }
      else
      {
         /* not busy, so initiate closure by telling object window to close */
         WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 );
      }
      return (MRESULT)NULL;


   case WM_COMMAND:
      /* do menu activities; see menu.c */
      return Menu( hwnd, msg, mp1, mp2 );


   case WM_CREATE:

      /*
       * Do one-time, startup processing in PRTCREAT.C.
       * This function allocates the pmp, a pointer to the program's
       * main parameters. See the declaration of this block of
       * parameters in PRTSAMP.H, the MAIN_PARM structure.
       *
       * The Create() function allocates this structure and
       * begins to initialize it. Throughout all the code, the pmp->
       * pointer is usually obtainable with a call to WinQueryWindowULong.
       * Window word space for this pointer was reserved on the call
       * to WinRegisterClass.
       *
       * Create() allocates, initializes, and stores the pmp pointer
       * in the client window words. It then starts thread 2 of the
       * application on which the object window operates. The pmp
       * pointer is passed to thread 2 with _beginthread in PRTCREAT.C.
       * The pmp is passed to the object window on the call to
       * WinCreateWindow in PRTOBJ.C. Finally, the object window stores
       * the pmp in its window words under the WM_CREATE case of the
       * ObjectWinProc in PRTOBJ.C.
       *
       */

      Create( hwnd );
#ifdef OSA_AWARE
      /* Do OSA Initialization */
      InitOSA(hwnd);
#endif

#ifdef OSA_AWARE
        /* Generate a Apple Event - Open Application to myself  (Workaround) */
        rc =  GenerateOSAEvent(hwnd, msg, MPFROMSHORT(IDM_AEOPENAPP), mp2);
#endif
      return (MRESULT)NULL;


   case WM_HSCROLL:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* Compute some fraction of scroll bar range for a unit of scrolling. */
      sStep  = pmp->sHScrollRange / 50;

      switch( SHORT2FROMMP( mp2 ))
      {
      case SB_LINELEFT:
         pmp->sHScrollPos -= sStep;
         break;
      case SB_PAGELEFT:
         pmp->sHScrollPos -= pmp->sizelClient.cx;
         break;
      case SB_LINERIGHT:
         pmp->sHScrollPos += sStep;
         break;
      case SB_PAGERIGHT:
         pmp->sHScrollPos += pmp->sizelClient.cx;
         break;
      case SB_SLIDERPOSITION:
      case SB_SLIDERTRACK:
         pmp->sHScrollPos = SHORT1FROMMP( mp2 );
         break;
      }

      /* Don't allow step assignments to exceed limits of zero to range. */
      pmp->sHScrollPos = max( (SHORT)0,
                              min( pmp->sHScrollPos, pmp->sHScrollRange ));

      if( pmp->sHScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndHScroll,
          SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 )))
      {
         /*
          * New scroll bar thumbbutton position is different than current.
          * Set a new X translation value to effect the scroll.
          * Current scale setting affects the X element of the matrix.
          */
         pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale *
                                                 (float)( pmp->sHScrollPos));
         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient,
                                        9,
                                        &pmp->matlfDefView,
                                        TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );
         CalibrateHorizontalScrollBar( pmp );
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;


   case WM_MOUSEMOVE:
      /* display which pointer? -- could query pmp->fBusy or... */
      if( WinIsWindowEnabled( hwnd ))
      {
         /* not disabled; display regular pointer */
         WinSetPointer( HWND_DESKTOP,
                        WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ));
      }
      else
      {
         /* disabled; display hourglass because I'm busy */
         WinSetPointer( HWND_DESKTOP,
                        WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ));
      }
     return (MRESULT) 1;



   case WM_NACK_BITMAP_NOT_SUPPORTED:
      /*
       * Object window does not support this format of bitmap -
       * show a message box.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab, (HMODULE)0,
                   ERRMSG_BITMAP_NOT_SUPPORTED, LEN_WORKSTRING, szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL);

      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_NACK_BITMAP_ERROR:
      /*
       * Object window had error loading the bitmap file -
       * show a message box
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab,
                           (HMODULE)NULLHANDLE,
                           ERRMSG_BAD_BITMAP,
                           LEN_WORKSTRING,
                           szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);

      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_NACK_FILE_READING_ERROR:
      /*
       * Object window had a problem with reading the disk -
       * show a message box.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE,
                           ERRMSG_READ_ERROR, LEN_WORKSTRING, szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL);
      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_PAINT:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* do not rely on client window rectangle being correct */
      WinQueryUpdateRect( hwnd, &rectl );
      WinQueryWindowRect( hwnd, &rectl );

      /* current mode of the program affects window painting */
      switch( pmp->ulMode )
      {
      case MODE_UNKNOWN:
         WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
         WinPostMsg( pmp->hwndObject, WM_USER_PAINT_DEFAULT_SCREEN,
                        (MPARAM)hwnd, (MPARAM)0 );
         /* must call default window proc for window validation */
         break;

      case MODE_TEXT:
         if( pmp->fBusy )
         {
            /*
             * Object window is busy with the client PS drawing into
             * retained segments. Use a cached micro PS to merely
             * fill the client window with a background wash.
             *
             * Proper painting of the text will occur in due time
             * because the WM_USER_ACK case below will
             * invalidate the client window and force a paint.
             * The object window won't be busy then.
             */
            hps = WinBeginPaint( hwnd, (HPS) 0, &rectl );
            pmassert( pmp->hab, hps );
            bOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW );
            pmassert( pmp->hab, bOK );
            WinEndPaint( hps );
         }
         else
         {
            /* PS not busy. Use GpiDrawChain to repaint the text */
            hps = WinBeginPaint( hwnd, (HPS)pmp->hpsClient, &rectl );
            pmassert( pmp->hab, hps );
            bOK = WinFillRect( pmp->hpsClient, &rectl, SYSCLR_WINDOW );
            pmassert( pmp->hab, bOK );
            /*
             * GpiDrawChain re-plays the GpiCharString orders that were
             * retain in the WM_USER_PAGINATE case in prtobj.c
             */
            bOK = GpiDrawChain( pmp->hpsClient );
            pmassert( pmp->hab, bOK );
            bOK = WinEndPaint( pmp->hpsClient );
            pmassert( pmp->hab, bOK );
         }
         return (MRESULT) 0;

      case MODE_BITMAP:
         if( pmp->hbm )
         {
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
            WinPostMsg( pmp->hwndObject, WM_USER_PAINT_BITMAP,
                        (MPARAM)hwnd, (MPARAM)0 );
         }
         /* must call default window proc for window validation */
         break;

      case MODE_METAFILE:
         hps = WinBeginPaint( hwnd, (HPS) 0, &rectl );
         pmassert( pmp->hab, hps );
         WinFillRect( hps, &rectl, SYSCLR_WINDOW );
         if( pmp->hmf )
         {
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
            WinPostMsg( pmp->hwndObject, WM_USER_PAINT_METAFILE,
                        (MPARAM)hwnd, (MPARAM)0 );
         }
         WinEndPaint( hps );
         return (MRESULT) 0;

      default:
         pmassert( pmp->hab, NULL == "bad case in WM_PAINT" );
      }
      break;


#ifdef OSA_AWARE
   case WM_SEMANTICEVENT:
      /* Handle Apple Event Manager Semantic Event */
      WinMessageBox( HWND_DESKTOP,
                     HWND_DESKTOP,
                     "WM_SEMANTIC_EVENT was received",
                     "WinProc",
                     (USHORT)0,
                     MB_OK | MB_NOICON);
      /* Call ProcessSemanticEvent to process the Apple Event */
      ProcessSemanticEvent( hwnd, msg, mp1, mp2 );
      return (MRESULT) 0;
#endif


   case WM_SIZE:
      /* Do size process if frame is not minimized  */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /*
       * If the object window is busy drawing, the GPI calls here can fail
       * because the PS is busy. Check for this situation and delay
       * the sizing operation by a few milliseconds.
       */
      if( pmp->fBusy )
      {
          WinStartTimer( pmp->hab, hwnd, ID_SIZE_TIMER, LEN_SIZE_TIMER );
          return (MRESULT) 0;
      }

      ulWork = WinQueryWindowULong( pmp->hwndFrame, QWL_STYLE );

      if( !( ulWork & WS_MINIMIZED ))
      {
         /* Frame is not minimized. Get window size in pels. */
         WinQueryWindowRect( hwnd, &rectl );

         /* how many twips will fit into the client window now? */
         bOK = GpiConvert( pmp->hpsClient, CVTC_DEVICE,
                           CVTC_WORLD, 2L, (PPOINTL)&rectl );
         pmassert( pmp->hab, bOK );

         /* compute client size in twips, store in pmp */
         pmp->sizelClient.cx = rectl.xRight - rectl.xLeft;
         pmp->sizelClient.cy = rectl.yTop   - rectl.yBottom;

         /* Try to keep the current position still in view by calculating */
         /* the difference between size required and client window. */
         /* The scroll position is then either 0 or the minimum of the */
         /* difference and the old scroll position */
         sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxxWidth) +
                    (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) -
                   pmp->sizelClient.cx;
         pmp->sHScrollPos = min( max( 0, sNewPos), pmp->sHScrollPos);
         sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxyHeight) +
                    (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) -
                   pmp->sizelClient.cy;
         pmp->sVScrollPos = min( max( 0, sNewPos), pmp->sVScrollPos);

         /* recalibrate the scroll bars */
         CalibrateHorizontalScrollBar( pmp );
         CalibrateVerticalScrollBar( pmp );

         /*
          * Modify def-view matrix translation to home the displayed page.
          * This depends on the current scaling value.
          */
         pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale *
                                                 (float)( pmp->sHScrollPos));
         pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale *
                          (float)( pmp->sVScrollPos - pmp->sVScrollRange ));
         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9,
                          &pmp->matlfDefView, TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );

         /* force a paint */
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;




   case WM_TIMER:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      switch( (ULONG) mp1 )
      {
      case ID_DEATH_TIMER:
         /* object window never posted a quit in allotted time.
         WinPostMsg( hwnd, WM_QUIT, 0, 0 );
         break;
      case ID_SIZE_TIMER:
         /* object window was busy with the PS before; try sizing now */
         bOK = WinStopTimer( pmp->hab, hwnd, ID_SIZE_TIMER );
         pmassert( pmp->hab, bOK );
         WinSendMsg( hwnd, WM_SIZE, 0, 0 );
         break;
      }
      return (MRESULT) 0;





   case WM_USER_ACK:
      /*
       * Object window is done processing lengthy task.
       * mp1 contains the WM_USER msg originally posted to the object window
       * mp2 may contain a result code, depending on mp1
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* reenable the client window */
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );

      switch( (ULONG)mp1 )
      {
      case WM_USER_LOAD_BITMAP:
      case WM_USER_LOAD_METAFILE:
      case WM_USER_LOAD_TEXT:
         /*
          * Do size processing so that document will
          * "home" in the client window.
          */
         WinSendMsg( hwnd, WM_SIZE, (MPARAM)0, (MPARAM)0 );
         break;
      case WM_USER_PAGINATE:
         switch( (ULONG)mp2  )
         {
         case PAGINATE_EOF:
         case PAGINATE_EOF_PART_PAGE:
            /* seek top of file */
            fseek( pmp->f, 0, SEEK_SET );
         }
         WinInvalidateRect( hwnd, NULL, FALSE );
         break;
      }

      return (MRESULT) 0;


   case WM_USER_DISABLE_CLIENT:
      /*
       * usually disable before posting a task to the object window
       * this message may be sent; disable menu action bar as well
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      pmp->fBusy = TRUE;
      WinEnableWindow( pmp->hwndClient,  FALSE );
      WinEnableWindow( pmp->hwndMenubar, FALSE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  FALSE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE );
      return (MRESULT)0;


   case WM_USER_ENABLE_CLIENT:
      /*
       * usually enable upon receipt of object window ack/nack
       * this message may be sent; enable menu actions if text mode
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      pmp->fBusy = FALSE;
      WinEnableWindow( pmp->hwndClient,  TRUE );
      WinEnableWindow( pmp->hwndMenubar, TRUE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  TRUE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  TRUE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE );
      if( pmp->ulMode == MODE_TEXT )
      {
         WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE );
      }
      return (MRESULT) 0;



   case WM_USER_NEW_MODE:
      /*
       * The program now has a new file, file type, or printer, or
       * printer form, orientation, resolution, etc. The receipt
       * and processing of this message works to reset the program:
       * Old file, bitmap, or metafile handles are closed, and
       * new ones get opened. The titlebar shows the new filename.
       * This case works very much like a program reset.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* close processing on current file */

      switch( pmp->ulMode )
      {
      case MODE_BITMAP:
        /* destroy previous memory dc, ps, and hbm */
        if( pmp->hpsMemory )
        {
          GpiAssociate( pmp->hpsMemory, (HDC)0 );
          GpiDestroyPS( pmp->hpsMemory );
          pmp->hpsMemory = (HPS) 0;
        }
        if( pmp->hdcMemory )
        {
          DevCloseDC( pmp->hdcMemory );
          pmp->hdcMemory = (HDC) 0;
        }
        if( pmp->hbm )
        {
          GpiDeleteBitmap( pmp->hbm );
          pmp->hbm = (HBITMAP) 0;
        }
        break;

      case MODE_METAFILE:
        /* destroy old metafile handle */
        if( pmp->hmf )
        {
          GpiDeleteMetaFile( pmp->hmf );
          pmp->hmf = (HMF) 0;
        }
        break;

      case MODE_TEXT:
        fclose( pmp->f );
        pmp->f = (FILE *) 0;
        /* turn off options for text mode */
        WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE );
        WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT,  FALSE );
        break;
      }

      /* turn off options for all modes */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  FALSE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  FALSE );

      /* copy over current values with the next values */
      pmp->ulMode = pmp->ulNextMode;
      strcpy( pmp->szFilename, pmp->szNextFilename );

      /* enable the print menu option if mode is known and there
         is a printer set up. */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_PRINT,
       (pmp->ulMode != MODE_UNKNOWN && pmp->hpsPrinterInfo ) );


      /* update title bar text and show filename in use */
      if( *pmp->szFilename )
      {
         /* parse full-qualified filename to just get filename and extension */
         psz = strrchr( pmp->szFilename, '\\' );
         if (psz && *psz)
         {
             ++psz;
         }
         else
         {
             psz = pmp->szFilename;
         }
         sprintf( szWork, "%s - %s", pmp->pszTitle, psz );
      }
      else
      {
         strcpy( szWork, pmp->pszTitle );
      }
      WinSetWindowText( pmp->hwndTitlebar, szWork );

      /* enable options for all modes */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE  );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE  );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  TRUE  );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  TRUE  );

      /* process this new mode */
      switch( pmp->ulMode )
      {
      case MODE_BITMAP:
        /* load the bitmap into memory so it is compatible with the screen */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        WinPostMsg( pmp->hwndObject, WM_USER_LOAD_BITMAP,
                    (MPARAM)hwnd, (MPARAM)FLAGS_SCREEN );
        break;

      case MODE_METAFILE:
        /* make object window read metafile */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        WinPostMsg( pmp->hwndObject, WM_USER_LOAD_METAFILE, (MPARAM)hwnd, 0 );
        break;

      case MODE_TEXT:
        /* turn on options for text mode */
        WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE  );
        WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT,  TRUE  );
        /* reset view matrix that was last in effect for viewing text pages; */
        /* this gets lost after viewing a metafile */
        bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9,
                                       &pmp->matlfDefView, TRANSFORM_REPLACE );
        pmassert( pmp->hab, bOK );
        /* disable until text loaded */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        /* tell object window to load the text file */
        bOK = WinPostMsg( pmp->hwndObject, WM_USER_LOAD_TEXT, (MPARAM)hwnd, 0 );
        pmassert( pmp->hab, bOK );
        break;


      case MODE_UNKNOWN:
        /* size screen to get correct scrollbars */
        WinPostMsg( pmp->hwndClient, WM_SIZE, 0, 0 );
        break;

      }
      return (MRESULT) 0;

   case WM_VSCROLL:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* Compute some fraction of scroll bar range for a unit of scrolling. */
      sStep  = pmp->sVScrollRange / 50;

      switch( SHORT2FROMMP( mp2 ))
      {
      case SB_LINEUP:
         pmp->sVScrollPos -= sStep;
         break;
      case SB_PAGEUP:
         pmp->sVScrollPos -= pmp->sizelClient.cy;
         break;
      case SB_LINEDOWN:
         pmp->sVScrollPos += sStep;
         break;
      case SB_PAGEDOWN:
         pmp->sVScrollPos += pmp->sizelClient.cy;
         break;
      case SB_SLIDERPOSITION:
      case SB_SLIDERTRACK:
         sNewPos          = SHORT1FROMMP( mp2 );
         pmp->sVScrollPos = sNewPos;
         break;
      }

      /* Don't allow step assignments to exceed limits of zero to range. */
      pmp->sVScrollPos = max( (SHORT)0,
                              min( pmp->sVScrollPos, pmp->sVScrollRange ));

      if( pmp->sVScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndVScroll,
          SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 )))
      {
         /*
          * New scroll bar thumbbutton position is different than current.
          * Set a new Y translation value to effect the scroll.
          * Current scale setting affects the Y element of the matrix.
          */
         pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale *
                          (float)( pmp->sVScrollPos - pmp->sVScrollRange ));

         pmp->matlfDefView.lM32 =  (LONG)(pmp->floatScale *
             (float)( OFFSET_XY_TWIPS +
                      pmp->sVScrollPos -
                      pmp->sVScrollRange ));

         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient,
                                        9,
                                        &pmp->matlfDefView,
                                        TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );
         CalibrateVerticalScrollBar( pmp );
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;
   }
   return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}  /* End of WinProc */