void Window::scrollHorz( int delta, int left, int right ) { RECTL scrollRect = { left, 0, right, height }; WinScrollWindow( hWndClient, delta, 0, &scrollRect, &scrollRect, NULLHANDLE, NULL, SW_INVALIDATERGN ); }
/* * _ShiftWindow - move current window up/down */ void _ShiftWindow( LPWDATA w, int diff ) { HWND hwnd; int amt; LPSTR txt_s,txt_d; int i,sline,eline,add; hwnd = w->hwnd; amt = -diff*w->ychar; #if defined( __OS2__ ) { RECTL rcl; WinQueryWindowRect( hwnd, &rcl ); WinScrollWindow( hwnd, 0, -amt, NULL, &rcl, NULL, NULL, SW_INVALIDATERGN ); } #else { RECT rect; GetClientRect( hwnd, &rect ); i = (rect.bottom + 1) / w->ychar; rect.bottom = i * w->ychar; ScrollWindow( hwnd, 0, amt, NULL, &rect ); } #endif if( diff < 0 ) { sline = w->height - 3 + diff; if( sline < 0 ) sline = 0; eline = 0; add = -1; } else { sline = diff; eline = w->height - 1; if( eline < sline ) eline = sline; add = 1; } i = sline; while( i != eline ) { txt_s = (LPSTR)&w->image[i * w->width]; txt_d = (LPSTR)&w->image[(i - diff) * w->width]; #ifdef _MBCS FARmemcpy( txt_d, txt_s, sizeof( mb_char ) * w->width ); #else FARmemcpy( txt_d, txt_s, w->width ); #endif i += add; } } /* _ShiftWindow */
void Window::scrollVert( int delta, int bottom, int top ) { RECTL scrollRect = { 0, bottom, width, top }; RECTL invalidated; WinScrollWindow( hWndClient, 0, delta, &scrollRect, &scrollRect, NULLHANDLE, &invalidated, NULL ); // Why do I have to do this? I don't know!!! SW_INVALIDATEREGION doesn't // work if several WinScrollWindows are done in a row. The below line should // do the same thing, but apparently it doesn't WinInvalidateRect( hWndClient, &invalidated, FALSE ); }
MRESULT MainVertScroll(HWND hwnd, /* handle to the main client window */ MPARAM mp2) { LONG sVscrollInc; switch (SHORT2FROMMP (mp2)) { case SB_LINEUP: sVscrollInc = -1 ; break ; case SB_LINEDOWN: sVscrollInc = 1 ; break ; case SB_PAGEUP: sVscrollInc = min (-1, -cyClient / cyChar) ; break ; case SB_PAGEDOWN: sVscrollInc = max (1, cyClient / cyChar) ; break ; case SB_SLIDERTRACK: sVscrollInc = SHORT1FROMMP (mp2) - sVscrollPos; break ; default: sVscrollInc = 0; break ; } sVscrollInc = max (-sVscrollPos, min (sVscrollInc, sVscrollMax - sVscrollPos)) ; if (sVscrollInc != 0) { sVscrollPos += sVscrollInc ; WinScrollWindow ((HWND)hwnd, 0, (cyChar * sVscrollInc), (PRECTL)NULL, (PRECTL)NULL, (HRGN)NULL, (PRECTL)NULL, SW_INVALIDATERGN); WinSendMsg (hwndVscroll, SBM_SETPOS, MPFROMSHORT (sVscrollPos), MPVOID) ; WinUpdateWindow (hwnd) ; } return (MRFROMLONG(0)); }
MRESULT MainHorizScroll(HWND hwnd, /* handle to the main client window */ MPARAM mp2) { LONG sHscrollInc; switch (SHORT2FROMMP (mp2)) { case SB_LINELEFT: sHscrollInc = -cxCaps ; break ; case SB_LINERIGHT: sHscrollInc = cxCaps ; break ; case SB_PAGELEFT: sHscrollInc = -8 * cxCaps ; break ; case SB_PAGERIGHT: sHscrollInc = 8 * cxCaps ; break ; case SB_SLIDERPOSITION: sHscrollInc = SHORT1FROMMP (mp2) - sHscrollPos; break ; default: sHscrollInc = 0; break ; } sHscrollInc = max (-sHscrollPos, min (sHscrollInc, sHscrollMax - sHscrollPos)) ; if (sHscrollInc != 0) { sHscrollPos += sHscrollInc ; WinScrollWindow ((HWND)hwnd, -sHscrollInc, 0, (PRECTL)NULL, (PRECTL)NULL, (HRGN)NULL, (PRECTL)NULL, SW_INVALIDATERGN); WinSendMsg (hwndHscroll, SBM_SETPOS, MPFROMSHORT (sHscrollPos), MPVOID) ; } return (MRFROMLONG(0)); }
/*------------------------------------------------------------------------*/ MRESULT EXPENTRY CanvasWndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { HPS hps; RECTL rcl; SHORT sVscrollInc; /* Vertical scrollbar incr val */ SHORT sHscrollInc; /* Horizontal scrollbar incr val */ switch (msg) { case WM_CREATE: view.hwndVscroll = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_VERTSCROLL); view.hwndHscroll = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_HORZSCROLL); view.iZoom = ZOOM_NORMAL; view.hwndClient = hwnd; return 0; case WM_SIZE: view.cxCanvas = (LONG)SHORT1FROMMP (mp2); view.cyCanvas = (LONG)SHORT2FROMMP (mp2); CanvScrollBar(pwiCanv, TRUE); return 0; case WM_CHAR: if (SHORT1FROMMP(mp1) & KC_KEYUP ) return 0; if (SHORT1FROMMP(mp1) & KC_INVALIDCHAR ) return 0; if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) { switch (SHORT2FROMMP(mp2)) { case VK_ESC: return KeybEsc(); /* see drwmain */ case VK_PAGEUP: case VK_PAGEDOWN: return WinSendMsg(view.hwndVscroll,msg,mp1,mp2); } } return (MRESULT)0; case WM_PAINT: hps = WinBeginPaint(hwnd,(HPS)0,NULL); WinQueryWindowRect(hwnd, &rcl); WinFillRect(hps,&rcl,CLR_DARKGRAY); WinEndPaint(hps); return 0; /*========================Vertical=Scrolling================================*/ case WM_VSCROLL: switch (SHORT2FROMMP (mp2)) { case SB_LINEUP: sVscrollInc = -pwiCanv->fattrs.lMaxBaselineExt; break; case SB_LINEDOWN: sVscrollInc = pwiCanv->fattrs.lMaxBaselineExt; break; case SB_PAGEUP: sVscrollInc = -view.cyCanvas; break; case SB_PAGEDOWN: sVscrollInc = view.cyCanvas; break; case SB_SLIDERPOSITION: sVscrollInc = SHORT1FROMMP (mp2) - view.sVscrollPos; break; default: sVscrollInc = 0; break; } sVscrollInc = max(-view.sVscrollPos, min(sVscrollInc,view.sVscrollMax - view.sVscrollPos)); if ( sVscrollInc != 0 ) { view.sVscrollPos += sVscrollInc; WinScrollWindow (hwnd,0,sVscrollInc,(PRECTL)NULL, (PRECTL)NULL,(HRGN)NULLHANDLE, (PRECTL)NULL,SW_INVALIDATERGN | SW_SCROLLCHILDREN ); WinSendMsg (view.hwndVscroll, SBM_SETPOS, MPFROMSHORT (view.sVscrollPos), NULL); WinUpdateWindow (hwnd); } return 0; /*========================Horizontal=Scrolling==============================*/ case WM_HSCROLL: switch(SHORT2FROMMP (mp2)) { case SB_LINELEFT: sHscrollInc = -pwiCanv->fattrs.lAveCharWidth; break; case SB_LINERIGHT: sHscrollInc = pwiCanv->fattrs.lAveCharWidth; break; case SB_PAGELEFT: sHscrollInc = -view.cxCanvas; break; case SB_PAGERIGHT: sHscrollInc = view.cxCanvas; break; case SB_SLIDERPOSITION: sHscrollInc = SHORT1FROMMP (mp2) - view.sHscrollPos; break; default: sHscrollInc = 0; break; } sHscrollInc = max ( -view.sHscrollPos, min (sHscrollInc, view.sHscrollMax - view.sHscrollPos)); if ( sHscrollInc !=0) { view.sHscrollPos += sHscrollInc; WinScrollWindow(hwnd,-sHscrollInc,0L, (PRECTL)NULL,(PRECTL)NULL, (HRGN)NULLHANDLE,(PRECTL)NULL, SW_INVALIDATERGN | SW_SCROLLCHILDREN); WinSendMsg (view.hwndHscroll, SBM_SETPOS, MPFROMSHORT (view.sHscrollPos), NULL); WinUpdateWindow (hwnd); } return 0; } return WinDefWindowProc (hwnd ,msg,mp1,mp2); }
/* * * BrowseWndProc * * DESCRIPTION: * * Processes messages for the Browse-O-Matic client window. * */ MRESULT EXPENTRY BrowseWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { switch( msg){ case WM_CREATE: { CHAR pszTitle[ MAX_TITLE_LENGTH]; PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA)mp1; WinSetWindowPtr( hwnd, QWL_USER, pWindowData); /*******************/ /* Load the object */ /*******************/ _LoadObject( pWindowData->somSelf, pWindowData->pszObjectName, &pWindowData->ulFileLength, &pWindowData->pBuffer, &pWindowData->pLines, &pWindowData->usNumberOfTextLines, &pWindowData->usNumberOfTextColumns); _GetLinesAndColumns( pWindowData->somSelf, pWindowData->bDisplay, &pWindowData->sTotalLines, &pWindowData->sTotalColumns, pWindowData->usNumberOfTextLines, pWindowData->usNumberOfTextColumns, pWindowData->ulFileLength); /*********************************************/ /* Get the window handle for the scroll bars */ /*********************************************/ pWindowData->hwndVscroll = WinWindowFromID( WinQueryWindow( hwnd, QW_PARENT), FID_VERTSCROLL); pWindowData->hwndHscroll = WinWindowFromID( WinQueryWindow( hwnd, QW_PARENT), FID_HORZSCROLL); /*************************/ /* Save font information */ /*************************/ WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0); /*****************/ /* Get the focus */ /*****************/ WinSetFocus( HWND_DESKTOP, hwnd); /*****************************************************/ /* Create the title for the Browse-O-Matic title bar */ /*****************************************************/ if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE) sprintf( pszTitle, "Object: %s (%d Bytes)", pWindowData->pszObjectName, pWindowData->ulFileLength); else sprintf( pszTitle, "Object: %s (%hd Lines)", pWindowData->pszObjectName, pWindowData->sTotalLines); /************************************************/ /* Register the current open view of the object */ /************************************************/ _wpAddToObjUseList( pWindowData->somSelf, &(pWindowData->UseItem)); _wpRegisterView( pWindowData->somSelf, WinQueryWindow( hwnd, QW_PARENT), pszTitle); } break; case WM_CLOSE: { HWND hwndFrame; PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER); hwndFrame = WinQueryWindow( hwnd, QW_PARENT); /*****************************************************/ /* Save the window info - size, location, and fonts. */ /*****************************************************/ WinStoreWindowPos( APPL_NAME, pWindowData->pszApplKey, hwndFrame); /**********************************************************/ /* Free the window data and unload the file system object */ /**********************************************************/ if( pWindowData){ if( pWindowData->pszObjectName) _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData->pszObjectName); _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData); } _UnloadObject( pWindowData->somSelf, pWindowData->pBuffer, pWindowData->pLines); _wpDeleteFromObjUseList( pWindowData->somSelf, &pWindowData->UseItem); /*******************/ /* Kill the window */ /*******************/ WinPostMsg( hwnd, WM_QUIT, 0, 0 ); WinDestroyWindow( hwndFrame); } break; /*******************************************************************/ /* The font characteristics have changed. This happens when a font */ /* from the font palette is dropped on the client window. */ /*******************************************************************/ case WM_PRESPARAMCHANGED: { PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER); if( (ULONG)mp1 == PP_FONTNAMESIZE){ /***********************************************/ /* Get the new font information and redraw the */ /* window with the new font/font size. */ /***********************************************/ WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0); WinSendMsg( hwnd, WM_SIZE, 0, MPFROM2SHORT( pWindowData->sClientWidth, pWindowData->sClientHeight)); } } break; case WM_SIZE: { PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER); /***************************************/ /* Save client window size information */ /***************************************/ pWindowData->sClientWidth = SHORT1FROMMP( mp2); pWindowData->sClientHeight = SHORT2FROMMP( mp2); pWindowData->sPageHeight = pWindowData->sClientHeight/ pWindowData->sCharHeight; pWindowData->sPageWidth = pWindowData->sClientWidth / pWindowData->sCharWidth; /**************************************/ /* Set the ranges for the scroll bars */ /**************************************/ WinPostMsg( pWindowData->hwndVscroll, SBM_SETSCROLLBAR, (MPARAM)pWindowData->sCurrentLine, MPFROM2SHORT( 0, pWindowData->sTotalLines - pWindowData->sPageHeight)); WinPostMsg( pWindowData->hwndHscroll, SBM_SETSCROLLBAR, (MPARAM)pWindowData->sCurrentColumn, MPFROM2SHORT( 0, pWindowData->sTotalColumns - pWindowData->sPageWidth)); /*************************************/ /* Set scroll bar thumb control size */ /*************************************/ WinPostMsg( pWindowData->hwndVscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT( pWindowData->sPageHeight, pWindowData->sTotalLines), (MPARAM) 0); WinPostMsg( pWindowData->hwndHscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT( pWindowData->sPageWidth, pWindowData->sTotalColumns), (MPARAM) 0); /************************************************************/ /* If the all the lines and/or columns can fit in the new */ /* sized window, set the sCurrentLine and/or sCurrentColumn */ /* to the top/right side. */ /************************************************************/ if( pWindowData->sPageHeight >= pWindowData->sTotalLines) pWindowData->sCurrentLine = 0; if( pWindowData->sPageWidth >= pWindowData->sTotalColumns) pWindowData->sCurrentColumn = 0; /********************************************/ /* Repaint window with new size information */ /********************************************/ WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); case WM_PAINT: { HPS hps; CHAR pszText[255]; UINT nLength = 0; RECTL rect; POINTL point; SHORT sLine; SHORT sTopLine; SHORT sBottomLine; SHORT sLinesFromTop; PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER); hps = WinBeginPaint( hwnd, NULLHANDLE, &rect); /*******************************************/ /* Clear the area that needs to be redrawn */ /*******************************************/ GpiErase( hps); /********************************/ /* Determine first clipped line */ /********************************/ sLinesFromTop = ( pWindowData->sClientHeight - rect.yTop) / pWindowData->sCharHeight; rect.yTop = pWindowData->sClientHeight - ( pWindowData->sCharHeight * sLinesFromTop); /***************************************************************/ /* Determine the first position to write at. NOTE: PM handles */ /* clipping for point.x < 0. Any characters written before the */ /* the first column or after the last column are clipped. */ /***************************************************************/ point.y = rect.yTop - pWindowData->sCharHeight + pWindowData->sCharDescender; point.x = pWindowData->sCurrentColumn*pWindowData->sCharWidth * -1; /***********************************************/ /* Determine the top and bottom lines to write */ /***********************************************/ sTopLine = rect.yTop / pWindowData->sCharHeight; sBottomLine = rect.yBottom / pWindowData->sCharHeight; /*********************************************************/ /* Make sure that we aren't trying to display more lines */ /* then are available. */ /*********************************************************/ if( pWindowData->sPageHeight - sBottomLine + 1 > pWindowData->sTotalLines - pWindowData->sCurrentLine) sBottomLine=pWindowData->sPageHeight-(pWindowData->sTotalLines - pWindowData->sCurrentLine) + 1; /********************************/ /* Redraw the invalid rectangle */ /********************************/ for( sLine = sTopLine; sLine >= sBottomLine; sLine--){ /*******************************************/ /* Get the line of text or hex information */ /* that we are going to write. */ /*******************************************/ if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE) nLength = _GetHexLine( pWindowData->somSelf, pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine +1, pWindowData->pBuffer, pWindowData->ulFileLength, pszText); else nLength = _GetTextLine( pWindowData->somSelf, pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine +1, pWindowData->pLines, pszText); /******************/ /* Write the text */ /******************/ if( nLength != 0) GpiCharStringAt( hps, &point, nLength, pszText); point.y -= pWindowData->sCharHeight; } WinEndPaint( hps); } return( 0); /*******************************************/ /* Keyboard support for scrolling and help */ /*******************************************/ case WM_CHAR: /****************************************/ /* Show general help if user selects F1 */ /****************************************/ if( CHARMSG( &msg)->vkey == VK_F1){ PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER); _wpDisplayHelp( pWindowData->somSelf, PANEL_MAIN, "browse.hlp"); return 0; } if( (CHARMSG( &msg)->fs & KC_KEYUP)) return 0; switch( CHARMSG( &msg)->vkey){ case VK_UP: WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEUP)); return 0; case VK_DOWN: WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEDOWN)); return 0; case VK_RIGHT: /************************************************************/ /* Ctrl-Right scrolls one page to the right. Right scrolls */ /* to the right. */ /************************************************************/ if( (CHARMSG( &msg)->fs & KC_CTRL)) WinPostMsg( hwnd, WM_HSCROLL, 0, MPFROM2SHORT(0, SB_PAGERIGHT)); else WinPostMsg( hwnd, WM_HSCROLL, 0, MPFROM2SHORT(0, SB_LINERIGHT)); return 0; case VK_LEFT: /*********************************************************/ /* Ctrl-Left scrolls one page to the left. Left scrolls */ /* to the Left. */ /*********************************************************/ if( (CHARMSG( &msg)->fs & KC_CTRL)) WinPostMsg( hwnd, WM_HSCROLL, 0, MPFROM2SHORT( 0, SB_PAGELEFT)); else WinPostMsg( hwnd, WM_HSCROLL, 0, MPFROM2SHORT( 0, SB_LINELEFT)); return 0; case VK_PAGEUP: WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEUP)); return 0; case VK_PAGEDOWN: WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEDOWN)); return 0; case VK_HOME: { PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER); /*********************************************************/ /* Ctrl-Home positions at the first line, Home positions */ /* at the beginning of the current line. */ /*********************************************************/ if( (CHARMSG( &msg)->fs & KC_CTRL)){ WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT( 0, SB_SLIDERPOSITION)); WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, MPFROMSHORT( 0), 0); } else{ WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT( 0, SB_SLIDERPOSITION)); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, MPFROMSHORT( 0), 0); } return 0; } case VK_END: { PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER); /*********************************************************/ /* Ctrl-End positions at the last line, End positions at */ /* the end of the current line. */ /*********************************************************/ if( (CHARMSG( &msg)->fs & KC_CTRL)){ WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT( pWindowData->sTotalLines - pWindowData->sPageHeight, SB_SLIDERPOSITION)); WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, MPFROMSHORT( pWindowData->sTotalLines - pWindowData->sPageHeight), 0); } else{ WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT( pWindowData->sTotalColumns - pWindowData->sPageWidth, SB_SLIDERPOSITION)); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, MPFROMSHORT( pWindowData->sTotalColumns - pWindowData->sPageWidth), 0); } return 0; } } break; /******************/ /* Scroll Up/Down */ /******************/ case WM_VSCROLL: { PBROWSEDATA pWindowData; pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER); switch( SHORT2FROMMP( mp2)){ case SB_LINEUP: if( pWindowData->sCurrentLine > 0){ pWindowData->sCurrentLine--; WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentLine, 0); WinScrollWindow( hwnd, 0, pWindowData->sCharHeight * -1, NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN); } return( 0); case SB_LINEDOWN: if( pWindowData->sCurrentLine < pWindowData->sTotalLines - pWindowData->sPageHeight){ pWindowData->sCurrentLine++; WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentLine, 0); WinScrollWindow( hwnd, 0, pWindowData->sCharHeight, NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN); } return( 0); case SB_PAGEUP: if( pWindowData->sCurrentLine > 0){ pWindowData->sCurrentLine = max( 0, pWindowData->sCurrentLine - pWindowData->sPageHeight); WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentLine,0); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); case SB_PAGEDOWN: if( pWindowData->sCurrentLine < pWindowData->sTotalLines - pWindowData->sPageHeight){ pWindowData->sCurrentLine= min( pWindowData->sTotalLines - pWindowData->sPageHeight, pWindowData->sCurrentLine + pWindowData->sPageHeight); WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentLine,0); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); case SB_SLIDERPOSITION: /***********************************************************/ /* Can't change current line if all the text fits in the */ /* window. */ /***********************************************************/ if( pWindowData->sTotalLines > pWindowData->sPageHeight){ pWindowData->sCurrentLine = SHORT1FROMMP( mp2); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); } } break; /*********************/ /* Scroll Right/Left */ /*********************/ case WM_HSCROLL: { PBROWSEDATA pWindowData; pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER); switch( SHORT2FROMMP( mp2)){ case SB_LINELEFT: if( pWindowData->sCurrentColumn > 0){ pWindowData->sCurrentColumn = max( 0, pWindowData->sCurrentColumn - 1); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentColumn,0); WinScrollWindow( hwnd, pWindowData->sCharWidth, 0, NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN); } return( 0); case SB_LINERIGHT: if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns - pWindowData->sPageWidth){ pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns, pWindowData->sCurrentColumn + 1); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentColumn, 0); WinScrollWindow( hwnd, pWindowData->sCharWidth * -1, 0, NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN); } return( 0); case SB_PAGELEFT: if( pWindowData->sCurrentColumn > 0){ pWindowData->sCurrentColumn = max( 0, pWindowData->sCurrentColumn - pWindowData->sPageWidth); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentColumn, 0); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); case SB_PAGERIGHT: if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns - pWindowData->sPageWidth){ pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns - pWindowData->sPageWidth, pWindowData->sCurrentColumn + pWindowData->sPageWidth); WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS, (MPARAM)pWindowData->sCurrentColumn, 0); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); case SB_SLIDERPOSITION: /***********************************************************/ /* Can't change current column if all the text fits in the */ /* window. */ /***********************************************************/ if( pWindowData->sTotalColumns > pWindowData->sPageWidth){ pWindowData->sCurrentColumn = SHORT1FROMMP( mp2); WinInvalidateRect( hwnd, NULL, FALSE); } return( 0); } } break; /*****************************/ /* Get font size information */ /*****************************/ case IDL_SETFONTINFO: { HPS hps; FONTMETRICS fm; PBROWSEDATA pWindowData; pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER); hps = WinGetPS( hwnd); GpiQueryFontMetrics( hps, sizeof( fm), &fm); WinReleasePS( hps); /***********************************************************/ /* The character width is average of the average uppercase */ /* and average lower case widths. */ /***********************************************************/ pWindowData->sCharWidth = (SHORT)fm.lMaxCharInc; pWindowData->sCharHeight = (SHORT)fm.lMaxBaselineExt; pWindowData->sCharDescender = (SHORT)fm.lMaxDescender; } return( 0); /*********************************************/ /* Display no help available message to user */ /*********************************************/ case HM_HELPSUBITEM_NOT_FOUND: return( ( MRESULT)FALSE); /**************************************/ /* Return name of help for keys panel */ /**************************************/ case HM_QUERY_KEYS_HELP: return( ( MRESULT)PANEL_HELPKEYS); } /********************************************************/ /* Let the default window procedure process the message */ /********************************************************/ return( WinDefWindowProc( hwnd, msg, mp1, mp2)); }