VOID UpdateSelFilesArray(HWND hwnd, PATTMAN pam) {
   int i, count, space;
   dprintf("UpdateSelFilesArray!!!\n");
   if (pam->fsp.psSel[0] >= 2000) { // precedente allocazione > minimo
      dprintf("Nuova allocazione\n");
      free(pam->fsp.psSel);
      if ((pam->fsp.psSel = malloc((size_t)4000)) == NULL) {
         PMPrint(hwnd, ERR_ALLOC_SELFILES);
         ProcessTermination(hwnd, FALSE);
         return;
      } /* endif */
   } /* endif */
   count = 1;      // numero items selezionati
   space = 4000;   // memoria allocata   --- primo item selezionato
   i = DlgLboxQuerySelectedItem(hwnd, LB_FILE);
   forever {
      dprintf("loop memorizzazione file selezionati: i = %d, count = %d\n", i, count);
      pam->fsp.psSel[count] = i;
      i = DlgLboxQueryNextSelItem(hwnd, LB_FILE, i);
      if (i == LIT_NONE) break;
      if (++count >= space / 2) {    // se serve > memoria:
         space += 4000;           // prova ad allocare altri 4KB
         if ((pam->fsp.psSel = realloc(pam->fsp.psSel, space)) == NULL) {
            PMPrint(hwnd, ERR_ALLOC_SELFILES);
            ProcessTermination(hwnd, FALSE);
            return;
         } /* endif */
      } /* endif */
   } /* endwhile */
   // abilita disabilita pulsanti per la selezione file precedente/successivo
   pam->fsp.psSel[0] = count;
   WinEnableControl(hwnd, BTN_UP, pam->fsp.psSel[1]);
   WinEnableControl(hwnd, BTN_DOWN, pam->fsp.psSel[count] !=
                    DlgLboxQueryItemCount(hwnd, LB_FILE) - 1);
}
Esempio n. 2
0
static
VOID MouseOptSetMptrHideDep(HWND hwnd, BOOL flag) {
   WinEnableControl(hwnd, TXT_MPTRHIDE, flag);
   WinEnableControl(hwnd, SPIN_MPTRHIDE, flag);
   WinEnableControl(hwnd, CHK_MPHXCLBTN, flag);
   WinEnableControl(hwnd, CHK_MPHXCLMENU, flag);
}
//===========================================================================
// Process notification messages.
// Parameters --------------------------------------------------------------
// HWND hwnd : window handle
// ULONG id       : control ID
// ULONG ulNotify : notify code
// HWND hCtrl     : control handle
// Return value ------------------------------------------------------------
// VOID
//===========================================================================
static
VOID onCtrlNotify(HWND hwnd, ULONG id, ULONG ulNotify, HWND hCtrl) {
   SHORT iitem;
   CHAR buf[360];
   switch (id) {
      case LBOX_CLASS:
         if (ulNotify == LN_SELECT) {
            iitem = WinQueryLboxSelectedItem(hCtrl);
            ulNotify = (iitem >= 0) && !bEditMode;
            WinEnableControl(hwnd, BTN_EDIT, ulNotify);
            WinEnableControl(hwnd, BTN_DEREG, ulNotify);
            WinEnableControl(hwnd, BTN_REMOVE, ulNotify);
         } else if (ulNotify == LN_ENTER) {
            WinPostMsg(hwnd, WM_COMMAND, (MPARAM)BTN_EDIT, MPVOID);
         //   onCommand(hwnd, BTN_EDIT);
         } /* endif */
         break;
      case EF_CLASSNAME:
      case EF_MODULENAME:
         if (ulNotify == EN_CHANGE) {
            ulNotify = DlgItemTextLength(hwnd, EF_CLASSNAME)
                       && DlgItemTextLength(hwnd, EF_MODULENAME)
                       && !bEditMode;
            DlgItemEnable(hwnd, BTN_ADD, ulNotify);
         } /* endif */
         break;
   } /* endswitch */
}
Esempio n. 4
0
//==========================================================================
// procedura utilizzata sia per l'inizializzazione del dialogo che per
// l'UNDO
// parametri:
// HWND hwnd: handle dialogo
// PAPPDATA p: indirizzo struttura dati applicazione
// POPTIONS po: indirizzo struttura opzioni globali (ocur=init,
//                                                       ou=undo)
// valore restituito:
// VOID
//==========================================================================
static
VOID MouseOptInit(HWND hwnd, POPTIONS po) {
   // autofocus
   WinCheckButton(hwnd, CHK_MAUTFOCUS, po->mou.focusAuto);
   DlgSpinSetValue(hwnd, SPIN_MAUTFOCUS, po->mou.focusDelay / 10);
   WinCheckButton(hwnd, CHK_MAFIGNDESK, po->mou.focusNoDesk);
   WinCheckButton(hwnd, CHK_MAFNOTOP, po->mou.focusNoTop);
   WinCheckButton(hwnd, CHK_MAFIGNNEW, po->mou.focusNoNew);
   MouseOptSetAutofocusDep(hwnd, po->mou.focusAuto);
   // pointer hiding
   WinCheckButton(hwnd, CHK_MPTRHIDE, po->mou.hide);
   DlgSpinSetValue(hwnd, SPIN_MPTRHIDE, po->mou.hideDelay / 100);
   WinCheckButton(hwnd, CHK_MPHXCLBTN, po->mou.hideNotOnBtn);
   WinCheckButton(hwnd, CHK_MPHXCLMENU, po->mou.hideNotOnMenu);
   MouseOptSetMptrHideDep(hwnd, po->mou.hide);
   // button 3 remap
   WinCheckButton(hwnd, CHK_MBTN3MAP, po->mou.btn3dblClk);
   WinEnableControl(hwnd, CHK_MBTN3MAP, p->is.mou3btns);
   WinCheckButton(hwnd, CHK_MBTN3TBAR, po->mou.btn3title);
   WinEnableControl(hwnd, CHK_MBTN3TBAR, po->mou.btn3dblClk && p->is.mou3btns);
   // move pointer to the focus window
   WinCheckButton(hwnd, CHK_MMOVETOFOCUS, po->mou.moveToFocus);
   WinCheckButton(hwnd, CHK_MMTFWINCREATE, po->mou.moveToNew);
   WinCheckButton(hwnd, CHK_MMTFWINDLG, po->mou.moveToDlg);
   WinCheckButton(hwnd, CHK_MMTFXCLDLGNOBTN, po->mou.moveNotBtnles);
   DlgSpinSetValue(hwnd, SPIN_MMTFSTEPS, po->mou.moveSteps);
   MouseOptSetMptrMove2FocusDep(hwnd, po->mou.moveToFocus);
}
Esempio n. 5
0
//==========================================================================
// abilita/disabilita controlli secondo settaggio checkbox Enable
// parametri:
// HWND hwnd: handle dialogo
// BOOL flag: TRUE = abilita, FALSE = disabilita
// valore restituito:
// VOID
//==========================================================================
static
VOID MouseOptSetAutofocusDep(HWND hwnd, BOOL flag) {
   WinEnableControl(hwnd, TXT_MAUTFOCUS, flag);
   WinEnableControl(hwnd, SPIN_MAUTFOCUS, flag);
   WinEnableControl(hwnd, CHK_MAFIGNDESK, flag);
   WinEnableControl(hwnd, CHK_MAFNOTOP, flag);
   WinEnableControl(hwnd, CHK_MAFIGNNEW, flag);
}
VOID SetSelectionDefault(HWND hwnd) {
   WinCheckButton(hwnd, CBOX_EXT_SEL, TRUE);
   WinCheckButton(hwnd, CBOX_SEL_ALL_INDIR, FALSE);
   WinEnableControl(hwnd, CBOX_SEL_ALL_INDIR, TRUE);
   WinCheckButton(hwnd, CBOX_MOUSE_SINGLE, FALSE);
   WinCheckButton(hwnd, CBOX_FILE_WIN, FALSE);
   WinCheckButton(hwnd, CBOX_ONLY_DIR, FALSE);
   WinEnableControl(hwnd, CBOX_ONLY_DIR, FALSE);
}
Esempio n. 7
0
static
VOID MouseOptSetMptrMove2FocusDep(HWND hwnd, BOOL flag) {
   WinEnableControl(hwnd, TXT_MMTFSTEPS, flag);
   WinEnableControl(hwnd, SPIN_MMTFSTEPS, flag);
   WinEnableControl(hwnd, CHK_MMTFWINCREATE, flag);
   WinEnableControl(hwnd, CHK_MMTFWINDLG, flag);
   WinEnableControl(hwnd, CHK_MMTFXCLDLGNOBTN, flag &&
                    WinQueryButtonCheckstate(hwnd, CHK_MMTFWINDLG));
}
Esempio n. 8
0
BOOL resetStrCtls(HWND hwnd, BOOL fl, BOOL fcase, BOOL fesc) {
   BOOL rc = WinEnableControl(hwnd, CHK_NOCASE, fl) &&
             WinEnableControl(hwnd, CHK_ESCAPE, fl) &&
             WinEnableControl(hwnd, BTN_REM1, fl);
   WinCheckButton(hwnd, CHK_NOCASE, (fl && fcase? 1: 0));
   WinCheckButton(hwnd, CHK_ESCAPE, (fl && fesc? 1: 0));
   if (fl) WsetDefBtn(hwnd, BTN_REM1);
   return rc;
}
VOID InitSelectionPage(HWND hwnd, PPREF_SEL psel) {
   WinCheckButton(hwnd, CBOX_EXT_SEL, psel->extsel);
   WinCheckButton(hwnd, CBOX_SEL_ALL_INDIR, psel->dir);
   WinEnableControl(hwnd, CBOX_SEL_ALL_INDIR, psel->extsel);
   WinCheckButton(hwnd, CBOX_MOUSE_SINGLE, psel->monoclick == LN_SELECT);
   WinCheckButton(hwnd, CBOX_FILE_WIN, psel->browse);
   WinCheckButton(hwnd, CBOX_ONLY_DIR, psel->browsedir);
   WinEnableControl(hwnd, CBOX_ONLY_DIR, psel->browse);
}
Esempio n. 10
0
BOOL enableBtns(HWND hwnd) {
   ULONG c1, c2;
   BOOL b1, b2;
   c1 = DlgLboxQueryItemCount(hwnd, LB_FILE);
   b1 = c1 && (DlgLboxQuerySelectedItem(hwnd, LB_FILE) >= 0);
   c2 = DlgLboxQueryItemCount(hwnd, LB_STRINGS);
   b2 = c2 && (DlgLboxQuerySelectedItem(hwnd, LB_STRINGS) >= 0);
   return (WinEnableControl(hwnd, BTN_REM0, b1) &&
           WinEnableControl(hwnd, BTN_REM1, b2) &&
           WinEnableControl(hwnd, BTN_START, c1 && c2) &&
           WinEnableControl(hwnd, BTN_SAVE, c1 || c2) &&
           WinEnableControl(hwnd, BTN_REMALL, c2));
}
Esempio n. 11
0
void wmControl( HWND hwndDlg, USHORT idControl, USHORT usEvent )
{
    switch( idControl )
    {
        case CHK_OVERRIDE_HSTRS:
            if( usEvent == BN_CLICKED )
            {
                BOOL fChecked = WinQueryButtonCheckstate( hwndDlg,
                                                          CHK_OVERRIDE_HSTRS );
                WinEnableControl( hwndDlg, EF_CNR_NAME, fChecked );
                WinEnableControl( hwndDlg, EF_SOURCE_NAME, fChecked );
                WinEnableControl( hwndDlg, EF_TARGET_NAME, fChecked );
                WinEnableControl( hwndDlg, ST_CNR_NAME, fChecked );
                WinEnableControl( hwndDlg, ST_SOURCE_NAME, fChecked );
                WinEnableControl( hwndDlg, ST_TARGET_NAME, fChecked );
            }

            break;

        case CHK_OVERRIDE_ID:
            if( usEvent == BN_CLICKED )
            {
                BOOL fChecked = WinQueryButtonCheckstate( hwndDlg,
                                                          CHK_OVERRIDE_ID );
                WinEnableControl( hwndDlg, EF_ITEMID, fChecked );
                WinEnableControl( hwndDlg, ST_ITEMID, fChecked );
            }

            break;
    }
}
//===========================================================================
// Enumerate the registered classes.
// If bClean is TRUE delete the listbox content first.
// Parameters --------------------------------------------------------------
// HWND hwnd : window handle
// VOID
// Return value ------------------------------------------------------------
// VOID
//===========================================================================
static
VOID enumClasses(HWND hwnd, BOOL bClean) {
   PWPSCLASSLIST pClassList;
   PWPSCLASSENTRY pClass;
   INT iitem;
   CHAR buf[512];
   CHAR prevItem[CB_CLASSFIELD + 1];
   PBYTE pEnd;
   INT citems = 0;
   HWND hlbox;
   prevItem[0] = prevItem[CB_CLASSFIELD] = 0;
   hlbox = DlgItemHwnd(hwnd, LBOX_CLASS);
   // store the text of the selected item and clean the listbox
   if (bClean) {
      iitem = wLbxItemSelected(hlbox);
      if (iitem >= 0)
         wLbxItemText(hlbox, iitem, CB_CLASSFIELD, prevItem);
      wLbxEmpty(hlbox);
      WinEnableControl(hwnd, BTN_EDIT, FALSE);
      WinEnableControl(hwnd, BTN_DEREG, FALSE);
      WinEnableControl(hwnd, BTN_REMOVE, FALSE);
   } /* endif */
   // get the WPS classes data from OS2SYS.INI
   if (NULL != (pClassList = getWPSClassData(hwnd))) {
      pEnd = (PBYTE)pClassList + pClassList->cbData;
      // loop through the whole class list
      for (pClass = &pClassList->aClass[0];
           (PBYTE)pClass < pEnd;
           pClass = PNEXTCLASS(pClass), ++citems) {
         sprintf(buf, SZ_FORMATSTR,
                 pClass->achClass,
                 pClass->achClass + strlen(pClass->achClass) + 1);
         wLbxItemIns(hlbox, LIT_SORTASCENDING, buf);
      } /* endfor */
   } /* endif */
   free(pClassList);
   // if any items have been inserted
   if (citems) {
      // index of the item to be selected
      iitem = -1;
      // if an item was previously selected get its new index
      if (prevItem[0])
         iitem = wLbxItemTextSearch(hlbox, LSS_PREFIX, LIT_FIRST, prevItem);
      wLbxItemSelect(hlbox, iitem);
   } else {
      WinPostMsg(hwnd, WM_QUIT, MPVOID, MPVOID);
   } /* endif */
}
Esempio n. 13
0
MRESULT EXPENTRY GameSettingsDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
	ULONG OldLineStyle = InfoData.GetLineStyle();
	switch( msg ){
		case WM_INITDLG:
			(VOID)WinCheckButton( hwnd, (USHORT)IDC_DIAGONALS, InfoData.IsLineStyle(IDC_DIAGONALS) );
			(VOID)WinCheckButton( hwnd, (USHORT)IDC_VERTICALS, InfoData.IsLineStyle(IDC_VERTICALS));
			(VOID)WinCheckButton( hwnd, (USHORT)IDC_DIAGONALS_AND_VERTICALS, InfoData.IsLineStyle(IDC_DIAGONALS_AND_VERTICALS));
			(VOID)WinCheckButton( hwnd, (USHORT)IDC_SOUND, InfoData.GetSound() );
			(VOID)WinEnableControl( hwnd, (USHORT)IDC_SOUND,
											InfoData.IsSoundAvailable() );
			break;
		case WM_COMMAND:
			switch( SHORT1FROMMP( mp1 ) ){
				case DID_OK:
					if( WinQueryButtonCheckstate( hwnd, IDC_DIAGONALS ) )
						InfoData.SetLineStyle(IDC_DIAGONALS);
					else
						if( WinQueryButtonCheckstate( hwnd, IDC_VERTICALS ) )
							InfoData.SetLineStyle(IDC_VERTICALS);
						else InfoData.SetLineStyle(IDC_DIAGONALS_AND_VERTICALS);
					InfoData.SetSound( WinQueryButtonCheckstate(hwnd, IDC_SOUND) );
					WinDismissDlg( hwnd, !InfoData.IsLineStyle(OldLineStyle) );
						// TRUE => repaint because of new linestyle
					return (MRESULT)0;
				case DID_CANCEL:
					WinDismissDlg( hwnd, FALSE );
					return (MRESULT)0;
				case IDC_GAMESETTINGSHELP:
					return (MRESULT)0;				
			}
	}	
	return WinDefDlgProc( hwnd, msg, mp1, mp2 );
}
VOID InitGeneralPage(HWND hwnd, PPREF_GEN pgen) {
   DlgSpinSetLimits(hwnd, SPIN_SUBJ_LEN, 255, 0);
   WinCheckButton(hwnd, CBOX_NOLOGO, pgen->nologo);
   WinCheckButton(hwnd, CBOX_BUBBLE, pgen->bubble);
   if (pgen->subj < 0) {  // disabilita ef subj length
      WinCheckButton(hwnd, CBOX_DEF_LEN, TRUE);
      DlgSpinSetValue(hwnd, SPIN_SUBJ_LEN, -pgen->subj);
      WinEnableControl(hwnd, SPIN_SUBJ_LEN, FALSE);
   } else {
      WinCheckButton(hwnd, CBOX_DEF_LEN, FALSE);
      DlgSpinSetValue(hwnd, SPIN_SUBJ_LEN, pgen->subj);
      WinEnableControl(hwnd, SPIN_SUBJ_LEN, TRUE);
   } /* endif */
   WinCheckButton(hwnd, CBOX_READ_ONLY, pgen->ronly);
   WinCheckButton(hwnd, CBOX_SV_LASTPATH, pgen->lastPath[0] != 0);
   WinSetDlgItemText(hwnd, TXT_FONT, pgen->font);
}
VOID SetGeneralDefault(HWND hwnd, PPREF_GEN pgen) {
   WinCheckButton(hwnd, CBOX_NOLOGO, FALSE);
   WinCheckButton(hwnd, CBOX_BUBBLE, TRUE);
   WinCheckButton(hwnd, CBOX_DEF_LEN, TRUE);
   DlgSpinSetValue(hwnd, SPIN_SUBJ_LEN, 40);
   WinEnableControl(hwnd, SPIN_SUBJ_LEN, FALSE);
   WinCheckButton(hwnd, CBOX_READ_ONLY, FALSE);
   WinCheckButton(hwnd, CBOX_SV_LASTPATH, FALSE);
   WinSetDlgItemText(hwnd, TXT_FONT, "5.System VIO");
}
MRESULT EXPENTRY SelDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_SEL psel;

   switch (msg) {
      case WM_INITDLG:
         psel = (PPREF_SEL)PVOIDFROMMP(mp2);
         InitSelectionPage(hwnd, psel);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_EXT_SEL &&
             SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_SEL_ALL_INDIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_EXT_SEL));
         } else if (SHORT1FROMMP(mp1) == CBOX_FILE_WIN &&
                    SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_ONLY_DIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_FILE_WIN));
         } /* endif */
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
            case BTTN_UNDO:
               InitSelectionPage(hwnd, psel);
               break;
            case BTTN_DEFAULT:
               SetSelectionDefault(hwnd);
               break;  
            default:
               break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Esempio n. 17
