home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
mag&info
/
msjv7_6.zip
/
TOPTEN.ARJ
/
ETO.ARJ
/
ETO.C
< prev
next >
Wrap
Text File
|
1992-10-01
|
7KB
|
271 lines
#include <windows.h>
#include "basedefs.h"
#include "eto.h"
WINPROC WndProc ( WINDOWS_PARAMS );
void TestIDM_RECT_FILLRECT ( HWND hWnd );
void TestIDM_RECT_ETO ( HWND hWnd );
void TestIDM_TEXT_TEXTOUT ( HWND hWnd );
void TestIDM_TEXT_ETO ( HWND hWnd );
/**************************************************************
* *
* Global Variables *
* *
**************************************************************/
HANDLE ghInst;
HWND ghWnd;
char szNullString[] = "";
char szAppName[] = "ETO";
HBRUSH hRGBBrush[16];
COLORREF dwRGB[16];
/**************************************************************
* *
* WinMain *
* *
**************************************************************/
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wndclass ;
int i;
if (!hPrevInstance)
{
// Register the Parent Window
wndclass.style = CS_BYTEALIGNCLIENT;
wndclass.lpfnWndProc = (WNDPROC)WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject ( LTGRAY_BRUSH ) ;
wndclass.lpszMenuName = (LPSTR)"PlainMenu" ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
return FALSE;
}
// Generate sixteen cached brushes, for each of the solid colors,
// and fill in the dwRGB array
for ( i = 0; i < 16; i++ )
hRGBBrush[i] = CreateSolidBrush ( dwRGB[i] =
RGB
(
min ((((i%8)&4)/4)*(((i%16)/8)+1)*128, 255),
min ((((i%8)&2)/2)*(((i%16)/8)+1)*128, 255),
min ((((i%8)&1)/1)*(((i%16)/8)+1)*128, 255)
)
);
ghInst = hInstance;
ghWnd = CreateWindow (szAppName, "Tiny Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
NULL, NULL, hInstance, NULL) ;
ShowWindow ( ghWnd, nCmdShow );
UpdateWindow ( ghWnd );
while (GetMessage((LPMSG)&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
for ( i = 0; i < 16; i++ )
DeleteObject ( hRGBBrush[i] );
return msg.wParam ;
}
/*********************************************************************
* *
* WndProc: Main Message Translator *
* *
*********************************************************************/
WINPROC WndProc ( WINDOWS_PARAMS )
{
switch ( msg )
{
case WM_COMMAND :
switch ( wParam )
{
case IDM_RECT_FILLRECT: TestIDM_RECT_FILLRECT ( hWnd ); break;
case IDM_RECT_ETO : TestIDM_RECT_ETO ( hWnd ); break;
case IDM_TEXT_TEXTOUT : TestIDM_TEXT_TEXTOUT ( hWnd ); break;
case IDM_TEXT_ETO : TestIDM_TEXT_ETO ( hWnd ); break;
}
break;
case WM_CREATE :
break;
case WM_DESTROY :
PostQuitMessage (0) ;
break ;
default :
return DefWindowProc ( hWnd, msg, wParam, lParam );
}
return 0L ;
}
//*************************************************************************
//
//
//
//*************************************************************************
void TestIDM_RECT_FILLRECT ( HWND hWnd )
{
RECT r;
int i, j;
HDC hDC;
GetClientRect ( hWnd, &r );
hDC = GetDC ( hWnd );
for ( j = 0; j < 3; j++ )
for ( i = 0; i < 16; i++ )
FillRect ( hDC, &r, hRGBBrush[i] );
ReleaseDC ( hWnd, hDC );
}
//*************************************************************************
//
//
//
//*************************************************************************
void TestIDM_RECT_ETO ( HWND hWnd )
{
RECT r;
int i, j;
HDC hDC;
GetClientRect ( hWnd, &r );
hDC = GetDC ( hWnd );
for ( j = 0; j < 3; j++ )
for ( i = 0; i < 16; i++ )
{
SetBkColor ( hDC, dwRGB[i] );
ExtTextOut ( hDC, 0, 0, ETO_OPAQUE, &r, NULL, NULL, NULL );
}
ReleaseDC ( hWnd, hDC );
}
//*************************************************************************
//
//
//
//*************************************************************************
void TestIDM_TEXT_TEXTOUT ( HWND hWnd )
{
RECT r;
int i, j, k;
HDC hDC;
int iNumLines;
WORD wCharHeight;
char szTest[] = "This is a test!!!! ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int cbTest = lstrlen ( szTest );
GetClientRect ( hWnd, &r );
hDC = GetDC ( hWnd );
wCharHeight = HIWORD (GetTextExtent(hDC, szTest, cbTest));
r.left = LOWORD (GetTextExtent(hDC, szTest, cbTest));
iNumLines = r.bottom / wCharHeight;
for ( j = 0; j < 3; j++ )
for ( i = 0; i < 16; i++ )
{
SetBkColor ( hDC, dwRGB[i] );
SetTextColor ( hDC, dwRGB[15-i] );
for ( k = 0; k < iNumLines; k++ )
{
r.top = k*wCharHeight;
r.bottom = r.top + wCharHeight;
TextOut ( hDC, 0, k*wCharHeight, szTest, cbTest );
FillRect ( hDC, &r, hRGBBrush[i] );
}
}
ReleaseDC ( hWnd, hDC );
}
//*************************************************************************
//
//
//
//*************************************************************************
void TestIDM_TEXT_ETO ( HWND hWnd )
{
RECT r;
int i, j, k;
HDC hDC;
int iNumLines;
WORD wCharHeight;
char szTest[] = "This is a test!!!! ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int cbTest = lstrlen ( szTest );
GetClientRect ( hWnd, &r );
hDC = GetDC ( hWnd );
wCharHeight = HIWORD (GetTextExtent(hDC, szTest, cbTest));
iNumLines = r.bottom / wCharHeight;
for ( j = 0; j < 3; j++ )
for ( i = 0; i < 16; i++ )
{
SetBkColor ( hDC, dwRGB[i] );
SetTextColor ( hDC, dwRGB[15-i] );
for ( k = 0; k < iNumLines; k++ )
{
r.top = k*wCharHeight;
r.bottom = r.top + wCharHeight;
ExtTextOut ( hDC, 0, k*wCharHeight, ETO_OPAQUE, &r, szTest, cbTest, NULL );
}
}
ReleaseDC ( hWnd, hDC );
}