修复客户区窗口大小与设定值不符的bug
This commit is contained in:
		
							parent
							
								
									3abc386793
								
							
						
					
					
						commit
						69d2f66405
					
				|  | @ -10,8 +10,10 @@ int WINAPI WinMain( | ||||||
| { | { | ||||||
| 	EApp app; | 	EApp app; | ||||||
| 
 | 
 | ||||||
| 	if (app.init(L"Easy2D Demo", 640, 480, app.NO_MINI_SIZE)) | 	if (app.init(L"Easy2D Demo", 640, 480)) | ||||||
| 	{ | 	{ | ||||||
|  | 		float w = EApp::getWidth(); | ||||||
|  | 		float h = EApp::getHeight(); | ||||||
| 		auto scene = new EScene(); | 		auto scene = new EScene(); | ||||||
| 
 | 
 | ||||||
| 		auto text = new EText(L"中文测试中文测试中文测试中文测试中文测试中文测试中文测试", EColor::WHITE, L"楷体"); | 		auto text = new EText(L"中文测试中文测试中文测试中文测试中文测试中文测试中文测试", EColor::WHITE, L"楷体"); | ||||||
|  |  | ||||||
|  | @ -114,12 +114,7 @@ bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowS | ||||||
| 		WARN_IF(screenWidth < width || screenHeight < height, "The window is larger than screen!"); | 		WARN_IF(screenWidth < width || screenHeight < height, "The window is larger than screen!"); | ||||||
| 		width = min(width, screenWidth); | 		width = min(width, screenWidth); | ||||||
| 		height = min(height, screenHeight); | 		height = min(height, screenHeight); | ||||||
| 		// 创建屏幕居中的矩形
 | 		 | ||||||
| 		RECT rtWindow; |  | ||||||
| 		rtWindow.left = (screenWidth - width) / 2; |  | ||||||
| 		rtWindow.top = (screenHeight - height) / 2; |  | ||||||
| 		rtWindow.right = rtWindow.left + width; |  | ||||||
| 		rtWindow.bottom = rtWindow.top + height; |  | ||||||
| 		// 创建窗口样式
 | 		// 创建窗口样式
 | ||||||
| 		DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU; | 		DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU; | ||||||
| 		if (!wStyle.NO_MINI_SIZE) | 		if (!wStyle.NO_MINI_SIZE) | ||||||
|  | @ -128,8 +123,6 @@ bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowS | ||||||
| 		} | 		} | ||||||
| 		// 保存窗口是否置顶显示
 | 		// 保存窗口是否置顶显示
 | ||||||
| 		m_bTopMost = wStyle.TOP_MOST; | 		m_bTopMost = wStyle.TOP_MOST; | ||||||
| 		// 计算客户区大小
 |  | ||||||
| 		AdjustWindowRectEx(&rtWindow, dwStyle, FALSE, 0L); |  | ||||||
| 		// 保存窗口名称
 | 		// 保存窗口名称
 | ||||||
| 		m_sTitle = title; | 		m_sTitle = title; | ||||||
| 		// 创建窗口
 | 		// 创建窗口
 | ||||||
|  | @ -137,10 +130,10 @@ bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowS | ||||||
| 			L"Easy2DApp", | 			L"Easy2DApp", | ||||||
| 			m_sTitle.c_str(), | 			m_sTitle.c_str(), | ||||||
| 			dwStyle, | 			dwStyle, | ||||||
| 			rtWindow.left, | 			0, | ||||||
| 			rtWindow.top, | 			0, | ||||||
| 			rtWindow.right - rtWindow.left, | 			width, | ||||||
| 			rtWindow.bottom - rtWindow.top, | 			height, | ||||||
| 			NULL, | 			NULL, | ||||||
| 			NULL, | 			NULL, | ||||||
| 			HINST_THISCOMPONENT, | 			HINST_THISCOMPONENT, | ||||||
|  | @ -153,6 +146,8 @@ bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowS | ||||||
| 		{ | 		{ | ||||||
| 			// 禁用输入法
 | 			// 禁用输入法
 | ||||||
| 			this->setKeyboardLayoutEnable(false); | 			this->setKeyboardLayoutEnable(false); | ||||||
|  | 			// 重设客户区大小
 | ||||||
|  | 			this->setWindowSize(width, height); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -101,7 +101,7 @@ | ||||||
|       <Optimization>Disabled</Optimization> |       <Optimization>Disabled</Optimization> | ||||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||||
|       <SDLCheck>true</SDLCheck> |       <SDLCheck>true</SDLCheck> | ||||||
|       <DebugInformationFormat>None</DebugInformationFormat> |       <DebugInformationFormat>EditAndContinue</DebugInformationFormat> | ||||||
|       <MinimalRebuild>false</MinimalRebuild> |       <MinimalRebuild>false</MinimalRebuild> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <Link> |     <Link> | ||||||
|  | @ -230,6 +230,7 @@ | ||||||
|     <ClCompile Include="Node\EFont.cpp" /> |     <ClCompile Include="Node\EFont.cpp" /> | ||||||
|     <ClCompile Include="Node\ETexture.cpp" /> |     <ClCompile Include="Node\ETexture.cpp" /> | ||||||
|     <ClCompile Include="Tool\EFileUtils.cpp" /> |     <ClCompile Include="Tool\EFileUtils.cpp" /> | ||||||
|  |     <ClCompile Include="Tool\EMusicUtils.cpp" /> | ||||||
|     <ClCompile Include="Tool\ERandom.cpp" /> |     <ClCompile Include="Tool\ERandom.cpp" /> | ||||||
|     <ClCompile Include="Tool\ETimer.cpp" /> |     <ClCompile Include="Tool\ETimer.cpp" /> | ||||||
|     <ClCompile Include="Transition\ETransitionEmerge.cpp" /> |     <ClCompile Include="Transition\ETransitionEmerge.cpp" /> | ||||||
|  |  | ||||||
|  | @ -171,6 +171,9 @@ | ||||||
|     <ClCompile Include="Tool\ETimer.cpp"> |     <ClCompile Include="Tool\ETimer.cpp"> | ||||||
|       <Filter>Tool</Filter> |       <Filter>Tool</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="Tool\EMusicUtils.cpp"> | ||||||
|  |       <Filter>Tool</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="Win\winbase.h"> |     <ClInclude Include="Win\winbase.h"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue