Skip to content

Commit 4ac53e8

Browse files
committed
Make it work for 64 bits.
1 parent 43ea161 commit 4ac53e8

5 files changed

Lines changed: 25 additions & 23 deletions

File tree

libmulti/libmulti.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
174174
maxH = userdata[4];
175175

176176
CMultiD2D* d2d = nullptr;
177-
if (_libmulti_exists(wind)) {
177+
if (_libmulti_exists(static_cast<double>(wind))) {
178178
d2d = vecWindows[wind].second;
179179
}
180180

181181
// gm stuff, ignore:
182-
const double window = wind;
182+
const double window = static_cast<double>(wind);
183183
const double zero = 0.0;
184184

185185

@@ -208,7 +208,7 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
208208
// size - 1 because the function won't handle a null byte.
209209
WideCharToMultiByte(CP_UTF8, 0, &wch, 1, mch, sizeof(mch) - 1, nullptr, nullptr);
210210

211-
double w_char = wParam;
211+
double w_char = static_cast<double>(wParam);
212212
// me can't do bit arithmetic so there we go:
213213
double w_repeat_count = LOWORD(lParam);
214214
double w_scancode = (HIWORD(lParam) & 0x00FF);
@@ -339,8 +339,8 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
339339

340340
if (minW > 0 && minH > 0) {
341341
SetRectEmpty(&rc);
342-
rc.right = minW; rc.bottom = minH;
343-
AdjustWindowRectEx(&rc, styles, GetMenu(hWnd) != nullptr, exstyles);
342+
rc.right = static_cast<LONG>(minW); rc.bottom = static_cast<LONG>(minH);
343+
AdjustWindowRectEx(&rc, static_cast<DWORD>(styles), GetMenu(hWnd) != nullptr, static_cast<DWORD>(exstyles));
344344
rc.right -= rc.left;
345345
rc.bottom -= rc.top;
346346

@@ -350,8 +350,8 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
350350

351351
if (maxW > 0 && maxH > 0) {
352352
SetRectEmpty(&rc);
353-
rc.right = maxW; rc.bottom = maxH;
354-
AdjustWindowRectEx(&rc, styles, GetMenu(hWnd) != nullptr, exstyles);
353+
rc.right = static_cast<LONG>(maxW); rc.bottom = static_cast<LONG>(maxH);
354+
AdjustWindowRectEx(&rc, static_cast<DWORD>(styles), GetMenu(hWnd) != nullptr, static_cast<DWORD>(exstyles));
355355
rc.right -= rc.left;
356356
rc.bottom -= rc.top;
357357

@@ -478,7 +478,7 @@ LIBMULTI_DOUBLE libmulti_create_window(double _x, double _y, double _w, double _
478478
std::pair<HWND, int>* startup = new std::pair<HWND, int>(window, S);
479479
DWORD threadId = 0;
480480
intptr_t* userdata = new intptr_t[7];
481-
int ind = _libmulti_find_free();
481+
std::size_t ind = _libmulti_find_free();
482482
userdata[0] = ind;
483483
userdata[1] = minW;
484484
userdata[2] = minH;
@@ -498,7 +498,7 @@ LIBMULTI_DOUBLE libmulti_create_window(double _x, double _y, double _w, double _
498498
LeaveVector();
499499

500500
CreateThread(nullptr, 0, libmulti_window_thread, startup, 0, &threadId);
501-
return ind;
501+
return static_cast<double>(ind);
502502
}
503503

504504
LIBMULTI_DOUBLE libmulti_destroy(double index) {

libmulti/libmulti.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@
7474
</PropertyGroup>
7575
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7676
<LinkIncremental>true</LinkIncremental>
77+
<TargetName>$(ProjectName)_x64</TargetName>
7778
</PropertyGroup>
7879
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
7980
<LinkIncremental>false</LinkIncremental>
8081
</PropertyGroup>
8182
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8283
<LinkIncremental>false</LinkIncremental>
84+
<TargetName>$(ProjectName)_x64</TargetName>
8385
</PropertyGroup>
8486
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8587
<ClCompile>

libmulti/libmulti_focus.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LIBMULTI_DOUBLE libmulti_get_active_window(void) {
2525
HWND window = vecWindows[i].first;
2626
if (window == nullptr) continue; // nope.
2727
if (h == window) {
28-
ret = i;
28+
ret = static_cast<double>(i);
2929
break;
3030
}
3131
}
@@ -47,7 +47,7 @@ LIBMULTI_DOUBLE libmulti_get_foreground_window(void) {
4747
HWND window = vecWindows[i].first;
4848
if (window == nullptr) continue; // nope.
4949
if (h == window) {
50-
ret = i;
50+
ret = static_cast<double>(i);
5151
break;
5252
}
5353
}

libmulti/libmulti_pos.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ LIBMULTI_DOUBLE libmulti_set_x(double index, double x) {
9898
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
9999

100100
RECT empty; SetRectEmpty(&empty);
101-
AdjustWindowRectEx(&empty, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
101+
AdjustWindowRectEx(&empty, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
102102
RECT client;
103103
GetClientRect(window, &client);
104104
POINT p{ 0, client.top };
@@ -119,7 +119,7 @@ LIBMULTI_DOUBLE libmulti_set_y(double index, double y) {
119119
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
120120

121121
RECT empty; SetRectEmpty(&empty);
122-
AdjustWindowRectEx(&empty, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
122+
AdjustWindowRectEx(&empty, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
123123
RECT client;
124124
GetClientRect(window, &client);
125125
POINT p{ 0, client.top };
@@ -143,7 +143,7 @@ LIBMULTI_DOUBLE libmulti_set_position(double index, double x, double y) {
143143
// get the offsets of the non-client area
144144
RECT rc;
145145
SetRectEmpty(&rc);
146-
AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
146+
AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
147147

148148
// I have zero idea how it works, really. I don't understand how these calculations make it work.
149149
coord += rc.left;
@@ -165,7 +165,7 @@ LIBMULTI_DOUBLE libmulti_set_width(double index, double w) {
165165
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
166166

167167
RECT empty; SetRectEmpty(&empty);
168-
AdjustWindowRectEx(&empty, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
168+
AdjustWindowRectEx(&empty, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
169169
RECT rwindow;
170170
GetWindowRect(window, &rwindow);
171171

@@ -184,7 +184,7 @@ LIBMULTI_DOUBLE libmulti_set_height(double index, double h) {
184184
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
185185

186186
RECT empty; SetRectEmpty(&empty);
187-
AdjustWindowRectEx(&empty, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
187+
AdjustWindowRectEx(&empty, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
188188
RECT rwindow;
189189
GetWindowRect(window, &rwindow);
190190

@@ -205,7 +205,7 @@ LIBMULTI_DOUBLE libmulti_set_size(double index, double w, double h) {
205205

206206
RECT rc;
207207
SetRectEmpty(&rc);
208-
AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
208+
AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
209209

210210
// I have zero idea how it works, really.
211211
coord += rc.right - rc.left;
@@ -231,7 +231,7 @@ LIBMULTI_DOUBLE libmulti_set_rectangle(double index, double x, double y, double
231231
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
232232
RECT rc{ ix,iy,iw,ih };
233233
RECT empty; SetRectEmpty(&empty);
234-
AdjustWindowRectEx(&empty, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
234+
AdjustWindowRectEx(&empty, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
235235
ok = SetWindowPos(window, HWND_TOP, rc.left + empty.left, rc.top + empty.top, rc.right + empty.right - empty.left, rc.bottom + empty.bottom - empty.top, SWP_NOZORDER);
236236
LastError = GetLastError();
237237
LeaveVector();
@@ -248,7 +248,7 @@ LIBMULTI_DOUBLE libmulti_get_nonclient_left(double index) {
248248
EnterVector();
249249
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
250250
RECT rc;
251-
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
251+
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
252252
if (ok == TRUE) v = rc.left;
253253
LeaveVector();
254254
return v;
@@ -263,7 +263,7 @@ LIBMULTI_DOUBLE libmulti_get_nonclient_top(double index) {
263263
EnterVector();
264264
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
265265
RECT rc;
266-
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
266+
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
267267
if (ok == TRUE) v = rc.top;
268268
LeaveVector();
269269
return v;
@@ -278,7 +278,7 @@ LIBMULTI_DOUBLE libmulti_get_nonclient_right(double index) {
278278
EnterVector();
279279
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
280280
RECT rc;
281-
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
281+
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
282282
if (ok == TRUE) v = rc.right;
283283
LeaveVector();
284284
return v;
@@ -293,7 +293,7 @@ LIBMULTI_DOUBLE libmulti_get_nonclient_bottom(double index) {
293293
EnterVector();
294294
HWND window = vecWindows[static_cast<std::size_t>(index)].first;
295295
RECT rc;
296-
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, GetWindowLongPtrW(window, GWL_STYLE), GetMenu(window) != nullptr, GetWindowLongPtrW(window, GWL_EXSTYLE));
296+
ok = SetRectEmpty(&rc) && AdjustWindowRectEx(&rc, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_STYLE)), GetMenu(window) != nullptr, static_cast<DWORD>(GetWindowLongPtrW(window, GWL_EXSTYLE)));
297297
if (ok == TRUE) v = rc.bottom;
298298
LeaveVector();
299299
return v;

libmulti/libmulti_thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ DWORD WINAPI libmulti_window_thread(LPVOID lpThreadParameter) {
2424
}
2525

2626
CoUninitialize();
27-
return msg.wParam;
27+
return static_cast<DWORD>(msg.wParam);
2828
}

0 commit comments

Comments
 (0)