Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Nick Repin Collect your points

By the way Nick, how do you add a minimize button to a Tool Window dialog box
0
raveroo
Asked:
raveroo
  • 3
1 Solution
 
NickRepinCommented:
It seems that you value my possibilities too high. I can find out the way how the Windows does something.
If the Windows cannot do that, I should write the code for this myself. It's more harder.
As to button, I think it's need to modify internal Windows code which prevent the user to do this. It's may compatible for one Windows build only and not compatible with other. In other word, your app may work eg, on US version and not on German. Or, work at SP3 and not work at any other.

The 2nd way - to draw button yourself. In this case, you should:
1) catch WM_NCPAINT message and draw button. To do this, obtain height of caption and size of border and caption buttons (GetSystemMetric or SystemParametersInfo). Then calculate button position. Then draw button using DrawFrame.
2) Provide functionality of button. You should intercept WM_NCMOUSE... messages to do this. It seems that creation standard owner-draw button will not work (at least, as I think at this morning) because the button must be created in non-client area.

The 3rd way. Try to play with different window styles. I've tried to play ~20 min without success.


By the way, why NickRepin and not others?

P.S. If I'll have time today, I'll try to find the solution for the 1st way.

0
 
NickRepinCommented:
1) write your own ModifyExStyle (it's easy, use Get/SetWindowLong(GWL_EXSTYLE) )
2) this code works fine except when window is minimized and user presses 'restore'
button. I have no time to fix this now, but I think its easy.

HWND w=CreateWindowEx(WS_EX_TOOLWINDOW,"ZZZ","ZZZ",
   WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE|WS_MINIMIZEBOX,
      0,0,200,200,hWin,0,hCurrentModule,0);
//---------------------------------------------------------------------------
LRESULT CALLBACK ZZZProc(HWND hWnd,UINT uMsg,WPARAM wP,LPARAM lP)
{
   switch(uMsg) {
   case WM_ERASEBKGND: {
      RECT r;
      GetClientRect(hWnd,&r);
      PatBlt(HDC(wP),0,0,r.right,r.bottom,PATCOPY);
      }
      break;
   case WM_NCCALCSIZE: {
      ModifyExStyle(hWnd,0,WS_EX_TOOLWINDOW); // Remove style
      LRESULT r=DefWindowProc(hWnd,uMsg,wP,lP);
      ModifyExStyle(hWnd,WS_EX_TOOLWINDOW,0); // Add style
      return r;
      }
   case WM_MOVE: {
      SetWindowPos(hWnd,0,0,0,0,0,SWP_DRAWFRAME | SWP_NOMOVE |
         SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE |
         SWP_NOZORDER | SWP_NOACTIVATE);
      }
      break;
   case WM_NCPAINT: { // Redraw non-client area
      ModifyExStyle(hWnd,0,WS_EX_TOOLWINDOW);
      LRESULT r=DefWindowProc(hWnd,uMsg,wP,lP);
      ModifyExStyle(hWnd,WS_EX_TOOLWINDOW,0);
      return r;
      }
   case WM_NCHITTEST: {
      ModifyExStyle(hWnd,0,WS_EX_TOOLWINDOW);
      LRESULT r=DefWindowProc(hWnd,uMsg,wP,lP);
      ModifyExStyle(hWnd,WS_EX_TOOLWINDOW,0);
      return r;
      }
   }
   return DefWindowProc(hWnd,uMsg,wP,lP);
}

0
 
NickRepinCommented:
Hmm, it seems that it's not that easy. You should ignore my previous comment. It's a dangerous and unstable way.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now