home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
-
-
- char HexDigit[16]={'0','1','2','3',
- '4','5','6','7',
- '8','9','A','B',
- 'C','D','E','F' };
-
- LRESULT WINAPI GrepView( HWND hWnd, UINT wMsg, WPARAM wp, LPARAM lp )
- {
- switch( wMsg )
- {
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hDC;
- RECT r, rOut;
- char szOutPuffer[2048];
- int iElementsPerRow;
- HFONT hPrintFont, hOldFont;
- POINT px;
- char iVal;
- int i,j;
- SIZE s;
-
- hDC = BeginPaint( hWnd, &ps );
-
- hPrintFont = CreateFont( -MulDiv( 10, GetDeviceCaps( hDC, LOGPIXELSY ), 72L ),
- 0, // logical average character width
- 0, // angle of escapement
- 0, // base-line orientation angle
- FW_NORMAL, // font weight
- FALSE, // italic attribute flag
- FALSE, // underline attribute flag
- FALSE, // strikeout attribute flag
- ANSI_CHARSET, // character set identifier
- OUT_DEFAULT_PRECIS, // output precision
- CLIP_DEFAULT_PRECIS, // clipping precision
- DEFAULT_QUALITY, // output quality
- FF_MODERN, // pitch and family
- "Courier New" // pointer to typeface name string
- );
- hOldFont = SelectObject( hDC, hPrintFont );
- GetClientRect( hWnd, &r );
-
- rOut = r;
- // Anzahl der Elemente pro Zeile
-
- GetTextExtentPoint( hDC, " ", 2, &s );
- // Zwei Spaces als Trenner
- iElementsPerRow = (r.right - r.left) - s.cx;
- // Jedes Element ben÷tigt mindestens eine Hex-DIgit und eine Ascii-Digit
-
- GetTextExtentPoint( hDC, "00 a", 2, &s );
- if( s.cx )
- iElementsPerRow /= s.cx;
- else
- iElementsPerRow = 1;
-
- do
- {
- j=0;
- iVal = 'a';
- for( i = 0; i < iElementsPerRow; i++ ) // MaxCount
- {
- szOutPuffer[j++]= HexDigit[(iVal>>4)];
- szOutPuffer[j++]= HexDigit[(iVal&0x0F)];
- szOutPuffer[j++]= ' ';
- iVal++;
- }
- for( ; i < iElementsPerRow; i++ ) // MaxCount
- {
- szOutPuffer[j++]= ' ';
- szOutPuffer[j++]= ' ';
- szOutPuffer[j++]= ' ';
- }
- szOutPuffer[j++]= ' ';
-
- // Zeichen Ausgeben
- for( i = 0; i < iElementsPerRow; i++ ) // MaxCount
- {
- if( isalpha( iVal ) || isdigit( iVal ) )
- {
- szOutPuffer[j++] = iVal;
- iVal++;
- }
- else
- szOutPuffer[j++] = '+';
- }
- for( ; i < iElementsPerRow; i++ ) // MaxCount
- {
- szOutPuffer[j++]= ' ';
- }
-
- GetTextExtentPoint( hDC, " ", 1, &s );
- if( !s.cy ) s.cy = 1;
-
- rOut.bottom = rOut.top + s.cy;
- ExtTextOut( hDC, rOut.left, rOut.top, ETO_OPAQUE, &rOut, szOutPuffer, j, NULL );
- rOut.top = rOut.bottom;
- }
- while( rOut.top < r.bottom );
- SelectObject( hDC, hOldFont );
-
- DeleteObject( hPrintFont );
- EndPaint( hWnd, &ps );
- }
- break;
- }
- return DefWindowProc( hWnd, wMsg, wp, lp );
- }
-
- BOOL RegisterViewer( HINSTANCE hInst )
- {
- WNDCLASSEX wc;
- wc.cbSize = sizeof(wc);
- wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
- wc.lpfnWndProc = GrepView;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = sizeof( HANDLE); // Platz fⁿr Dateihandle
- wc.hInstance = hInst;
- wc.hIcon = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL; //(LPSTR)MAKEINTRESOURCE(IDR_MAINMENU);
- wc.lpszClassName = "VIEW";
- wc.hIconSm = NULL;
- return RegisterClassEx( &wc );
- }
-
- BOOL UnregisterViewer( HINSTANCE hInst )
- {
- return UnregisterClass( "VIEW", hInst );
- }
-
- BOOL CreateWindows( HINSTANCE hInst, HWND *hwndView, LPSTR lpFileName )
- {
- *hwndView = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE,
- "VIEW",
- "Window",
- WS_THICKFRAME|WS_CAPTION|WS_SYSMENU,
- 200,0,600,600,
- NULL,
- NULL,
- hInst,
- lpFileName );
- if( *hwndView ) return TRUE;
- return FALSE;
- }
-