Solved

Nick Repin Collect your points

Posted on 1999-01-14
3
242 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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