我的VC的对话框用户界面在1024*768的分辨率下显示正常,
但在800*600的分辨率下只显示对话框用户界面的一部分。
如何使VC的对话框用户界面适用于两种不同的分辨率,
望高手指点!谢谢!!!!

解决方案 »

  1.   

    HDC hdc;
    hdc = CreatDC("Display",NULL,NULL,NULL);
    int ixPixcel=GetDeviceCaps(hdc,HORZRES);            //例:得到1024pix...
    int iyPixcel=GetDeviceCaps(hdc,VERTRES);            //例:得到768pix...
    Release(hdc);根据得到的ixPixcel,iyPixcel调整你的对话框大小包括所有内部控件的显示
    (内部控件位置大小建议使用百分比等相对值)
      

  2.   

    在vc下没有不可能自动调整你只有在判断当前分辨率的情况下用代码movewindow来调整
      

  3.   

    对话框.MoveWindow();
    内部控件.MoveWindow();
    也可以用SetWindowPos();
      

  4.   

    HDC hdc;
    CString x,y;
    hdc = CreateDC("Display",NULL,NULL,NULL);
    int ixPixcel=GetDeviceCaps(hdc,HORZRES);            //例:得到1024pix...
    int iyPixcel=GetDeviceCaps(hdc,VERTRES);            //例:得到768pix...
    ReleaseDC((CDC *)hdc);
    x.Format("%d",ixPixcel);
    y.Format("%d",iyPixcel);
    MessageBox(x);
    MessageBox(y);
    以上是我的程序,编译通过,但运行时由于ReleaseDC((CDC *)hdc);的存在
    而内存出错,望高手指点,谢谢!
      

  5.   

    CDC *pDC = this->GetDC();
    int ScrWidth = pDC->GetDeviceCaps(HORZRES);
    int ScrHeight = pDC->GetDeviceCaps(VERTRES);
      

  6.   

    我的测试程序如下,望高手指点改错,谢谢!!!!!! CString x,y;
    POINT startPoint;
    CRect dlgRect;
    bool highPixelFlag;
    int w,h,w1,h1;
    //取分辨率并设标志---成功
    CDC *pDC = this->GetDC();
    int ScrWidth = pDC->GetDeviceCaps(HORZRES);
    int ScrHeight = pDC->GetDeviceCaps(VERTRES);
    ReleaseDC(pDC);
    if((ScrWidth==1024)&&(ScrHeight==768))
    highPixelFlag=TRUE;
    else
    highPixelFlag=FALSE;
    x.Format("%d",ScrWidth);
    y.Format("%d",ScrHeight);
    MessageBox(x);
    MessageBox(y);
    //取对话框的宽度,高度,起点---?数值不对?
    GetWindowRect(dlgRect);
    x.Format("%d",dlgRect.Width);
    y.Format("%d",dlgRect.Height);
    MessageBox(x);
    MessageBox(y); startPoint=dlgRect.TopLeft;
    x.Format("%d",startPoint.x);
    y.Format("%d",startPoint.y);
    MessageBox(x);
    MessageBox(y);
        //根据分辨率调整对话框窗口的大小---成功
    //w=rect.Width;
    //h=rect.Height;
    w=1024/1.28;
    h=768/1.28;
    w1=1024;
    h1=768; if(!highPixelFlag)
    MoveWindow(0,0,w,h);
    else
    MoveWindow(0,0,w1,h1);    //调整后的对话框大小和调整前一样---?不对?
    GetWindowRect(dlgRect);
    x.Format("%d",dlgRect.Width);
    y.Format("%d",dlgRect.Height);
    MessageBox(x);
    MessageBox(y);    //取对话框中的下拉列表控件的宽度和长度,与对话框的宽度和长度一样---?不对?
    CListCtrl *pListCtrl=(CListCtrl *)GetDlgItem(IDC_LIST1);
    CRect listCtrlRect;
    pListCtrl->GetClientRect(&listCtrlRect);
    x.Format("%d",listCtrlRect.Width);
    y.Format("%d",listCtrlRect.Height);
    MessageBox(x);
    MessageBox(y);