ボタン以外のコントロールです。
MyControl.h は次のようにします。
#pragma once /* コントロール */ #include <windowsx.h> #include <commctrl.h> class MyControl : public MyCreateStruct{ public: // コンストラクタ MyControl(){ style = WS_CHILD | WS_VISIBLE; hwndParent = hWnd; Location(0, 0); Size(100, 100); } // 生成前のメソッド void ID(int id){ hMenu = (HMENU)id; } // 生成後のメソッド HWND SetID(int id){ hwnd = GetDlgItem(hWnd, id); return hwnd; } // キャプション void GetText(LPTSTR txt){ GetWindowText(hwnd, txt, GetWindowTextLength(hwnd) + 1); } // キャプション void SetText(LPCTSTR txt){ SetWindowText(hwnd, txt); } void Move(int x, int y, int cx, int cy){ MoveWindow(hwnd, x, y, cx, cy, TRUE); } }; //=============================================== // 部品A //=============================================== // ボタン------------------------------ class MyButton : public MyControl{ public: MyButton(){ lpszClass = L"BUTTON"; style = style | BS_DEFPUSHBUTTON; } }; // チェックボタン-------------------- class MyCheckBox : public MyControl{ public: MyCheckBox(){ lpszClass = L"BUTTON"; style = style | BS_AUTOCHECKBOX; } }; // ラジオボタン-------------------- class MyRadioBox : public MyControl{ public: MyRadioBox(){ lpszClass = L"BUTTON"; style = style | BS_AUTORADIOBUTTON; } }; // グループボックス-------------------- class MyGroupBox : public MyControl{ public: MyGroupBox(){ lpszClass = L"BUTTON"; style = style | BS_GROUPBOX; } }; // ラベル------------------------------ class MyLabel : public MyControl{ public: MyLabel(){ lpszClass = L"STATIC"; style = style | SS_NOTIFY | SS_LEFT; } }; // スタティック・ピクチャー------------------ class MyStaticPicture : public MyControl{ public: MyStaticPicture(){ lpszClass = L"STATIC"; style = style | SS_SUNKEN | SS_NOTIFY; } }; // エディット------------------------------------ class MyEdit : public MyControl{ public: MyEdit(){ lpszClass = L"EDIT"; style = style | WS_BORDER | ES_AUTOHSCROLL; } }; // エディットボックス class MyEditBox : public MyControl{ public: MyEditBox(){ lpszClass = L"EDIT"; style = style | WS_BORDER | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL; } }; // コンボボックス-------------------------------- class MyComboBox : public MyControl{ public: MyComboBox(){ lpszClass = L"COMBOBOX"; style = style | WS_VSCROLL | CBS_DROPDOWNLIST; } // アイテム追加 void addItem(LPCTSTR txt){ ComboBox_AddString(hwnd, (LPCSTR)txt); } // 焦点 void SetCurSel(int no){ ComboBox_SetCurSel(hwnd, no); } }; // リストボックス class MyListBox:public MyControl{ public: MyListBox(){ lpszClass = L"LISTBOX"; style = style | WS_BORDER | WS_VSCROLL | LBS_NOTIFY; } void addItem(LPCTSTR txt){ ListBox_AddString(hwnd, txt); } void SetCurSel(int no){ ListBox_SetCurSel(hwnd, no); } }; // 横スクロールバー------------------------------ class MyHScrollBar:public MyControl{ public: MyHScrollBar(){ lpszClass = L"SCROLLBAR"; style = style | SBS_HORZ; } }; // 縦スクロールバー class MyVScrollBar:public MyControl{ public: MyVScrollBar(){ lpszClass = L"SCROLLBAR"; style = style | SBS_VERT; } }; //=============================================== // 部品B //=============================================== // タブコントロール class MyTabControl:public MyControl{ public: TCITEM tcItem; int no; MyTabControl(){ lpszClass = WC_TABCONTROL; style = style | WS_CLIPSIBLINGS; no = 0; } void addItem(LPTSTR); }; void MyTabControl::addItem(LPTSTR txt){ tcItem.mask = TCIF_TEXT; tcItem.pszText = txt; SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)no++, (LPARAM)&tcItem); } // ツリービュー class MyTreeView:public MyControl{ public: TVINSERTSTRUCT tvi; HTREEITEM hTreeItem; MyTreeView(){ lpszClass = WC_TREEVIEW; style = style | WS_BORDER | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT; } void addItem(LPTSTR); }; /* void MyTreeView::addItem(LPTSTR txt){ tvi.hParent = TVI_ROOT; tvi.hInsertAfter = TVI_SORT; tvi.item.mask = TVIF_TEXT; tvi.item.pszText = txt; hTreeItem = TreeView_InsertItem(hwnd , &tvi); tvi.hParent = hTreeItem; for ( ; iCount < 3 ; iCount++) { tvi.item.pszText = strItem[iCount]; TreeView_InsertItem(hTree , &tvi); } } */ // リストビュー class MyListView:public MyControl{ public: LVCOLUMN col; LVITEM item; int iColumn; int iCount; MyListView(){ lpszClass = WC_LISTVIEW; style = style | WS_BORDER | LVS_REPORT; iColumn = 0; iCount = 0; } void addColumn(LPTSTR); void addItem(LPTSTR); }; /* MyListView::MyListView():MyControl(WC_LISTVIEW, WS_BORDER | LVS_REPORT){ // item = {0}; iColumn = 0; iCount = 0; } */ void MyListView::addColumn(LPTSTR txt){ col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; col.fmt = LVCFMT_LEFT; col.cx = 100; col.pszText = txt; ListView_InsertColumn(hwnd, iColumn++, &col); } void MyListView::addItem(LPTSTR txt){ item.mask = LVIF_TEXT; item.pszText = txt; item.iItem = iCount++; ListView_InsertItem(hwnd, &item); } // リッチエディット class MyRichEdit:public MyControl{ public: MyRichEdit(){ lpszClass = L"SYSTABCONTROL32"; style = style | WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL | ES_AUTOHSCROLL; } }; // トラックバー class MyTrackBar:public MyControl{ public: MyTrackBar(){ lpszClass = L"MSCTLS_TRACKBAR32"; style = style | TBS_AUTOTICKS; } }; // プログレスバー class MyProgressBar:public MyControl{ public: MyProgressBar(){ lpszClass = L"MSCTLS_PROGRESS32"; style = style | WS_BORDER; } }; // アップダウンコントロール class MyUpDownCtrl:public MyControl{ public: MyUpDownCtrl(){ lpszClass = L"MSCTLS_UPDOWN32"; style = style | UDS_ALIGNRIGHT; } }; // ヘッダー class MyHeader:public MyControl{ public: MyHeader(){ lpszClass = L"SYSHEADER32"; style = style | HDS_BUTTONS; } }; // ホットキー class MyHotKey:public MyControl{ public: MyHotKey(){ lpszClass = L"MSCTLS_HOTKEY32"; style = style | WS_BORDER; } }; // アニメーション class MyAnimation:public MyControl{ public: MyAnimation(){ lpszClass = L"SYSANIMATE32"; style = style | WS_BORDER; } }; // Dtp class MyDtp:public MyControl{ public: MyDtp(){ lpszClass = L"SysDateTimePick32"; style = style | DTS_RIGHTALIGN; } }; // カレンダー class MyMc:public MyControl{ public: MyMc(){ lpszClass = MONTHCAL_CLASS; style = style | MCS_NOTODAY; } }; // class MyIpa:public MyControl{ public: MyIpa(){ lpszClass = L"SYSIPADDRESS32"; style = style | WS_BORDER; } }; // コンボボックス class MyComboBoxEx:public MyControl{ public: MyComboBoxEx(){ lpszClass = WC_COMBOBOXEX; style = style | CBS_DROPDOWN | CBS_SORT | WS_VSCROLL; } };
基本的には別名です。 説明は、別の所でします。