수안이의 컴퓨터 연구실

  • Mainpage
  • About Me
  • Tags
  • Metapage
  • Notice
  • Location
  • Keywords
  • Guestbook
  • Admin
  • Write an Article
  • Total | 1693891
  • Today | 242
  • Yesterday | 588

Programming/MFC2007/02/22 10:23

Toolbar안에 다른 Control넣기

원본 : http://www.debuglab.com/knowledge/toolbarcontrol.html

1.요약

Font종류나 확대/축소 비율을 정할 때 Toolbar에 ComboBox를 넣어서 많이 씁니다. 이처럼 자기가 원하는 Control를 Toolbar안에 어떻게 삽입하는지 설명하겠습니다.


2.본문

ComboBox를 생성하는 것을 예로 들었습니다.
CToolBarEx를 상속받는 CCombobar를 생성한다.
CCombobar에서 다음과 같이 구현해 준다.

/////////////////////

// combobar.cpp



BEGIN_MESSAGE_MAP(CComboBar, CToolBarEx) 

//{{AFX_MSG_MAP(CComboBar) 

ON_CBN_SELENDOK(IDW_TOOLCOMBO, OnSelEndOk) 

//}}AFX_MSG_MAP 

END_MESSAGE_MAP() 



// 이안에서 Toolbar도 생성하고 ComboBox도 생성한다. 

BOOL CComboBar::Create(CFrameWnd * pParent, UINT nID, UINT nComboID, 

                       const int nWidth, 

                       const int nHeight) 

{ 

    // Create the toolbar as CMainFrame::OnCreate() would do 

    if (!CToolBar::Create(pParent) || 

        !LoadToolBar(nID)) 

    { 

        TRACE0("Falied to create the toolbar.\n"); 

        return FALSE;      // fail to create 

    } 

    

    // set the size of combo-control 

    CRect rect(-nWidth, -nHeight, 0, 0); 

    

    

    // ComboxBox가 들어갈 위치를 TBBS_SEPARATOR속성으로 바꾸고 

    // 넓이를 지정해 준다. 

    ASSERT(CommandToIndex(nComboID) >= 0); // make sure the id is valid 

    SetButtonInfo(CommandToIndex(nComboID), nComboID, TBBS_SEPARATOR, nWidth); 

    

    // ComboBox를 생성한다. 

    if (!m_pWndBox.Create(WS_CHILD | CBS_DROPDOWN | 

        CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS, rect, this, 

        nComboID)) 

    { 

        TRACE("Failed to create the combo-box %p .\n", ComboID); 

        return FALSE; 

    } 

    

    // ComboBox가 들어갈 위치의 크기를 가져온다. 

    // 그 크기에 따라 ComboBox의 크기와 위치를 조절해 준다. 

    GetItemRect(CommandToIndex(nComboID), &rect); 

    m_pWndBox.SetWindowPos(0, rect.left, rect.top, 0, 0, 

        SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCOPYBITS); 

    m_pWndBox.SetFont(&m_GuiFont); 

    m_pWndBox.ShowWindow(SW_SHOW); 

    

    if (!OnInitialCreate()) 

    { 

        TRACE("Failed to add strings to %p\n", nComboID); 

        return FALSE; 

    } 

    

    return TRUE; 

} 



// ComboBox의 데이터를 초기화한다. 

BOOL CComboBar::OnInitialCreate() 

{ 

    if(m_pWndBox.m_hWnd != NULL) 

    { 

        //This is where you add your strings 

        m_pWndBox.AddString("Page Width"); 

        m_pWndBox.AddString("150 %"); 

        m_pWndBox.AddString("125 %"); 

        m_pWndBox.AddString("100 %"); 

        m_pWndBox.AddString("75  %"); 

        m_pWndBox.AddString("50  %"); 

        m_pWndBox.AddString("25  %"); 

        //Don't forget the initial position. 

        m_pWndBox.SetCurSel(0); 

        

        return TRUE; 

    } 

    return FALSE; 

} 



int CComboBar::m_cbIndex = 0; 



void CComboBar::OnSelEndOk() 

{ 

    m_cbIndex = m_pWndBox.GetCurSel(); 

} 





/////////////////////////

