Solved

Nick Repin Collect your points

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now