0
VOID MainWinControl(HWND hwnd, ULONG idCtl, ULONG ulEvent) {
   if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
      switch (idCtl) {
         case CHK_MWUSESMWFONT:   // check box "Use Smart Windows Font"
            p->po->dlg.font = p->ocur.dlg.font =
                           WinQueryButtonCheckstate(hwnd, CHK_MWUSESMWFONT);
            EnableToolbarUndoBtn(1);
            MainWinSetMainDep(hwnd, p->po);
            break;
         case CHK_MWOVERRDPPS:    // check box "Override PresParms"
            p->po->dlg.ovrPP = p->ocur.dlg.ovrPP =
                           WinQueryButtonCheckstate(hwnd, CHK_MWOVERRDPPS);
            WinEnableControl(hwnd, CHK_MWIGNOREPP,
                             p->po->dlg.font && p->po->dlg.ovrPP);
            EnableToolbarUndoBtn(1);
            break;
      } // end switch
      _stlrMsgPostAll(STLR_SETFRAMEFONT, 0);
   } // end if
}
Esempio n. 18
0
 static void containerAction(HWND hwnd, USHORT id, void *parm)
 {
    PRECORD       rec;
    ICQMSGDIALOG  *cfg   = WinQueryWindowPtr(hwnd,0);
    const char    *text  = NULL;
    int           f      = 0;

    DBGTracex(cfg);

    if(id != CN_EMPHASIS)
       return;

    DBGTracex(((PNOTIFYRECORDEMPHASIS) parm)->fEmphasisMask & CRA_SELECTED);

    if( !(((PNOTIFYRECORDEMPHASIS) parm)->fEmphasisMask & CRA_SELECTED) )
       return;

    rec = (PRECORD) ((PNOTIFYRECORDEMPHASIS) parm)->pRecord;
    DBGTracex(rec);
    DBGMessage(rec->text);

    text = (char *) icqQueryURL(cfg->fr.icq, rec->text);

    DBGTracex(text);

    if(text)
    {
       for(f=0;*text && !isspace(*text) && f < 0xFE;f++)
          cfg->sendToParm[f] = *(text++);
    }

    cfg->sendToParm[f] = 0;

    DBGMessage(cfg->sendToParm);
#ifndef DEBUG
    WinEnableControl(hwnd, DLG_ELEMENT_ID+MSGID_SENDTO, f > 0);
#endif

 }
