반응형
www.devpia.com 의 김동천(winicon)님이 올려주신 글 내용 중 일부
--------------------------------------------------------------
인터넷에서 겨우 구한겁니다. 도움이 되었으면 합니다.
CDLGTOOLBAR1Dlg의 헤더에
CToolBar cToolBar; BOOL CDLGTOOLBAR1Dlg::OnInitDialog() { ~ ~ ~ mInitToolbar(); void CDLGTOOLBAR1Dlg::mInitToolbar() { if (!cToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !cToolBar.LoadToolBar(IDR_TOOLBAR1)) { TRACE0("Failed to Create Dialog Toolbar\n"); EndDialog(IDCANCEL); } CRect rcClientNew; // New Client Rect with Tollbar Added GetClientRect(rcClientOld); // Retrive the Old Client WindowSize // Called to reposition and resize control bars in the client area of a window // The reposQuery FLAG does not really traw the Toolbar. It only does the calculations. // And puts the new ClientRect values in rcClientNew so we can do the rest of the Math. RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rcClientNew); // All of the Child Windows (Controls) now need to be moved so the Tollbar does not cover them up. // Offest to move all child controls after adding Tollbar CPoint ptOffset(rcClientNew.left-rcClientOld.left,rcClientNew.top-rcClientOld.top); CRect rcChild; CWnd* pwndChild = GetWindow(GW_CHILD); //Handle to the Dialog Controls while(pwndChild) // Cycle through all child controls { pwndChild->GetWindowRect(rcChild); // Get the child control RECT ScreenToClient(rcChild); rcChild.OffsetRect(ptOffset); // Changes the Child Rect by the values of the claculated offset pwndChild->MoveWindow(rcChild,FALSE); // Move the Child Control pwndChild = pwndChild->GetNextWindow(); } CRect rcWindow; GetWindowRect(rcWindow); // Get the RECT of the Dialog rcWindow.right += rcClientOld.Width() - rcClientNew.Width(); // Increase width to new Client Width rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height(); // Increase height to new Client Height MoveWindow(rcWindow,FALSE); // Redraw Window RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); }
출처 : www.devpia.com
'Programming > MFC' 카테고리의 다른 글
UNICODE <-> ANSI 변환 (0) | 2011.11.24 |
---|---|
컨트롤을 상속 클래스, NM_CLICK 가 부모윈도우에 통지가 안될때.. (2) | 2010.12.03 |
ini 에서 섹션(Section) 정보 얻기 - GetPrivateProfileSectionNames (6) | 2010.08.13 |
CListCtrl 파일로 저장 - CListCtrl Save, Load (0) | 2010.08.12 |
CImageList Class (0) | 2008.10.08 |
MFC 에서 서로 다른 클래스의 핸들 얻어오기 (1) | 2008.05.30 |
Visual Studio 6.0 + Windows XP 설치 해결법 (0) | 2008.05.28 |
다이얼로그에 드래그앤 드랍 (1) | 2007.04.27 |