www.pudn.com > inet_stock.zip > FX.CPP


#include 
#include 
#include 
#include "resource.h"
#include "global.h"
#include "hq.h"
#include "fx.h"
//#include "hq_cl.h"

#define FX_CLASS	"CFX"

extern HINSTANCE ghInstance;
extern HWND ghWndMain;
extern BOOL ErrMsg(HWND, LPSTR);
extern BOOL IsZsRec(int jys, int rec_num);
LRESULT CALLBACK FxWndProc(HWND, UINT, WPARAM, LPARAM);

BOOL RegisterFx(void)
{
	WNDCLASS wc;
	
	memset(&wc, 0, sizeof(wc));
	
	wc.lpfnWndProc =FxWndProc;
	wc.lpszClassName =FX_CLASS;
	wc.cbWndExtra =2*sizeof(WORD);
	wc.hbrBackground =GetStockObject(BLACK_BRUSH);
	wc.hInstance = ghInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);        
	if(!RegisterClass(&wc)) return FALSE;
	
	return TRUE;
}

BOOL CreateWndFx(HWND hWnd, int fx_type, int rec_left,
		int x, int y, int w, int h)
{                          
	HWND hwnd;
	HANDLE hFx;
	LPFX lpFx;
		
	hwnd =CreateWindow(FX_CLASS, NULL, WS_CHILD|WS_CLIPSIBLINGS,
						x, y, w, h,	hWnd, NULL, ghInstance, NULL);
	if(hwnd ==NULL)
	{
		ErrMsg(hWnd, "Error create fx window");
		return FALSE;
	}
	
	hFx =LocalAlloc(GHND, sizeof(FX));
	if(!hFx)
	{
		ErrMsg(NULL, "alloc fx failed");
		DestroyWindow(hwnd);
		return FALSE;
	}
	lpFx =(LPFX)LocalLock(hFx);
	if(!lpFx)
	{
		ErrMsg(NULL, "alloc fx failed");
		DestroyWindow(hwnd);
		return FALSE;
	}
	
	lpFx->type =fx_type;
	lpFx->recFirst =rec_left;
	
	LocalUnlock(hFx);
	
	SetWindowWord(hWnd, 0, hFx);
	
	return TRUE;
}

LRESULT CALLBACK FxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HANDLE hFx;
	LPFX lpFx;
	
	switch(wParam)
	{
		case WM_CREATE:
		break;
		
		case WM_PAINT:
			BeginPaint(hWnd, &ps);
			hFx =GetWindowWord(hWnd, 0);
			if(hFx)
			{
				lpFx =(LPFX)LocalLock(hFx);
				if(lpFx){DrawFx(hWnd, ps.hdc, lpFx); LocalUnlock(hFx);}
			}
			EndPaint(hWnd, &ps);
		break;
		
		case WM_COMMAND:
		break;
		
		case WM_KEYDOWN:
		break;
		
		case WM_DESTROY:
		break;
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}