MRESULT EXPENTRY GenDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_GEN pgen;

   switch (msg) {

      case WM_INITDLG:
         pgen = (PPREF_GEN)PVOIDFROMMP(mp2);
         InitGeneralPage(hwnd, pgen);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_DEF_LEN &&
             SHORT2FROMMP(mp1) == BN_CLICKED)
            WinEnableControl(hwnd, SPIN_SUBJ_LEN,
                         !WinQueryButtonCheckstate(hwnd, CBOX_DEF_LEN));
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
         case BTN_FONT: {
            char achFont[FACESIZE];  // buffer usato per i dati del nuovo font
            if (ShowFontDlg(hwnd, achFont))
               WinSetDlgItemText(hwnd, TXT_FONT, achFont);
            }
            break;
         case BTTN_UNDO:
            InitGeneralPage(hwnd, pgen);
            break;
         case BTTN_DEFAULT:
            SetGeneralDefault(hwnd, pgen);
            break;
         default:
           break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Esempio n. 20
0
VOID MainWinSetMainDep(HWND hwnd, POPTIONS po) {
   WinEnableControl(hwnd, CHK_MWOVERRDPPS, po->dlg.font);
   WinEnableControl(hwnd, BTN_MWFONT, po->dlg.font);
}
Esempio n. 21
0
void UpdateControls( HWND hwndDlg )
{
    int  i;
    char szFromUl[ 9 ];
    HWND hwndLB;

    hwndLB = WinWindowFromID( hwndDlg, LB_CONTROL );
    WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( LIT_NONE ),
                MPFROMLONG( FALSE ) );
    for( i = 0; i < cControlTypes; i++ )
        if( dlgInfo.fsControl & dcControl[ i ].iItem )
            WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( i ),
                        MPFROMLONG( TRUE ) );

    hwndLB = WinWindowFromID( hwndDlg, LB_SUPPORTEDOPS );
    WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( LIT_NONE ),
                MPFROMLONG( FALSE ) );
    for( i = 0; i < cSupportedOps; i++ )
        if( dlgInfo.fsSupportedOps & dcSupportedOp[ i ].iItem )
            WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( i ),
                        MPFROMLONG( TRUE ) );

    for( i = 0; i < cOperations; i++ )
        if( dlgInfo.usOperation == dcOperation[ i ].iItem )
        {
            WinSetDlgItemText( hwndDlg, CB_OPERATION, dcOperation[ i ].szItem );
            break;
        }
    if( i == cOperations )
        WinSetDlgItemText( hwndDlg, CB_OPERATION,
                           _ultoa( (ULONG)dlgInfo.usOperation, szFromUl, 16 ) );

    if( dlgInfo.ulItemID )
        WinSetDlgItemText( hwndDlg, EF_ITEMID,
                           _ultoa( dlgInfo.ulItemID, szFromUl, 16 ) );
    else
        WinSetDlgItemText( hwndDlg, EF_ITEMID, "" );

    WinSetDlgItemText( hwndDlg, CB_TYPE, dlgInfo.szType );
    for( i = 0; i < cTypes; i++ )
    {
       if( !stricmp( ntsType[ i ].szString, dlgInfo.szType ) )
           WinSetDlgItemText( hwndDlg, CB_TYPE, ntsType[ i ].szName );
    }

    WinSetDlgItemText( hwndDlg, EF_CNR_NAME, dlgInfo.szContainerName );
    WinSetDlgItemText( hwndDlg, EF_SOURCE_NAME, dlgInfo.szSourceName );
    WinSetDlgItemText( hwndDlg, EF_TARGET_NAME, dlgInfo.szTargetName );

    WinCheckButton( hwndDlg, CHK_OVERRIDE_ID, dlgInfo.fUseDlgItemID );
    WinCheckButton( hwndDlg, CHK_OVERRIDE_HSTRS, dlgInfo.fUseDlgDragNames );

    WinEnableControl( hwndDlg, EF_ITEMID, dlgInfo.fUseDlgItemID );
    WinEnableControl( hwndDlg, ST_ITEMID, dlgInfo.fUseDlgItemID );
    WinEnableControl( hwndDlg, EF_CNR_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, EF_SOURCE_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, EF_TARGET_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_CNR_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_SOURCE_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_TARGET_NAME, dlgInfo.fUseDlgDragNames );
}
Esempio n. 22
0
static MRESULT EXPENTRY PSListProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   PPRINTSETUP pPrintSetup = WinQueryWindowPtr(hwnd, QWL_USER);
   HWND hwndListbox;
   int i, index;
   char *psz;
   PPRQINFO3 pqi;

   switch(msg)
   {
      case WM_INITDLG:
         pPrintSetup = (PPRINTSETUP) mp2;
         WinSetWindowPtr(hwnd, QWL_USER, pPrintSetup);

         // fill listbox with print queues
         hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );

         for( i = 0; i < pPrintSetup->cQueues; i++ )
         {
           // Display printer comment if possible, else use queue name for display.
           psz = *pPrintSetup->pQueueInfo[i].pszComment ? pPrintSetup->pQueueInfo[i].pszComment : pPrintSetup->pQueueInfo[i].pszName;

           index = (LONG) WinSendMsg( hwndListbox, LM_INSERTITEM, (MPARAM)LIT_END, (MPARAM)psz );

           if( 0 == strcmp( pPrintSetup->pQueueInfo[i].pszName, pPrintSetup->szPreferredQueue ))
           {
             // Hilight preferred queue.
             WinSendMsg( hwndListbox, LM_SELECTITEM, (MPARAM)index, (MPARAM)TRUE );
           }
         }
         if (pPrintSetup->cQueues)
            WinEnableControl(hwnd, IDD_PS_LIST+3, TRUE);
         break;

      case WM_COMMAND:
         switch(SHORT1FROMMP(mp1))
         {
            case IDD_PS_LIST+3:
               hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );
               ConfigurePrinter(hwndListbox, pPrintSetup);
               return (MRESULT) FALSE;

            default:
               return (MRESULT) FALSE;
         }

      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == IDD_PS_LIST+2 &&
             SHORT2FROMMP(mp1) == LN_ENTER)
            ConfigurePrinter((HWND) mp2, pPrintSetup);
         break;

      case WM_DESTROY:
         hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );

         index = (LONG) WinSendMsg( hwndListbox, LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0 );
         if (index != LIT_NONE)
         {
            pqi = &pPrintSetup->pQueueInfo[ index ];

            if (pPrintSetup->pDriverData)
               free(pPrintSetup->pDriverData);
            pPrintSetup->pDriverData = malloc(pqi->pDriverData->cb);
            memcpy(pPrintSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb);

            // New preferred queue. Modify the one in the PRINTERSETUP structure.
            strcpy( pPrintSetup->szPreferredQueue, pqi->pszName );
            pPrintSetup->bDirty = TRUE;
         }
         break;

      default:
         break;
   }
   return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
