(请教老妖)bcb程序自适应不同分辨率的问题
我的程序在1920×1080正常的分辨率编写的,1024*768分辨率下还OK,但是如果换成800×600得分辨率界面会放大导致部分看不见。 请问:有什么简单得方法能让程序同时适应这不同的分辨率?网上说的Anchors(老妖建议的方法)、ScaleBy(int,int)、BorderStyle、AutoSize、Align等方法都试过了,在800×600下还是那样不能正常显示。先谢谢了!
int PelsWidth = GetSystemMetrics(SM_CXSCREEN); int PelsHeight = GetSystemMetrics(SM_CYSCREEN); HDC hdc=GetDC(NULL); //获得屏幕设备描述表句柄 int i=GetDeviceCaps(hdc,HORZRES); //查询屏幕水平分辨率,并返回在变量i中 int j=GetDeviceCaps(hdc,VERTRES); //查询屏幕垂直分辨率,并返回在变量j中 ReleaseDC(NULL,hdc); //释放屏幕设备描述表 if(PelsWidth == 1280 || PelsHeight == 1024) { //ScaleBy(3,4); this->Anchors = TAnchors() << akLeft << akTop << akRight << akBottom; this->Top = 500; } else if(PelsWidth == 1024 || PelsHeight == 768) { //ScaleBy(3,4); this->Anchors = TAnchors() << akLeft << akTop << akRight << akBottom; this->Top = 240; this->Width = 1000; } else if(PelsWidth == 800 || PelsHeight == 600) { //ScaleBy(3,4); this->Anchors = TAnchors() << akLeft << akTop << akRight << akBottom; this->Left = 0; this->Top = 75; //this->Top = (PelsHeight - this->Height)/2; //this->Width = 770; this->Height = 600; this->Scaled = false; this->AutoSize = false; //this->Align = alClient; //this->Width = i/2; //this->Height = j/2; //this->BorderStyle = bsNone; }