-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabControl.h
43 lines (36 loc) · 1.25 KB
/
TabControl.h
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
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TABCONTROL_H
#define TABCONTROL_H
#include <Windows.h>
#include <vector>
#include <string>
#include <commctrl.h>
#include <functional>
#pragma comment(lib, "Comctl32.lib")
class TabControl {
public:
TabControl(HWND parentWindow);
void addTab(const std::wstring& title, HWND content, const std::wstring& filePath = L"");
void removeTab(int index);
int getCurrentTabIndex() const;
void setCurrentTab(int index);
int getTabCount();
HWND getTabControlHandle() const;
HWND getCurrentEditControl() const;
void setCurrentFilePath(const std::wstring& path);
std::vector<std::wstring>& getFilePaths();
std::wstring getCurrentFilePath();
void changeTabName(const std::wstring& filePath);
void Resize(int width, int height);
void DrawTabWithCloseButton(HDC hdc, const RECT& rect, LPCTSTR text, bool isSelected);
std::function<void(int)> onTabChanged;
std::function<void(int)> onTabRemoved;
private:
HWND hTabControl;
WNDPROC OldTabProc;
std::vector<HWND> tabContents;
std::vector<std::wstring> filePaths;
static LRESULT CALLBACK TabProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void showTabContent(int index);
LRESULT OnPaint(HWND hWnd);
};
#endif // TABCONTROL_H