// combobar.h 





class CComboBar : public CToolBarEx 

{ 

    // Construction 

public: 

    CComboBar(); 

    CComboBox m_pWndBox; 

    

    static int m_cbIndex; 

    

    // Attributes 

public: 

    

    // Operations 

public: 

    BOOL OnInitialCreate(); 

    //  is the toolbar-resource to load 

    //  is the ID of the button, that shall be used as the 

    combo-control 

        BOOL Create(CFrameWnd * pParent, UINT nID, UINT nComboID, const int 

        nWidth, 

        const int nHeight); 

    

    // Overrides 

    // ClassWizard generated virtual function overrides 

    //{{AFX_VIRTUAL(CComboBar) 

public: 

    virtual void OnFinalRelease(); 

    //}}AFX_VIRTUAL 

    

    // Implementation 

public: 

    virtual ~CComboBar(); 

    

    // Generated message map functions 

protected: 

    //{{AFX_MSG(CComboBar) 

    //}}AFX_MSG 

    

    DECLARE_MESSAGE_MAP() 

        // Generated OLE dispatch map functions 

        //{{AFX_DISPATCH(CComboBar) 

        // NOTE - the ClassWizard will add and remove member functions here. 

        afx_msg void OnSelEndOk(); 

    //}}AFX_DISPATCH 

    DECLARE_DISPATCH_MAP() 

        DECLARE_INTERFACE_MAP() 

}; 

CMainFrame에서 CCombobar를 선언해서 일반 툴바와 같은 방법으로 사용한다.



- 2001.08.13 Smile Seo -

"MFC" 카테고리의 다른 글
  • Explorer처럼 툴바에 Text 넣기 (0)2007/02/22
  • 문자열 검색 API (0)2007/02/22
  • Toolbar안에 다른 Control넣기 (0)2007/02/22
  • Winamp 처럼 벽에 붙이기 (0)2007/02/22
  • 윈앰프처럼 TaskBar와 SystemTray 마음대로 주무루기 (0)2007/02/22
2007/02/22 10:23 2007/02/22 10:23
Posted by webdizen
Tags ComboBox, ToolBar
No Trackback No Comment

Trackback URL : http://www.webdizen.net/blog/trackback/2626

Leave your greetings.

[로그인][오픈아이디란?]

«Prev  1 ... 622 623 624 625 626 627 628 629 630 ... 3009  Next»

RSS HanRSS
Blog Image
webdizen
이곳은 컴퓨터에 대해 연구하고, 공유하고, 소통하기 위한 연구실입니다. 개인적으로는 OLAP, Data Mining, Semantic Web, Data Modeling에 대해서 연구하고 있습니다.

Categories

전체 (3009)
Webdizen (141)
Life (6)
Diary (16)
Blog (9)
IDEA (2)
Travel (10)
Book (16)
Photo (7)
Movie (8)
Music (14)
Leisure Sports (10)
Funny (6)
Hardware (121)
Software (120)
Windows (5)
Unix & Linux (120)
Installation (5)
Kernel (10)
System (34)
Develop (22)
X-Window (0)
Applicaton (31)
Security (4)
Framework (2)
Hadoop (2)
Programming (804)
Algorithm & Data Structure (1)
Assembly (38)
UNIX/Linux C (95)
C++ (128)
STL (4)
Java (38)
Win32 API (92)
ATL/COM (44)
MFC (151)
.NET (26)
WCF/WPF (4)
C# (28)
Network Programming (17)
Database Programming (12)
OpenGL / DirectX (13)
Multimedia Programming (0)
Game Programming (21)
Parallel Distributed Progra... (0)
Reverse Engineering (0)
Debugging (9)
Python (1)
Ruby (1)
Ruby on Rails (1)
QT (4)
GTK (0)
JSP (0)
PHP (6)
ASP.NET (6)
ASP (2)
Development (28)
Useful Library (2)
Data Modeling (0)
Database (105)
Oracle (4)
MSSQL (41)
MySQL (2)
Data Warehouse (2)
Data Mining (4)
Network (66)
Web (79)
DHTML (4)
XHTML (1)
Javascript (1)
CSS (1)
AJAX (9)
XML (11)
Flex (1)
Silverlight (3)
Security (91)
DoS (1)
Kernel (10)
Scanning (3)
Sniffing (0)
Spoofing (4)
Overflow (28)
Web (11)
Shell (10)
Format String (14)
Window (2)
Embedded (70)
Multimedia (27)
Mobile (14)
Graphic (24)
Management (633)
Knowledge (581)
Hadoop (0)

