Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Nick Repin Collect your points

Posted on 1999-01-14
3
244 Views
Last Modified: 2013-12-03
By the way Nick, how do you add a minimize button to a Tool Window dialog box
0
Comment
Question by:raveroo
  • 3
3 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 1418754
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1418755
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1418756
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio Debugging 3 138
wordpress limitations 4 123
SignTool Error with Windows 10 5 174
Need to impress with my knowledge of .NET 5 92
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question