-
Notifications
You must be signed in to change notification settings - Fork 0
/
DVDHandler.cpp
115 lines (108 loc) · 2.29 KB
/
DVDHandler.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "DVDHandler.h"
#include "OMDbInfo.h"
#include <string>
#include "MkvParseStream.h"
DVDHandler::DVDHandler()
{
info = new OMDbInfo(set.strOMDbkey);
LoadDrives();
}
void DVDHandler::LoadDrives()
{
char volBuf[MAX_PATH+1] = {0};
DWORD driveMask = GetLogicalDrives();
char drive = 'A';
while (driveMask)
{
if (driveMask & 1)
{
sprintf_s(volBuf, MAX_PATH, "%c:\\", drive);
UINT ret = GetDriveTypeA(volBuf);
if (ret == DRIVE_CDROM)
{
Worker* w = new Worker(drive, &set);
mapWorkers[drive] = w;
}
}
driveMask >>= 1;
drive++;
}
}
void DVDHandler::SetupOutput(HWND parent)
{
std::map<char, Worker*>::iterator it;
for (it = mapWorkers.begin(); it != mapWorkers.end(); it++)
{
Worker* w = it->second;
HWND txtBox = CreateWindowEx(
0, L"EDIT", // predefined class
NULL, // no window title
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_READONLY |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 300, 300, // set size in WM_SIZE message
parent, // parent window
0, // edit control ID
(HINSTANCE)GetWindowLongPtr(parent, GWLP_HINSTANCE),
NULL);
w->SetTextWindow(txtBox);
}
UpdateTextPositions();
}
void DVDHandler::UpdateTextPositions()
{
int wide = set.wndWide;
if (mapWorkers.size() > 1)
{
wide = set.wndWide / (int)mapWorkers.size();
}
std::map<char, Worker*>::iterator it;
int left = 0;
for (it = mapWorkers.begin(); it != mapWorkers.end(); it++)
{
HWND hwnd = it->second->GetTextWindow();
if (hwnd == NULL)
{
continue;
}
MoveWindow((HWND)(hwnd),
left, 0, // starting x- and y-coordinates
wide, // width of client area
set.wndHigh, // height of client area
TRUE); // repaint window
left += wide;
}
}
void DVDHandler::WindowChanged(int x, int y, int width, int height)
{
set.xPos = x;
set.yPos = y;
set.wndWide = width;
set.wndHigh = height;
UpdateTextPositions();
set.SaveSettings();
}
void DVDHandler::DiskLoaded(char drive)
{
Worker* w = mapWorkers[drive];
if (w == NULL)
{
Worker* w = new Worker(drive, &set);
mapWorkers[drive] = w;
w->Start();
}
else
{
w->Start();
}
}
void DVDHandler::DiskEjected(char drive)
{
Worker* w = mapWorkers[drive];
if (w)
{
w->Stop();
// cleanup
//mapWorkers[drive] = NULL;
//delete w;
}
}