用PB 4.2 定制操作系统,分辨率为320x240,烧到板子上后,主窗口显示正常,大小匹配,但是打开譬如控制面板中的电源管理之类的没有最大化按钮的子窗口时,窗口横向的一部分超出了主窗口大小。请高手指教,谢谢!
你说的这个情况很正常。这是wince系统的设计决定的。
一块屏可以当横屏使,也可以当竖屏使用,所以组件中就有横屏资源和竖屏资源两种
从Windows CE 4.0开始,DEVMODE 结构多了一个属性dmDisplayOrientation,你可以通过这个属性来取得或设置屏幕旋转模式,它对应的值如下。
DMDO_0 不旋转
DMDO_90 旋转90度
DMDO_180 旋转180度
DMDO_270 旋转270度
切换屏幕旋转模式通过调用 ChangeDisplaySettingsEx 来实现,如:
DEVMODE devmode = {0};
devmode.dmSize = sizeof(DEVMODE);
devmode.dmDisplayOrientation = DMDO_90; //水平模式
devmode.dmFields = DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL, &devmode, NULL, 0, NULL);
取得当前模式的代码如下:
DEVMODE devmode = {0};
devmode.dmSize = sizeof(DEVMODE);
devmode.dmFields = DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL, &devmode, 0, CDS_TEST, NULL);
通过 devmode.dmDisplayOrientation 的值可以判断当前模式。
值得注意的是,这样切换模式并不是永久的,当设备重新起动后,就会还原为初始状态。
如果你需要在保留切换的屏幕模式,可以通过设置注册表中HKEY_LOCAL_MACHINE\System\GDI\Rotation 下的两个键值实现
Angle - DWORD (0, 90, 180, 270)
LandscapeMode - DWORD (0,1)
//是不是可以用连接显示屏的线 交换X Y引脚?
可能加上特征Quarter VGA Resources – Portrait Mode就好了,下面是pb的帮助:
You can ensure that an application works in both landscape and portrait modes if your application always checks the screen size by calling the GetSystemMetrics function. Once you determine the screen size, resize your application so that it fits on the screen.
For dialog boxes, you can create two different resource DLLs that contain the landscape and portrait versions of the same dialog box. After you check the screen size, you can load the appropriate DLL.
An OEM can create a custom build flag that includes the appropriate DLL for the size of the screen included in an OS design. In previous versions, Windows CE used the CPLMAIN_LP environment variable in this manner to determine whether to include landscape or portrait versions of Control Panel applications. As of Windows CE .NET 4.2, a custom build flag enables you to select resources for portrait views on quarter VGA (QVGA) displays. You can select this Catalog item in the Catalog at Shell and User Interface\User Interface\Quarter VGA Resources – Portrait Mode.