home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
cprog
/
blx21.zip
/
OV2DLL.ARJ
/
SUPERC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-11
|
4KB
|
144 lines
#include <windows.h>
#include <stdlib.h>
#include <string.h>
FARPROC lpOldWindowProc;
HWND HWin;
WNDCLASS MyWndClass;
HWND Wnd;
char ChildWin[50];
HWND ChildWinH;
FARPROC EnumFunc;
HANDLE LibInst;
HBITMAP hBitmp;
BITMAP Bitmp;
#pragma argsused
int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
WORD wHeapSize, LPSTR lpszCmdLine )
{
// The startup code for the DLL initializes the local heap (if
// there is one) with a call to LocalInit which locks the data
// segment.
if ( wHeapSize != 0 )
UnlockData( 0 );
LibInst = hInstance;
return 1; // Indicate that the DLL was initialized successfully.
}
#pragma argsused
int FAR PASCAL WEP ( int bSystemExit )
{
return 1;
}
DWORD FAR PASCAL _export WndProc( HWND rWin, WORD Message, WORD wParam, DWORD lParam )
{
PAINTSTRUCT PS;
char s[20];
HDC MemDC;
RECT R;
DWORD LPos;
HDC DC, MemHDC;
switch ( Message ) {
case WM_PAINT:
{
DC = BeginPaint( rWin, &PS );
MemHDC = CreateCompatibleDC( DC );
SelectObject( MemHDC,hBitmp );
GetObject(hBitmp, sizeof( Bitmp ), ( LPSTR ) &Bitmp );
GetClientRect( rWin, &R );
StretchBlt( DC, 0, 0, R.right, R.bottom, MemHDC, 0,0,
Bitmp.bmWidth, Bitmp.bmHeight, SRCCOPY );
ReleaseDC( rWin, DC );
DeleteDC( MemHDC );
EndPaint( rWin, &PS );
}
}
return DefWindowProc( rWin, Message, wParam, lParam );
}
void RegisterMyClass()
{
MyWndClass.style = CS_HREDRAW | CS_VREDRAW;
MyWndClass.lpfnWndProc = WndProc;
MyWndClass.cbClsExtra = 0;
MyWndClass.cbWndExtra = 0;
MyWndClass.hInstance = LibInst;
MyWndClass.hIcon = LoadIcon( 0, IDI_APPLICATION );
MyWndClass.hCursor = LoadCursor( 0, IDC_ARROW );
MyWndClass.hbrBackground = GetStockObject( WHITE_BRUSH );
MyWndClass.lpszMenuName = NULL;
MyWndClass.lpszClassName = "MyWindowClass";
RegisterClass( &MyWndClass );
}
#pragma argsused
DWORD FAR PASCAL _export NewWinProc( HWND rWin, WORD wMsg, WORD wParam, DWORD lParam )
{
RECT R;
HDC DC;
DWORD LPos;
switch ( wMsg ) {
case WM_COMMAND:
{
if ( wParam == 7 )
{
RegisterMyClass();
GetClientRect( ChildWinH, &R );
DC = GetDC( ChildWinH );
LPos = GetDCOrg( DC );
Wnd = CreateWindow( "MyWindowClass", "Client", WS_OVERLAPPED,
LOWORD(LPos), HIWORD(LPos), R.right, R.bottom,
HWin, 0, LibInst, NULL );
ShowWindow( Wnd, SW_SHOWNORMAL );
UpdateWindow( Wnd );
ReleaseDC( ChildWinH, DC );
SetFocus( Wnd );
return 1;
}
}
case WM_CLOSE:
{
DestroyWindow( Wnd );
SetWindowLong( HWin, GWL_WNDPROC, (DWORD) lpOldWindowProc );
DefWindowProc( HWin, wMsg, wParam, lParam );
}
}
return CallWindowProc( lpOldWindowProc, rWin, wMsg, wParam, lParam );
}
#pragma argsused
BOOL FAR PASCAL _export EnumWinFunc( HWND hWindow, DWORD Continue )
{
char PCH[50];
if ( hWindow != 0 )
{
GetWindowText( hWindow, PCH, GetWindowTextLength( hWindow ) + 1 );
if ( _fstrstr(PCH, ChildWin) != NULL )
{
ChildWinH = hWindow;
return 0;
}
else
return 1;
}
else
return 1;
}
int FAR PASCAL _export ReplaceProc ( HANDLE hInst, HWND hWindow, LPSTR Child )
{
hBitmp = LoadBitmap( LibInst, "RACECAR" );
HWin = hWindow;
strcpy( ChildWin, Child );
EnumFunc = MakeProcInstance( EnumWinFunc, hInst );
EnumChildWindows( HWin, EnumFunc, 0 );
lpOldWindowProc = (FARPROC) SetWindowLong( HWin, GWL_WNDPROC, (DWORD) NewWinProc );
return 1;
}