Skip to content

Commit

Permalink
Some cool improvements
Browse files Browse the repository at this point in the history
- new win32 error debug thing
- now loadcursor and loadbitmap and loadstring works
- now window class registers!
  • Loading branch information
dz333n committed Jun 27, 2019
1 parent a8dd10d commit e3ae04e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
57 changes: 41 additions & 16 deletions COREDLL/COREDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace COREDLL
#ifdef __cplusplus
extern "C" {
#endif
BOOL ProgramErrorDialog(LPCWSTR Text);
BOOL ProgramErrorDialog(LPCWSTR Text, BOOL YesNo);

BOOL InvalidateRect_WCECL(HWND hWnd, const RECT *lpRect, BOOL bErase)
{
Expand Down Expand Up @@ -85,15 +85,9 @@ namespace COREDLL

HCURSOR LoadCursorW_WCECL(HINSTANCE hInstance, LPCWSTR lpCursorName)
{
#ifdef LOADCURSOR_WORS
// This functions was replaced by LoadImage, so
auto result = (HCURSOR)::LoadImageW(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0, LR_SHARED);
auto result = (HCURSOR)::LoadImageW(NULL, lpCursorName, IMAGE_CURSOR, 0, 0, LR_SHARED);
return result;
#else
// FIX ME currently fails in Solitare (https://github.com/feel-the-dz3n/wcecl/issues/6) so force default cursor
auto result = (HCURSOR)LoadImageW(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED);
return result;
#endif
}

int LoadStringW_WCECL(
Expand All @@ -102,7 +96,14 @@ namespace COREDLL
LPWSTR lpBuffer,
int cchBufferMax)
{
auto result = ::LoadStringW(hInstance, uID, lpBuffer, cchBufferMax);
auto result = ::LoadStringW(NULL, uID, lpBuffer, cchBufferMax);

if (w32err(result == NULL))
{
auto win32error = GetLastError();
DebugBreak();
}

return result;
}

Expand Down Expand Up @@ -173,13 +174,31 @@ namespace COREDLL

HICON LoadIconW_WCECL(HINSTANCE hInstance, LPCWSTR lpIconName)
{
auto result = ::LoadIconW(hInstance, lpIconName);
auto result = ::LoadIconW(NULL, lpIconName);
return result;
}

HWND FindWindowW_WCECL(LPCWSTR lpClassName, LPCWSTR lpWindowName)
{
auto result = ::FindWindowW(lpClassName, lpWindowName);
return result;
}

BOOL SetForegroundWindow_WCECL(HWND hWnd)
{
auto result = ::SetForegroundWindow(hWnd);
return result;
}

BOOL TerminateProcess_WCECL(HANDLE hProcess, DWORD uExitCode)
{
auto result = ::TerminateProcess(hProcess, uExitCode);
return result;
}

ATOM RegisterClassW_WCECL(const WNDCLASS *lpWndClass)
{
auto result = ::RegisterClass(lpWndClass);
auto result = ::RegisterClassW(lpWndClass);
return result;
}

Expand Down Expand Up @@ -241,6 +260,12 @@ namespace COREDLL
hInstance,
lpParam);

if (w32err(result == NULL))
{
auto win32error = GetLastError();
DebugBreak();
}

return result;
}

Expand Down Expand Up @@ -305,18 +330,18 @@ namespace COREDLL
Stub(WeirdThing1841);
Stub(WeirdThing1840);

BOOL ProgramErrorDialog(LPCWSTR Text)
BOOL ProgramErrorDialog(LPCWSTR Text, BOOL YesNo)
{
int box = MessageBoxExW(
NULL,
Text,
L"Windows CE Compatibility Layer",
MB_YESNOCANCEL,
(YesNo ? MB_YESNO : MB_YESNOCANCEL),
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));

if (box == IDNO) return TRUE;
else if (box == IDCANCEL) exit(1);
else return FALSE; // yes/close
if (box == IDNO && !YesNo) return TRUE;
else if ((box == IDCANCEL) || (box == IDNO && YesNo)) exit(1);
else return FALSE; // yes/close

return FALSE;
}
Expand Down
6 changes: 3 additions & 3 deletions COREDLL/Exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ EXPORTS
SetScrollRange @281
MapWindowPoints @284
CallWindowProcW @285
FindWindowW @286
FindWindowW=FindWindowW_WCECL @286
EnableWindow @287
IsWindowEnabled @288
ScrollWindowEx @289
Expand Down Expand Up @@ -126,7 +126,7 @@ EXPORTS
SizeofResource @534
OutputDebugStringW @541
RaiseException @543
TerminateProcess @544
TerminateProcess=TerminateProcess_WCECL @544
NKDbgPrintfW @545
CreateFileMappingW @548
MapViewOfFile @549
Expand All @@ -150,7 +150,7 @@ EXPORTS
IsDialogMessageW @698
MapDialogRect @699
SetDlgItemInt @700
SetForegroundWindow @702
SetForegroundWindow=SetForegroundWindow_WCECL @702
SetActiveWindow @703
SetFocus @704
SetCapture @708
Expand Down
3 changes: 2 additions & 1 deletion COREDLL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
#undef RasHangUp
#undef RasDial

#define Stub(Function) int Function() { return ProgramErrorDialog(L"Function " #Function " is not implemented yet.\n\nYES - return FALSE\nNO - return TRUE\nCANCEL - exit"); }
#define Stub(Function) int Function() { return ProgramErrorDialog(L"Function " #Function " is not implemented yet.\n\nYES - return FALSE\nNO - return TRUE\nCANCEL - exit", FALSE); }
#define StubSilent(Function) int Function() { return FALSE; }
#define w32err(Expression) (Expression) && IsDebuggerPresent()

0 comments on commit e3ae04e

Please sign in to comment.