Notice

  • 메타 블로그 사이트에 등록
  • 새해 맞이 블로그의 변화
  • 블로그 명칭 변경
  • 도메인(www.webdizen.net) 구...
  • TEXTCUBE 1.6.1로 업그레이드...

Tags

  • 분산 프로세스
  • 싱크
  • 엔터티빈
  • 정보학
  • 윈도우 종료
  • G.ho.st
  • 전처리
  • BDM
  • Solaris
  • Code
  • The Secret
  • ALTIBASE
  • 버퍼 오버런
  • 휘닉스 파크
  • Naver
  • WORLDCOMP
  • 프로세스
  • 20가지 법칙
  • Data Mart
  • 베르사유

Recent Articles

  • 트위터(Twitter)의 시작!.
  • 청년 리더의 조건.
  • 애플의 타블렛 PC - 아이패드....
  • 미래의 인터페이스 - 육감 기....
  • 기초발성법 동영상 강좌.

Recent Comments

  • 학교 과제물중 쓰레드에 대하....
    장진혁 03/17
  • 관리자만 볼 수 있는 댓글입....
    비밀방문자 03/12
  • 상대방의 이야기를 열심히 경....
    DoNuts 03/03
  • Lots of students know techn....
    Bobbi35Shannon 02/25
  • 좋은글 잘 보고 갑니다..
    Und_hacker 01/08

Recent Trackbacks

  • printf,scanf를 이용한 형식....
    yundream의 프로그래밍 이야기 03/10
  • 파일 열기/저장하기 CFileDialog.
    은마군의 나태블록 2009
  • World IT Show 2008.
    상우 :: Oranzie's BLOG 2008
  • cvs서버 설치하기.
    3인3색 2008
  • 속속 공개되는 Google Chart....
    PHP와 Web 2.0 2007

Archive

  • 2010/02 (1)
  • 2010/01 (6)
  • 2009/12 (5)
  • 2009/09 (3)
  • 2009/08 (1)

Calendar

«   2010/03   »
일 월 화 수 목 금 토
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Bookmarks

    • Administration
      • IIS.NET
      • NTFAQ
      • OS의 모든 것
      • 리눅스포털
    • Database
      • SQL Server Central
      • SQL Team
    • Development
      • .NET Heaven
      • ASP Alliance
      • ASP.NET 2.0
      • Bullog.net
      • C# Corner
      • C++ (C PlusPlus.com)
      • C++ Reference
      • CodeGuru
      • CodePlex
      • DebugLab
      • Dev Articles
      • Devpia
      • DotNet Junkies
      • DotNet Zone
      • Driver Online
      • GOSU.NET
      • HOONS 닷넷
      • Joinc 팀블로그
      • KOSR
      • MSDN Home Page
      • OSR Online
      • Sky.ph - 개발자 커뮤니...
      • TAEYO.NET
      • The Code Project
      • WindowsClient.net
      • 김상욱의 개발자 Side
      • 조인시 위키
    • Human Networks
      • belief21c's e-space
      • I think I can
      • Invisible Rover's Blog :D
      • Rodman®
      • ■ Feel So Good~! ■
      • 까만 나비
      • 나를 가꾸는 시간.
      • 나만의 즐거움~~!
      • 단녕
      • 상우 :: Oranzie's BLOG
    • Information Technology
      • Microsoft TechNet
      • 지디넷코리아 - 글로벌...
    • Security
      • FoundStone
      • milw0rm
      • NewOrder
      • OpenRCE
      • Phrack.org
      • Reverse Engineering b1...
      • Reverse Engineering Team
      • RootKit
      • SecurityFocus
      • SecurityXploded by Nag...
      • Wow Hacker
      • Zone-H
Textcube
Louice Studio Inc.
Powered by Textcube. Original designed by Tistory.