Esempio n. 23
0
static MRESULT EXPENTRY AreaMsgBaseProc(HWND parent, ULONG message, MPARAM mp1, MPARAM mp2)
{
   extern AREALIST arealiste;
   extern HWND hwndhelp;
   static AREADEFLIST *pArea=NULL;
   char pchTemp[LEN_PATHNAME+1];
   SHORT sTemp;

   switch(message)
   {
      case WM_INITDLG:
         pArea=((AREAPAR *)mp2)->pAreaDef;
         WinSubclassWindow(WinWindowFromID(parent, IDD_AS_MSGBASE+9),
                           FileEntryProc);

         WinSendDlgItemMsg(parent, IDD_AS_MSGBASE+9,
                           EM_SETTEXTLIMIT,
                           MPFROMSHORT(LEN_PATHNAME),
                           (MPARAM) NULL);
         if (pArea)
         {
            WinSetDlgItemText(parent, IDD_AS_MSGBASE+9,
                              pArea->areadata.pathfile);

            switch(pArea->areadata.areaformat)
            {
               case AREAFORMAT_FTS:
                  WinCheckButton(parent, IDD_AS_MSGBASE+2, TRUE);
                  break;

               case AREAFORMAT_SQUISH:
                  WinCheckButton(parent, IDD_AS_MSGBASE+3, TRUE);
                  break;

               case AREAFORMAT_JAM:
                  WinCheckButton(parent, IDD_AS_MSGBASE+4, TRUE);
                  break;

               default:
                  WinCheckButton(parent, IDD_AS_MSGBASE+2, TRUE);
                  break;
            }
            switch(pArea->areadata.areatype)
            {
               case AREATYPE_NET:
                  WinCheckButton(parent, IDD_AS_MSGBASE+6, TRUE);
                  break;

               case AREATYPE_ECHO:
                  WinCheckButton(parent, IDD_AS_MSGBASE+7, TRUE);
                  break;

               case AREATYPE_LOCAL:
                  WinCheckButton(parent, IDD_AS_MSGBASE+12, TRUE);
                  break;
            }
            if (pArea->areadata.ulAreaOpt & AREAOPT_FROMCFG)
            {
               WinEnableControl(parent, IDD_AS_MSGBASE+2, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+3, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+4, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+6, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+7, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+12, FALSE);
               WinSendDlgItemMsg(parent, IDD_AS_MSGBASE+9, EM_SETREADONLY,
                                 (MPARAM)TRUE, (MPARAM) NULL);
               WinEnableControl(parent, IDD_AS_MSGBASE+10, FALSE);
            }
         }
         WinDefDlgProc(parent, message, mp1, mp2);
         SetFocusControl(parent, IDD_AS_MSGBASE+9);
         return (MRESULT) TRUE;

      case WM_CLOSE:
      case WM_DESTROY:
         if (!WinQueryWindowULong(parent, QWL_USER))
         {
            WinQueryDlgItemText(parent, IDD_AS_MSGBASE+9, LEN_PATHNAME+1,
                                pchTemp);
            if (strcmp(pArea->areadata.pathfile, pchTemp))
            {
               strcpy(pArea->areadata.pathfile, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }

            if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+2))
               sTemp=AREAFORMAT_FTS;
            else
               if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+3))
                  sTemp=AREAFORMAT_SQUISH;
               else
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+4))
                     sTemp=AREAFORMAT_JAM;
                  else
                     sTemp=AREAFORMAT_FTS;

            if (sTemp!=pArea->areadata.areaformat)
            {
               pArea->areadata.areaformat=sTemp;
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }

            if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+6))
               sTemp=AREATYPE_NET;
            else
               if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+7))
                  sTemp=AREATYPE_ECHO;
               else
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+12))
                     sTemp=AREATYPE_LOCAL;
                  else
                     sTemp=AREATYPE_NET;

            if (sTemp != pArea->areadata.areatype)
            {
               pArea->areadata.areatype=sTemp;
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
         }
         break;

      case WM_COMMAND:
         if (SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON)
         {
            if(SHORT1FROMMP(mp1)==IDD_AS_MSGBASE+10)
            {
               WinQueryDlgItemText(parent, IDD_AS_MSGBASE+9,
                                   LEN_PATHNAME+1, pchTemp);
               if (GetPathname(parent, pchTemp)==DID_OK)
               {
                  char drive[_MAX_DRIVE];
                  char path[_MAX_DIR];
                  char name[_MAX_FNAME];
                  char ext[_MAX_EXT];

                  _splitpath(pchTemp, drive, path, name, ext);
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+3))
                     _makepath(pchTemp, drive, path, name, "");
                  else
                  {
                    _makepath(pchTemp, drive, path, "", "");
                    pchTemp[strlen(pchTemp)-1]='\0';
                  }
                  WinSetDlgItemText(parent, IDD_AS_MSGBASE+9,
                                    pchTemp);
                  arealiste.bDirty = TRUE;
               }
            }
         }
         return (MRESULT) FALSE;

      case APM_REQCLOSE:
         if (WinQueryDlgItemTextLength(parent, IDD_AS_MSGBASE+9)==0)
         {
            /* Fehler, kein Pfadname */
            if (MessageBox(parent, IDST_MSG_NOPATHFILE, 0,
                           IDD_NOPATHFILE, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                return (MRESULT) 2;
            else
                return (MRESULT) 1;
         }
         return (MRESULT) 0;

      case APM_CANCEL:
         WinSetWindowULong(parent, QWL_USER, 1);
         break;

      default:
         break;
   }
   return WinDefDlgProc(parent,message,mp1,mp2);
}
Esempio n. 24
0
static MRESULT EXPENTRY AreaGenSettProc(HWND parent, ULONG message, MPARAM mp1, MPARAM mp2)
{
   HWND hwndList;
   extern USERDATAOPT userdaten;
   extern AREALIST arealiste;
   extern TEMPLATELIST templatelist;
   SHORT sItem=0, sSelect=0;
   static AREADEFLIST *pArea=NULL;
   char pchTemp[LEN_PATHNAME+1];
   static HWND hwndSettingsFrame;
   PMSGTEMPLATE pTemplate;
   AREADEFLIST *pAreaTemp;

   switch(message)
   {
      case WM_INITDLG:
         pArea=((PAREAPAR)mp2)->pAreaDef;

         if (!((PAREAPAR)mp2)->bMultiple)
         {
            SendMsg(hwndSettingsFrame=WinQueryWindow(parent, QW_PARENT),
                       APM_SETTITLE, pArea->areadata.areatag, NULL);
            WinSendDlgItemMsg(parent,IDD_AS_GENERAL+3,
                              EM_SETTEXTLIMIT,
                              MPFROMSHORT(LEN_AREATAG),
                              (MPARAM) NULL);

            WinSendDlgItemMsg(parent,IDD_AS_GENERAL+5,
                              EM_SETTEXTLIMIT,
                              MPFROMSHORT(LEN_AREADESC),
                              (MPARAM) NULL);
         }
         else
         {
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+2), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+3), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+4), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+5), FALSE);
         }

         /* Adressen eintragen */
         hwndList=WinWindowFromID(parent, IDD_AS_GENERAL+9);
         SendMsg(hwndList, LM_DELETEALL, (MPARAM)0, (MPARAM)0);
         sItem=0;
         sSelect = LIT_NONE;
         while(sItem<MAX_ADDRESSES && userdaten.address[sItem][0])
         {
            SendMsg(hwndList, LM_INSERTITEM,
                       MPFROMSHORT(LIT_END),
                       (MPARAM) userdaten.address[sItem]);
            if (pArea && !strcmp(pArea->areadata.address, userdaten.address[sItem]))
               sSelect = sItem;
            sItem++;
         }
         SendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(sSelect), (MPARAM) TRUE);

         /* Namen eintragen */
         hwndList=WinWindowFromID(parent, IDD_AS_GENERAL+12);
         SendMsg(hwndList, LM_DELETEALL, (MPARAM)0, (MPARAM)0);
         sItem=0;
         sSelect = LIT_NONE;
         while(sItem<MAX_USERNAMES && userdaten.username[sItem][0])
         {
            SendMsg(hwndList, LM_INSERTITEM,
                       MPFROMSHORT(LIT_END),
                       (MPARAM) userdaten.username[sItem]);
            if (pArea && !strcmp(pArea->areadata.username, userdaten.username[sItem]))
               sSelect = sItem;
            sItem++;
         }
         SendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(sSelect), (MPARAM) TRUE);

         if (pArea)
         {
            WinSetDlgItemText(parent, IDD_AS_GENERAL+3,
                              pArea->areadata.areatag);
            WinSetDlgItemText(parent, IDD_AS_GENERAL+5,
                              pArea->areadata.areadesc);

            if (pArea->areadata.ulAreaOpt & AREAOPT_FROMCFG)
               WinSendDlgItemMsg(parent, IDD_AS_GENERAL+3, EM_SETREADONLY,
                                 (MPARAM)TRUE, NULL);
         }

         /* Template-Namen eintragen */
         pTemplate = templatelist.pTemplates;
         while (pTemplate)
         {
            sItem = (SHORT) WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_INSERTITEM,
                                              MPFROMSHORT(LIT_SORTASCENDING),
                                              pTemplate->TName);
            WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_SETITEMHANDLE,
                              MPFROMSHORT(sItem),
                              MPFROMLONG(pTemplate->ulID));
            if (pArea && pTemplate->ulID == pArea->areadata.ulTemplateID)
               WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_SELECTITEM,
                                 MPFROMSHORT(sItem), MPFROMSHORT(TRUE));

            pTemplate = pTemplate->next;
         }
         break;

      case WM_CLOSE:
      case WM_DESTROY:
         if (!WinQueryWindowULong(parent, QWL_USER))
         {
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1,
                                pchTemp);
            if (strcmp(pArea->areadata.areatag, pchTemp))
            {
               strcpy(pArea->areadata.areatag, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+5, LEN_AREADESC+1,
                                pchTemp);
            if (strcmp(pArea->areadata.areadesc, pchTemp))
            {
               strcpy(pArea->areadata.areadesc, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+9, LEN_5DADDRESS+1,
                                pchTemp);
            if (strcmp(pArea->areadata.address, pchTemp))
            {
               strcpy(pArea->areadata.address, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+12, LEN_USERNAME+1,
                                pchTemp);
            if (strcmp(pArea->areadata.username, pchTemp))
            {
               strcpy(pArea->areadata.username, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            sItem = (SHORT)WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_QUERYSELECTION,
                                               MPFROMSHORT(LIT_FIRST), NULL);
            if (sItem >= 0)
            {
               ULONG ulID;

               ulID = (ULONG) WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_QUERYITEMHANDLE,
                                                MPFROMSHORT(sItem), NULL);
               if (ulID != pArea->areadata.ulTemplateID)
               {
                  pArea->areadata.ulTemplateID = ulID;
                  arealiste.bDirty = TRUE;
                  pArea->dirty=TRUE;
               }
            }
         }
         break;

      case WM_COMMAND:
         return (MRESULT) FALSE;

      case WM_CONTROL:
         if (SHORT1FROMMP(mp1)==IDD_AS_GENERAL+3)
            if (SHORT2FROMMP(mp1)==EN_KILLFOCUS)
            {
               char pchTempTag[LEN_AREATAG+1];

               WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1, pchTempTag);
               SendMsg(hwndSettingsFrame,
                          APM_SETTITLE, pchTempTag, NULL);
            }
         if (SHORT1FROMMP(mp1) == IDD_AS_GENERAL+15)
            if (SHORT2FROMMP(mp1) == BN_CLICKED ||
                SHORT2FROMMP(mp1) == BN_DBLCLICKED)
            {
               if (WinQueryButtonCheckstate(parent, IDD_AS_GENERAL+15))
                  WinEnableControl(parent, IDD_AS_GENERAL+7, FALSE);
               else
                  WinEnableControl(parent, IDD_AS_GENERAL+7, TRUE);
            }
         break;

      case APM_REQCLOSE:
         WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1,
                             pchTemp);
         if (pchTemp[0] == 0)
         {
            /* Fehler, kein Area-Tag */
            if (MessageBox(parent, IDST_MSG_NOAREATAG, 0,
                           IDD_NOAREATAG, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                return (MRESULT) 2;
            else
                return (MRESULT) 1;
         }
         else
         {
            pAreaTemp = AM_FindArea(&arealiste, pchTemp);
            if (pAreaTemp && pAreaTemp != pArea)
            {
               /* Fehler, schon vorhanden */
               if (MessageBox(parent, IDST_MSG_ALREADYHAVEAREA, 0,
                              IDD_ALREADYHAVEAREA, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                   return (MRESULT) 2;
               else
                   return (MRESULT) 1;
            }
         }
         return (MRESULT) 0;

      case APM_CANCEL:
         WinSetWindowULong(parent, QWL_USER, 1);
         break;

      default:
         break;
   }
   return WinDefDlgProc(parent,message,mp1,mp2);
}
Esempio n. 25
0
static MRESULT EXPENTRY pm_keyset(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static int set1 = TRUE;
    static int id = 0;

    switch (msg) {
        case WM_INITDLG:
            {
                int j1, j2;

                resources_get_int("JoyDevice1", &j1);
                resources_get_int("JoyDevice2", &j2);
                WinSendMsg(hwnd, WM_KPROCESS, (void*)!!((j1 | j2) & JOYDEV_KEYSET1), (void*)!!((j1 | j2) & JOYDEV_KEYSET2));
            }
            break;
        case WM_CONTROL:
            {
                int ctrl = SHORT1FROMMP(mp1);

                switch (ctrl) {
                    case RB_SET1:
                    case RB_SET2:
                        if (!(ctrl == RB_SET1 && set1) && !(ctrl == RB_SET2 && !set1)) {
                            set1 = !set1;
                            WinSendMsg(hwnd, WM_KENABLECTRL, 0, 0);
                            WinSendMsg(hwnd, WM_KFILLSPB, 0, 0);
                        }
                        break;
                    case SPB_N:
                    case SPB_NE:
                    case SPB_E:
                    case SPB_SE:
                    case SPB_S:
                    case SPB_SW:
                    case SPB_W:
                    case SPB_NW:
                    case SPB_FIRE:
                        if (SHORT2FROMMP(mp1) == SPBN_SETFOCUS) {
                            id = ctrl;
                        }
                        break;
                }
                break;
            }
        case WM_KPROCESS:
            if (((int)mp1 ^ (int)mp2) & 1) {
                set1 = (int)mp1;
            }

            WinCheckButton(hwnd, set1 ? RB_SET1 : RB_SET2, 1);
            WinEnableControl(hwnd, RB_SET1, (ULONG)mp1);
            WinEnableControl(hwnd, RB_SET2, (ULONG)mp2);

            WinSendMsg(hwnd, WM_KENABLECTRL, (void*)(!mp1 && !mp2), NULL);
            WinSendMsg(hwnd, WM_KFILLSPB, 0, 0);
            break;
        case WM_TRANSLATEACCEL:
            if (id >= SPB_N && id <= SPB_FIRE) {
                //
                // Returning FALSE and using WM_CHAR doesn't work
                // for all keys - I don't know why
                //
                SetKeyVal(hwnd, id, set1, CHAR4FROMMP(((QMSG*)mp1)->mp1));
                return FALSE;
            }
            break;
        case WM_SETKEY:
            {
                ULONG state1 = mp1 ? 1 : 0;
                ULONG state2 = mp2 ? 1 : 0;

                WinEnableControl(hwnd, RB_SET1, state1);
                WinEnableControl(hwnd, RB_SET2, state2);
                WinSendMsg(hwnd, WM_KPROCESS, (void*)state1, (void*)state2);
            }
            break;
        case WM_KENABLECTRL:
            WinEnableControl(hwnd, SPB_N, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_E, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_S, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_W, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_NE, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_SE, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_SW, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_NW, mp1 ? 0 : 1);
            WinEnableControl(hwnd, SPB_FIRE, mp1 ? 0 : 1);
            return FALSE;
        case WM_KFILLSPB:
            UpdateKeyVal(hwnd, SPB_N, set1);
            UpdateKeyVal(hwnd, SPB_E, set1);
            UpdateKeyVal(hwnd, SPB_S, set1);
            UpdateKeyVal(hwnd, SPB_W, set1);
            UpdateKeyVal(hwnd, SPB_NE, set1);
            UpdateKeyVal(hwnd, SPB_SE, set1);
            UpdateKeyVal(hwnd, SPB_SW, set1);
            UpdateKeyVal(hwnd, SPB_NW, set1);
            UpdateKeyVal(hwnd, SPB_FIRE, set1);
            return FALSE;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_Echo_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_echo;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Clicker.Settings.Keyboard_echo ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.Play_sound, BM_SETCHECK, MPFROMLONG( Value ), 0 );
     WinEnableControl( Window, Keyboard_Echo.Settings.For_IRC, Value );
     WinEnableControl( Window, Keyboard_Echo.Settings.For_ICQ, Value );
     WinEnableControl( Window, Keyboard_Echo.Settings.Use_RAMFS, Value );

     Value = 0; if( Clicker.Settings.Keyboard_echo_for_IRC ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.For_IRC, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Clicker.Settings.Keyboard_echo_for_ICQ ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.For_ICQ, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Clicker.Settings.Cache_echo_file ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.Use_RAMFS, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.Play_sound )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo = 0;
           else Clicker.Settings.Keyboard_echo = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.For_IRC )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo_for_IRC = 0;
           else Clicker.Settings.Keyboard_echo_for_IRC = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.For_ICQ )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo_for_ICQ = 0;
           else Clicker.Settings.Keyboard_echo_for_ICQ = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.Use_RAMFS )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Cache_echo_file = 0;
           else Clicker.Settings.Cache_echo_file = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo", &Clicker.Settings.Keyboard_echo, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo for IRC", &Clicker.Settings.Keyboard_echo_for_IRC, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo for ICQ", &Clicker.Settings.Keyboard_echo_for_ICQ, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Cache echo file", &Clicker.Settings.Cache_echo_file, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
