@@ -81,6 +81,7 @@ bool SciterMainWindow::Show(void)
8181 m_window->OnDestroySinkAdd (this );
8282 m_window->CenterWindow ();
8383 SetCaption (m_windowTitle);
84+
8485 SciterElement menuElement (rootElement.GetElementByID (" MainMenu" ));
8586 void * interfacePtr = nullptr ;
8687 if (menuElement.IsValid () && m_sciterUI.GetElementInterface (menuElement, IID_IMENUBAR , &interfacePtr))
@@ -93,13 +94,23 @@ bool SciterMainWindow::Show(void)
9394 SciterElement mainContents (rootElement.GetElementByID (" MainContents" ));
9495 if (mainContents.IsValid ())
9596 {
97+ m_sciterUI.AttachHandler (mainContents, IID_IRESIZESINK , (IResizeSink*)this );
9698 rect = mainContents.GetLocation ();
9799 }
98100
101+ uint32_t width = rect.right - rect.left ;
102+ uint32_t height = rect.bottom - rect.top ;
99103 m_renderWindow = CreateWindowExW (0 , L" Static" , L" " , WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS ,
100- rect.left , rect.top , rect. right , rect. bottom , (HWND )m_window->GetHandle (), nullptr , GetModuleHandle (nullptr ), nullptr );
104+ rect.left , rect.top , width, height , (HWND )m_window->GetHandle (), nullptr , GetModuleHandle (nullptr ), nullptr );
101105 ShowWindow ((HWND )m_renderWindow, SW_HIDE );
102106 SwitchSystem::Create (*this );
107+
108+ SwitchSystem* system = SwitchSystem::GetInstance ();
109+ if (system != nullptr )
110+ {
111+ IVideo & video = system->Video ();
112+ video.UpdateFramebufferLayout (rect.right - rect.left , rect.bottom - rect.top );
113+ }
103114 return true ;
104115}
105116
@@ -401,6 +412,11 @@ void * SciterMainWindow::RenderSurface(void) const
401412 return m_renderWindow;
402413}
403414
415+ float SciterMainWindow::PixelRatio (void ) const
416+ {
417+ return 1.0 ;
418+ }
419+
404420bool SciterMainWindow::OnKeyDown (SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState)
405421{
406422 SwitchSystem* system = SwitchSystem::GetInstance ();
@@ -434,4 +450,23 @@ bool SciterMainWindow::OnKeyUp(SCITER_ELEMENT element, SCITER_ELEMENT item, Scit
434450bool SciterMainWindow::OnKeyChar (SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState)
435451{
436452 return false ;
437- }
453+ }
454+
455+ bool SciterMainWindow::OnSizeChanged (SCITER_ELEMENT elem)
456+ {
457+ SciterElement rootElement (m_window->GetRootElement ());
458+ if (elem == rootElement.GetElementByID (" MainContents" ))
459+ {
460+ SciterElement::RECT rect = SciterElement (elem).GetLocation ();
461+ uint32_t width = rect.right - rect.left ;
462+ uint32_t height = rect.bottom - rect.top ;
463+ MoveWindow ((HWND )m_renderWindow, rect.left , rect.top , width, height, false );
464+ SwitchSystem * system = SwitchSystem::GetInstance ();
465+ if (system != nullptr )
466+ {
467+ IVideo & video = system->Video ();
468+ video.UpdateFramebufferLayout (width, height);
469+ }
470+ }
471+ return false ;
472+ }
0 commit comments