#include "stdafx.h"
#include "newswindow.h"
#include "webctrl.h"

NewsWindow::NewsWindow(void)
{
	hBrowser = NULL;
}

NewsWindow::~NewsWindow(void)
{
}

int NewsWindow::Create(HWND parent)
{
	Load("news");
	
	title = env.GetWideString("news","title",L"News");
	titlebar.Load("news::titlebar");
	titlebar.title = title;

	resizeable = 0;
	SkinnableFrame::Create(parent);
	browser.Load("news::browser");

	return 1;
}

void NewsWindow::SetURL(const TCHAR * url)
{
	if(hBrowser==NULL){
		InitWebCtrl();

		hBrowser = CreateWindow(
						WC_WEBCTRL,
						L"about:blank",
						WS_CHILD | WS_VISIBLE,
						browser.location.X, browser.location.Y,
						browser.size.Width, browser.size.Height,
						hWnd,
						(HMENU) NULL,
						env.hInstance,
						NULL );
	}

	SafeSendMessage(hBrowser,WM_SETTEXT,0,(LPARAM)url);
}

void NewsWindow::OnClose()
{
	Hide();
}