Esempio n. 27
0
//==========================================================================
// processa il messaggio WM_CONTROL
// - se cambiato stato checkbox Enable abilita/disabilita altri controlli
// parametri:
// HWND hwnd: handle dialogo
// ULONG idCtl: identit… controllo
// ULONG ulEvent: identit… evento
// valore restituito:
// VOID
//==========================================================================
static
VOID MouseOptControl(HWND hwnd, ULONG idCtl, ULONG ulEvent) {
   switch (idCtl) {
      // opzioni autofocus
      case CHK_MAUTFOCUS:           // enable autofocus
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.focusAuto = p->ocur.mou.focusAuto =
                              WinQueryButtonCheckstate(hwnd, CHK_MAUTFOCUS);
            MouseOptSetAutofocusDep(hwnd, p->ocur.mou.focusAuto);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case SPIN_MAUTFOCUS:          // delay autofocus
         if (ulEvent == SPBN_CHANGE) {
            LONG l;
            WinSendDlgItemMsg(hwnd, idCtl, SPBM_QUERYVALUE, (MPARAM)&l,
                              MPFROM2SHORT(0, SPBQ_ALWAYSUPDATE));

            if ((l *= 10) != p->ocur.mou.focusDelay) {
               p->ocur.mou.focusDelay = l;
               EnableToolbarUndoBtn(1);
            } /* endif */
         } else if (ulEvent == SPBN_KILLFOCUS) {
            p->po->mou.focusDelay = p->ocur.mou.focusDelay;
         } /* endif */
         break;
      case CHK_MAFIGNDESK:          // ignore desktop
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.focusNoDesk = p->ocur.mou.focusNoDesk =
                           WinQueryButtonCheckstate(hwnd, CHK_MAFIGNDESK);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case CHK_MAFNOTOP:            // don't bring to top
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.focusNoTop = p->ocur.mou.focusNoTop =
                           WinQueryButtonCheckstate(hwnd, CHK_MAFNOTOP);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case CHK_MAFIGNNEW:           // ignore new windows
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.focusNoNew = p->ocur.mou.focusNoNew =
                           WinQueryButtonCheckstate(hwnd, CHK_MAFIGNNEW);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      // opzioni pointer hiding
      case CHK_MPTRHIDE:            // abilita pointer hiding
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.hide = p->ocur.mou.hide = WinQueryButtonCheckstate(hwnd, CHK_MPTRHIDE);
            MouseOptSetMptrHideDep(hwnd, p->ocur.mou.hide);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case SPIN_MPTRHIDE:           // ritardo pointer hiding
         if (ulEvent == SPBN_CHANGE) {
            LONG l;
            WinSendDlgItemMsg(hwnd, idCtl, SPBM_QUERYVALUE, (MPARAM)&l,
                              MPFROM2SHORT(0, SPBQ_ALWAYSUPDATE));
            if ((l *= 100) != p->ocur.mou.hideDelay) {
               p->ocur.mou.hideDelay = l;
               EnableToolbarUndoBtn(1);
            } /* endif */
         } else if (ulEvent == SPBN_KILLFOCUS) {
            p->po->mou.hideDelay = p->ocur.mou.hideDelay;
         } /* endif */
         break;
      case CHK_MPHXCLBTN:           // exclude buttons
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.hideNotOnBtn = p->ocur.mou.hideNotOnBtn =
                           WinQueryButtonCheckstate(hwnd, CHK_MPHXCLBTN);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case CHK_MPHXCLMENU:          // exclude menu
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.hideNotOnMenu = p->ocur.mou.hideNotOnMenu =
                           WinQueryButtonCheckstate(hwnd, CHK_MPHXCLMENU);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      // opzione remap tasto 3
      case CHK_MBTN3MAP:
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.btn3dblClk = p->ocur.mou.btn3dblClk =
                           WinQueryButtonCheckstate(hwnd, CHK_MBTN3MAP);
            WinEnableControl(hwnd, CHK_MBTN3TBAR,
                             p->ocur.mou.btn3dblClk && p->is.mou3btns);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      // opzione include titlebar
      case CHK_MBTN3TBAR:
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.btn3title = p->ocur.mou.btn3title =
                           WinQueryButtonCheckstate(hwnd, CHK_MBTN3TBAR);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      // opzione move pointer to focus window
      case CHK_MMOVETOFOCUS:        // move the pointer to the focus window
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.moveToFocus = p->ocur.mou.moveToFocus =
                            WinQueryButtonCheckstate(hwnd, CHK_MMOVETOFOCUS);
            MouseOptSetMptrMove2FocusDep(hwnd, p->ocur.mou.moveToFocus);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case SPIN_MMTFSTEPS:           // ritardo pointer hiding
         if (ulEvent == SPBN_CHANGE) {
            LONG l;
            WinSendDlgItemMsg(hwnd, idCtl, SPBM_QUERYVALUE, (MPARAM)&l,
                              MPFROM2SHORT(0, SPBQ_ALWAYSUPDATE));
            if ((l) != p->ocur.mou.moveSteps) {
               p->ocur.mou.moveSteps = l;
               EnableToolbarUndoBtn(1);
            } /* endif */
         } else if (ulEvent == SPBN_KILLFOCUS) {
            p->po->mou.moveSteps = p->ocur.mou.moveSteps;
         } /* endif */
         break;
      case CHK_MMTFWINCREATE:   // check box
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.moveToNew = p->ocur.mou.moveToNew =
                           WinQueryButtonCheckstate(hwnd, CHK_MMTFWINCREATE);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case CHK_MMTFWINDLG:
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.moveToDlg = p->ocur.mou.moveToDlg =
                               WinQueryButtonCheckstate(hwnd, CHK_MMTFWINDLG);
            WinEnableControl(hwnd, CHK_MMTFXCLDLGNOBTN, p->ocur.mou.moveToDlg);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
      case CHK_MMTFXCLDLGNOBTN:   // check box
         if (ulEvent == BN_CLICKED || ulEvent == BN_DBLCLICKED) {
            p->po->mou.moveNotBtnles = p->ocur.mou.moveNotBtnles =
                           WinQueryButtonCheckstate(hwnd, CHK_MMTFXCLDLGNOBTN);
            EnableToolbarUndoBtn(1);
         } // end if
         break;
   } /* endswitch */
}
Esempio n. 28
0
static MRESULT EXPENTRY pm_joystick(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg) {
        case WM_INITDLG:
            {
                int joy1, joy2;
                //
                // disable controls of non existing joysticks
                // remark: I think this cannot change while runtime
                //
                if (!(number_joysticks & JOYDEV_HW1)) {
                    WinEnableControl(hwnd, CB_JOY11, 0);
                    WinEnableControl(hwnd, CB_JOY12, 0);
                }
                if (!(number_joysticks&JOYDEV_HW2)) {
                    WinEnableControl(hwnd, CB_JOY21, 0);
                    WinEnableControl(hwnd, CB_JOY22, 0);
                }
                if (number_joysticks == 0) {
                    WinEnableControl(hwnd, ID_CALIBRATE, 0);
                }

                if (machine_class == VICE_MACHINE_VIC20) {
                    WinEnableControl(hwnd, CB_JOY12, 0);
                    WinEnableControl(hwnd, CB_JOY22, 0);
                    WinEnableControl(hwnd, CB_NUMJOY2, 0);
                    WinEnableControl(hwnd, CB_KS1JOY2, 0);
                    WinEnableControl(hwnd, CB_KS2JOY2, 0);
                    WinEnableControl(hwnd, ID_SWAP, 0);
                }

                resources_get_int("JoyDevice1", &joy1);
                resources_get_int("JoyDevice2", &joy2);
                WinSendMsg(hwnd, WM_SETCBS, (void*)joy1, (void*)joy2);
            }
            break;
        case WM_DESTROY:
        case WM_CLOSE:
            {
                if (WinIsWindowVisible(hwndCalibrate)) {
                    WinSendMsg(hwndCalibrate, WM_CLOSE, 0, 0);
                }

                if (WinIsWindowVisible(hwndKeyset)) {
                    WinSendMsg(hwndKeyset, WM_CLOSE, 0, 0);
                }
            }
            break;
        case WM_COMMAND:
            switch(LONGFROMMP(mp1)) {
                case DID_CLOSE:
                    {
                        if (WinIsWindowVisible(hwndCalibrate)) {
                            WinSendMsg(hwndCalibrate, WM_CLOSE, 0, 0);
                        }

                        if (WinIsWindowVisible(hwndKeyset)) {
                            WinSendMsg(hwndKeyset, WM_CLOSE, 0, 0);
                        }
                    }
                    break;
                case ID_SWAP:
                    {
                        int joy1, joy2;

                        resources_get_int("JoyDevice1", &joy1);
                        resources_get_int("JoyDevice2", &joy2);

                        resources_set_int("JoyDevice1", joy2);
                        resources_set_int("JoyDevice2", joy1);

                        WinSendMsg(hwnd, WM_SETCBS,  (void*)joy2, (void*)joy1);
                    }
                    return FALSE;
                case ID_CALIBRATE:
                    calibrate_dialog(hwnd);
                    return FALSE;
                case ID_KEYSET:
                    keyset_dialog(hwnd);
                    return FALSE;;
            }
            break;
        case WM_CONTROL:
            {
                int button =SHORT1FROMMP(mp1);
                int state = WinQueryButtonCheckstate(hwnd, button);
                int port = button & JOY_PORT1;
                int joya, joyb;

                resources_get_int(port ? "JoyDevice1" : "JoyDevice2", &joya);
                resources_get_int(port ? "JoyDevice2" : "JoyDevice1", &joyb);
                if (state) {
                    joya |= button & JOYDEV_ALL;
                } else {
                    joya &= ~(button & JOYDEV_ALL);
                }

                resources_set_int(port ? "JoyDevice1" : "JoyDevice2", joya);
                WinSendMsg(hwnd, WM_SETDLGS, (void*)(port ? joya : joyb), (void*)(port ? joyb : joya));

             }
             break;
        case WM_SETDLGS:
            {
                int joy1 = (int)mp1;
                int joy2 = (int)mp2;
                int joys = joy1 | joy2;

                if (WinIsWindowVisible(hwndCalibrate)) {
                    WinSendMsg(hwndCalibrate, WM_SETJOY, (MPARAM)(joys & JOYDEV_HW1), (MPARAM)(joys & JOYDEV_HW2));
                }

                if (WinIsWindowVisible(hwndKeyset)) {
                    WinSendMsg(hwndKeyset, WM_SETKEY, (MPARAM)(joys&JOYDEV_KEYSET1), (MPARAM)(joys&JOYDEV_KEYSET2));
                }
            }
            break;
        case WM_SETCBS:
            WinCheckButton(hwnd, CB_JOY11, (JOYDEV_HW1 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY12, (JOYDEV_HW1 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY21, (JOYDEV_HW2 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY22, (JOYDEV_HW2 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_NUMJOY1, (JOYDEV_NUMPAD & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_NUMJOY2, (JOYDEV_NUMPAD & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS1JOY1, (JOYDEV_KEYSET1 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS1JOY2, (JOYDEV_KEYSET1 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS2JOY1, (JOYDEV_KEYSET2 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS2JOY2, (JOYDEV_KEYSET2 & (int)mp2) ? 1 : 0);
            break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
Esempio n. 29
0
static MRESULT EXPENTRY pm_emulator(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    // FIXME: Speed=0 'No Limit' is missing
    static int first = TRUE;
    const char psz[11][6] = {
        " Auto",
        " 1/1",
        " 1/2",
        " 1/3",
        " 1/4",
        " 1/5",
        " 1/6",
        " 1/7",
        " 1/8",
        " 1/9",
        " 1/10"
    };

    switch (msg) {
        case WM_INITDLG:
            {
            int val=0;

                for (val = 0; val < 11; val++) {
                    WinDlgLboxInsertItem(hwnd, CBS_REFRATE, psz[val]);
                }
                resources_get_int("Speed", &val);
                WinSetDlgSpinVal(hwnd, SPB_SPEED, val);
                WinEnableControl(hwnd, PB_SPEED100, (val!=100));
                resources_get_int("RefreshRate", &val);
                WinDlgLboxSelectItem(hwnd, CBS_REFRATE, val);
            }
            break;
        case WM_COMMAND:
            switch (LONGFROMMP(mp1)) {
                case PB_SPEED100:
                WinSetDlgSpinVal(hwnd, SPB_SPEED, 100);
                vsync_suspend_speed_eval();
                resources_set_int("Speed", 100);
                WinEnableControl(hwnd, PB_SPEED100, FALSE);
                return FALSE;
            }
            break;
        case WM_DISPLAY:
            {
                char txt1[8] = "---%";
                char txt2[8] = "--fps";

                if ((int)mp1 < 100000) {
                    sprintf(txt1, "%5d%%", mp1);
                }
                if ((int)mp2 < 10000) {
                    sprintf(txt2, "%4dfps", mp2);
                }
                WinSetDlgItemText(hwnd, ID_SPEEDDISP, txt1);
                WinSetDlgItemText(hwnd, ID_REFRATEDISP, txt2);
            }
            return FALSE;
        case WM_CONTROL:
            {
                const int ctrl = SHORT1FROMMP(mp1);

                switch (ctrl) {
                    case SPB_SPEED:
                        if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN) {
                            const ULONG val = WinGetSpinVal((HWND)mp2);

                            vsync_suspend_speed_eval();
                            resources_set_int("Speed", val);
                            WinEnableControl(hwnd, PB_SPEED100, (val != 100));
                        }
                        break;
                    case CBS_REFRATE:
                        if (SHORT2FROMMP(mp1) == LN_SELECT) {
                            const int val = WinQueryLboxSelectedItem((HWND)mp2);

                            resources_set_int("RefreshRate", val);
                        }
                        break;
                }
                break;
            }
            break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
/*************************************************************************
 *
 * 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 */