Click here to Skip to main content
15,902,275 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionActiveX Pin
siva45515-Apr-09 8:33
siva45515-Apr-09 8:33 
AnswerRe: ActiveX Pin
KarstenK16-Apr-09 4:35
mveKarstenK16-Apr-09 4:35 
QuestionSendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 7:41
CString(0xcccccccc)15-Apr-09 7:41 
AnswerRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 9:43
professionalStuart Dootson15-Apr-09 9:43 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 12:48
CString(0xcccccccc)15-Apr-09 12:48 
GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 15:33
professionalStuart Dootson15-Apr-09 15:33 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 21:31
CString(0xcccccccc)15-Apr-09 21:31 
GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 22:30
professionalStuart Dootson15-Apr-09 22:30 
I've had some success (I think) with this code for handling OnNcPaint:

CRect GetCaptionRect(CWindow& wnd)
{
   // Get size of frame around window
   DWORD dwStyle = wnd.GetStyle();
   CSize szFrame = (dwStyle & WS_THICKFRAME) ?
      CSize(GetSystemMetrics(SM_CXSIZEFRAME),
      GetSystemMetrics(SM_CYSIZEFRAME)) :
   CSize(GetSystemMetrics(SM_CXFIXEDFRAME),
      GetSystemMetrics(SM_CYFIXEDFRAME));

   int cxIcon = GetSystemMetrics(SM_CXSIZE); // width of caption icon/button

   CRect r;
   // Compute rectangle
   wnd.GetWindowRect(&r);		// window rect in screen coords
   r -= CPoint(r.left, r.top);	// shift origin to (0,0)
   r.left  += szFrame.cx;				// frame
   r.right -= szFrame.cx;				// frame
   r.top   += szFrame.cy;				// top = end of frame
   r.bottom = r.top + GetSystemMetrics(SM_CYCAPTION)  // height of caption
      - GetSystemMetrics(SM_CYBORDER);				  // minus gray shadow border
   return r;
}

class MyDialog : public CDialogImpl<MyDialog>
{
public:
   BEGIN_MSG_MAP(MyDialog)
      MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint)
   END_MSG_MAP()

   LRESULT OnNcPaint(UINT nMsg, WPARAM hRgn, LPARAM lParam, BOOL& /*bHandled*/)
   {
      CRect r = GetCaptionRect(*this);
      r.right = r.left + r.Width()/2;
      HRGN onlyRedrawIn = ::CreateRectRgn(r.left, r.top, r.right, r.bottom);

      ::DefWindowProc(m_hWnd, nMsg, (WPARAM)onlyRedrawIn, lParam);
      return 0;
   }
};


The trouble is (I think) that your handler sometimes gets routed around - have you read this article[^] by Paul DiLascia about custom caption bars? It talks about MFC, but is relevant to ATL and Windows in general.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)16-Apr-09 11:38
CString(0xcccccccc)16-Apr-09 11:38 
GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson16-Apr-09 13:46
professionalStuart Dootson16-Apr-09 13:46 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)16-Apr-09 22:16
CString(0xcccccccc)16-Apr-09 22:16 
Questioncreating tooltip that follows cusor, to display coordinates. Pin
soongez15-Apr-09 6:21
soongez15-Apr-09 6:21 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
Stuart Dootson15-Apr-09 9:40
professionalStuart Dootson15-Apr-09 9:40 
QuestionRe: creating tooltip that follows cusor, to display coordinates. Pin
Maximilien15-Apr-09 10:06
Maximilien15-Apr-09 10:06 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
soongez15-Apr-09 15:19
soongez15-Apr-09 15:19 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
Rolf Kristensen15-Apr-09 20:49
Rolf Kristensen15-Apr-09 20:49 
QuestionDate Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 4:09
Don Jones BNYMellon15-Apr-09 4:09 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
led mike15-Apr-09 4:18
led mike15-Apr-09 4:18 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 4:59
Don Jones BNYMellon15-Apr-09 4:59 
QuestionRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 5:57
David Crow15-Apr-09 5:57 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 7:36
Don Jones BNYMellon15-Apr-09 7:36 
QuestionRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 7:39
David Crow15-Apr-09 7:39 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 8:00
Don Jones BNYMellon15-Apr-09 8:00 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 8:17
Don Jones BNYMellon15-Apr-09 8:17 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 9:15
David Crow15-Apr-09 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.