Solved

Nick Repin Collect your points

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…

726 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