dofile( XLCurPath().."Message.lua" )

function OnMainWndPaint( obj, wParm, lParam )
	XLDrawPicture( obj, 0, 0, 60, 25, XLCurPath().."left_top.bmp" );
	
	toplength = XLGetWindowRectWidth( obj ) - 83;
	x = 0;
	while x < toplength do
		XLDrawPicture( obj, x + 60, 0, 177, 25, XLCurPath().."top.bmp" );
		x = x + 177;
	end
	
	XLDrawPicture( obj, toplength + 60, 0, 23, 25, XLCurPath().."close.bmp" );
	
	leftheight = XLGetWindowRectHeight( obj ) - 27;
	y = 0;
	while y < leftheight do
		XLDrawPicture( obj, 0, y + 25, 2, 133, XLCurPath().."left.bmp" );
		y = y + 133;
	end
	
	XLDrawPicture( obj, 0, leftheight + 25, 2, 2, XLCurPath().."left_bottom.bmp" );
	
	bottomlength = XLGetWindowRectWidth( obj ) - 4;
	x = 2;
	while x < bottomlength do
		XLDrawPicture( obj , x, leftheight + 25, 256, 2, XLCurPath().."bottom.bmp" );
		x = x + 256
	end
	
	rightheight = leftheight;
	y = 0;
	while y < rightheight do
		XLDrawPicture( obj, bottomlength + 2, y + 25, 2, 133, XLCurPath().."right.bmp" );
		y = y + 133;
	end
	
	XLDrawPicture( obj, bottomlength + 2, leftheight + 25, 2, 2, XLCurPath().."right_bottom.bmp" );
	
end

function OnDecratedWindowSize( obj, wParam, lParam )
	windowleft = XLGetWindowLeft( lParam );
	windowtop = XLGetWindowTop( lParam );
	windowWidth = XLGetWindowWidth( lParam );
	windowHeight = XLGetWindowHeight( lParam );
	
	left = windowleft - 2;
	top = windowtop - 25;
	Width = windowWidth + 4;
	Height = windowHeight + 27;
	
	XLSetRect( obj, left, top, Width, Height );
	XLMoveWindow( lParam, 2, 25, windowWidth, windowHeight );
	
	id = XLGetWindowElement( obj, "close" );
	XLSetRect( id, Width - 22, 3, 18, 18 );
end

function OnCloseMouseMove( obj, wParam, lParam )
	XLDrawPicture( obj, 0, -3, 23, 25, XLCurPath().."close_mouse.bmp" );
end

function OnClosePaint( obj, wParam, lParam )
	XLDrawPicture( obj, 0, -3, 23, 25, XLCurPath().."close.bmp" );
end

function OnInitSkin( obj, wParam, lParam )
--	XLSetCanDrag( obj );
end

MainWndID = XLRegisterWindow( "XLTipsMainWnd" );
XLRegisterMessage( MainWndID, WM_PAINT, "OnMainWndPaint" );
XLRegisterMessage( MainWndID, WM_DECORATEDWINDOWSIZE, "OnDecratedWindowSize" );
XLRegisterMessage( MainWndID, WM_INITSKIN, "OnInitSkin" );

CloseID = XLRegisterWindowElement( MainWndID, "close", 238, 3, 18, 18, 61536 )
XLRegisterElementMessage( CloseID, WM_PAINT, "OnClosePaint" );
XLRegisterElementMessage( CloseID, WM_MOUSEMOVE, "OnCloseMouseMove" );
	
XLSkinDecorateWindow( "XLTipsMainWnd", "XLTipsWnd" );
