Exemplo n.º 1
0
  window* window::create( int x, int y, int width, int height, const wchar_t* caption ) 
  {
    window* pw = new window();

    UINT style = WS_POPUP | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX;
    pw->hwnd = CreateWindowExW( WS_EX_LAYERED, CLASSNAME, NULL, style ,
                                x, y, width, height, NULL, NULL, hinstance, NULL);
//    pw->hwnd = CreateWindowExW( 0, CLASSNAME, NULL, style ,
//                                x, y, width, height, NULL, NULL, hinstance, NULL);
    self(pw->hwnd,pw);
    HTMLayoutSetCallback(pw->hwnd,&callback,pw);
    PBYTE pb; DWORD cb;
    if(load_resource_data(L"DEFAULT",pb,cb))
    {
      HTMLayoutLoadHtml(pw->hwnd,pb,cb);

      dom::element r = pw->root();

      pw->body            = r.find_first("body");
      pw->caption         = r.get_element_by_id("caption");
      pw->button_min      = r.get_element_by_id("minimize");
      pw->button_max      = r.get_element_by_id("maximize");
      pw->button_icon     = r.get_element_by_id("icon");
      pw->button_close    = r.get_element_by_id("close");
      pw->corner          = r.get_element_by_id("corner");

      attach_event_handler(pw->hwnd, pw);

      pw->set_caption(caption);

    }
    return pw;
  }
wyBool 
Announcements::HandleAnnouncementsCheck(HWND hwnd)
{
	HWND		hwndHTML;
	wyString	htmlbuffer;
	WNDPROC		wndproc, origmainwndproc;
	CHttp		http;
	htmlbuffer.SetAs(pGlobals->m_announcementshtml.GetString());
	VERIFY(m_hwnd =  CreateWindow(ANNOUNCEMENTS_MAIN_WINDOW,
								L"", 
								WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 
								2, 450, 300, 180,
							    hwnd, (HMENU)-1,
								pGlobals->m_pcmainwin->GetHinstance(), NULL));

	VERIFY(hwndHTML = CreateWindowEx(0, ANNOUNCEMENTS_WINDOW, 
								L"AnnouncementsWindow",  
								WS_CHILD | WS_VISIBLE, 
                                0, 0, 270, 270, 
								m_hwnd, (HMENU)-1, 
								pGlobals->m_pcmainwin->GetHinstance(), NULL));

    origmainwndproc = (WNDPROC)SetWindowLongPtr(m_hwnd, GWLP_WNDPROC, (LONG_PTR)Announcements::AnnounceWndMainProc);
    SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)origmainwndproc);
	
	m_hwndHTML = hwndHTML;

	htmlayout::attach_event_handler(hwndHTML, &AnnEvtHandler);
	HTMLayoutSetCallback(hwndHTML, HTMLayoutNotifyHandler, 0);  
	//htmlayout::attach_event_handler(hwndHTML, &DOMEventsHandler);

    wndproc = (WNDPROC)SetWindowLongPtr(hwndHTML, GWLP_WNDPROC, (LONG_PTR)Announcements::AnnounceWndProc);
    SetWindowLongPtr(hwndHTML, GWLP_USERDATA, (LONG_PTR)wndproc);

	if(HTMLayoutLoadHtml(hwndHTML, (PBYTE)htmlbuffer.GetString(), htmlbuffer.GetLength()))
	{
		//if loadhtml fails return false and the html is malformed 
		HTMLayoutSetMode(hwndHTML, HLM_SHOW_SELECTION);
		return wyTrue;
	}
	else
	{
		//cleanup
		CloseWindow(m_hwndHTML);
		CloseWindow(m_hwnd);
		DestroyWindow(m_hwndHTML);
		DestroyWindow(m_hwnd);
		return wyFalse;
	}

}
Exemplo n.º 3
0
	LRESULT CALLBACK ZDForm::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
	{
		/*PAINTSTRUCT ps;
		HDC hdc;*/

		LRESULT lResult;
		BOOL    bHandled = FALSE;

		// HTMLayout +
		// HTMLayout could be created as separate window 
		// using CreateWindow API.
		// But in this case we are attaching HTMLayout functionality
		// to the existing window delegating windows message handling to 
		// HTMLayoutProcND function.
		lResult = HTMLayoutProcND(hWnd,message,wParam,lParam, &bHandled);
		if(bHandled)
			return lResult;
		// HTMLayout -

		switch (message)
		{
			/*case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			{
			RECT r;
			GetClientRect(hWnd,&r);
			HBRUSH hb = CreateSolidBrush(0xffffffff);
			FillRect(hdc,&r,hb);
			DeleteObject(hb);
			}
			// TODO: Add any drawing code here...
			EndPaint(hWnd, &ps);
			break;*/
		case WM_CREATE:
			{
				//EnableBlurBehind ( hWnd );
				UIToolKits uit;
				uit.SetAeroTransparentBack ( hWnd );

				// Normally HTMLayout sends its notifications
				// to its parent. 
				// In this particular case we are using callback function to receive and
				// and handle notification. Don't bother the desktop window (parent of this window)
				// by our notfications.

				ZDForm* form = (ZDForm*)GetZDApplication()->GetZDObject(hWnd);
				HTMLayoutSetCallback(hWnd,form->HTMLayoutNotifyHandler,hWnd);

				// attach DOM events handler so we will be able to receive DOM events like BUTTON_CLICK, HYPERLINK_CLICK, etc.
				//HTMLayoutWindowAttachEventHandler( hWnd, 
				//    DOMEventsHandler.element_proc, 
				//   &DOMEventsHandler, 
				//    DOMEventsHandler.subscribed_to);
				htmlayout::attach_event_handler(hWnd, form);

				WCHAR path[2048] = L"file://"; 
				GetModuleFileNameW(NULL, &path[7], 2048 - 7);

				PBYTE pb; DWORD cb;
				if(form->GetHtmlResource(form->m_zdHtmlRes,pb,cb))
					HTMLayoutLoadHtmlEx(hWnd,pb,cb,path); // we use path here so all relative links in the document will resolved against it.

			} break;
		case WM_ERASEBKGND:
			return TRUE; // as HTMLayout will draw client area in full
		case WM_DESTROY:
			{
				PostQuitMessage(0);
			}
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		return 0;
	}