문제

이 있는 API 를 호출하는 결정의 크기와 위치를 창 캡션 버튼?하려고 해요 그리 vista 스타일 캡션 버튼에는 소유자가 그려진 창입니다.내가 다루는 c/c++/mfc.

편집:지 코드 예제를 그리는 닫기 버튼?

도움이 되었습니까?

해결책

내가 찾은 기능을 위해 필요하의 위치에서 버튼 vista: WM_GETTITLEBARINFOEX

이 링크를 보여줍 시스템 통계를 얻을하는 데 필요한 모든 간격의 정확한(부끄러운 그것은 전체 대화 그림을 하지만).이 완벽하게 작동에 비스타,XP 에서 대부분(XP 에서 거기에 약간의 너무 많 갭 버튼 사).

From http://shellrevealed.com/photos/blog_images/images/4538/original.aspx

다른 팁

getsystemmetrics 이 모든 정보를 제공합니다. 창 장식 안에 그리려면 사용하십시오 getwindowdc.

다음 코드 적응에서"글로벌 제목 표시줄 훅"를 들어아에는 취소 수수료가 없 http://www.catch22.net/content/snippets.나는 수정의 예를 만들 MFC 친절합니다.그것은 반환 X-좌표의 제목 표시줄 왼쪽 버튼 그러나 그것은 쉽게 수정하여 위의 버튼이 있습니다.

#define B_EDGE 2

int CMyWindow::CalcRightEdge()
{
 if(GetStyle() & WS_THICKFRAME)
  return GetSystemMetrics(SM_CXSIZEFRAME);
 else
  return GetSystemMetrics(SM_CXFIXEDFRAME);
}


int CMyWindow::findNewButtonPosition()
{
 int   nButSize  = 0;
 DWORD dwStyle   = GetStyle();
 DWORD dwExStyle = GetExStyle();

 if(dwExStyle & WS_EX_TOOLWINDOW)
 {
  int nSysButSize = GetSystemMetrics(SM_CXSMSIZE) - B_EDGE;

  if(GetStyle() & WS_SYSMENU) 
   nButSize += nSysButSize + B_EDGE;

  return nButSize + CalcRightEdge();
 }
 else
 {
  int nSysButSize = GetSystemMetrics(SM_CXSIZE) - B_EDGE;

 // Window has Close [X] button. This button has a 2-pixel
 // border on either size
  if(dwStyle & WS_SYSMENU) 
   nButSize += nSysButSize + B_EDGE;

 // If either of the minimize or maximize buttons are shown,
 // Then both will appear (but may be disabled)
 // This button pair has a 2 pixel border on the left
  if(dwStyle & (WS_MINIMIZEBOX | WS_MAXIMIZEBOX) )
   nButSize += B_EDGE + nSysButSize * 2;

 // A window can have a question-mark button, but only
 // if it doesn't have any min/max buttons
  else if(dwExStyle & WS_EX_CONTEXTHELP)
   nButSize += B_EDGE + nSysButSize;

 // Now calculate the size of the border...aggghh!
  return nButSize + CalcRightEdge();
 }
}

getsystemmetrics 함수는 크기 (sm_cysize 및 sm_cxsize 매개 변수)에 도움이됩니다.

편집하다

이 기능으로 위치를 찾을 수 있는지 잘 모르겠지만 살펴볼 수 있습니다. 에뮬 소스 코드, 그들은 창 자막에 버튼을 추가했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top