如何使 WS_THICKFRAME 不可见,但在 MFC 中仍然有效?

2022-01-12 00:00:00 c++ mfc

所以,我创建了一个具有以下样式的对话框:WS_THICKFRAME.这个 WS_THICKFRAME 为对话框提供了调整窗口大小的功能,但我的问题是我的窗口周围的边框不可见.如何使边框不可见,但仍具有调整大小的功能?

So, I created a dialog that has a style: WS_THICKFRAME. This WS_THICKFRAME gives the dialog box the functionality to resize the window, but my problems is that I don't won't a border around my window to be visible. How would I make the border invisible, but still have the re-size capability?

举个例子会很有帮助!谢谢!

An example would be most helpful! Thanks!

下面是我创建的对话框的模板样式:

Below, are the styles of the template for the dialog box I created:

IDD_GADGETTRANSLUCENTDIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_SYSMENU | WS_THICKFRAME

推荐答案

移除 WS_THICKFRAME

Remove WS_THICKFRAME

大致如下处理WM_NCHITTEST:

Handle WM_NCHITTEST roughly as follows:

UINT CMyClass::OnNcHitTest(CPoint point) 
{
   CRect rWindow;
   GetWindowRect(rWindow);

   CRect rInner(rWindow);
   rInner.DeflateRect(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));

   if (rWindow.PtInRect(point) && !rInner.PtInRect(point))
   {
      // figure out which of the following codes to return: //
      // HTBOTTOM, HTTOP, HTLEFT, HTRIGHT                   //
      // HTBOTTOMLEFT, HTBOTTOMRIGHT, HTTOPLEFT, HTTOPRIGHT // 
   }
   else
   {
      return CMyBaseClass::OnNcHitTest(point);
   }
} 

相关文章