| 90 | }; |
| 91 | |
| 92 | LRESULT CALLBACK PiuWindowProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) |
| 93 | { |
| 94 | static BOOL tracking = FALSE; |
| 95 | switch(message) { |
| 96 | case WM_CREATE: { |
| 97 | CREATESTRUCT* cs = (CREATESTRUCT*)lParam; |
| 98 | SetWindowLongPtr(window, 0, (LONG_PTR)cs->lpCreateParams); |
| 99 | PiuView* piuView = (PiuView*)GetWindowLongPtr(window, 0); |
| 100 | (*piuView)->window = window; |
| 101 | HKEY key; |
| 102 | DWORD size = 4; |
| 103 | char szSubKey[1024]; |
| 104 | char title[64]; |
| 105 | c_strcpy(szSubKey, "SOFTWARE\\moddable.tech\\"); |
| 106 | title[0] = 0; |
| 107 | GetWindowText(window, title, sizeof(title)); |
| 108 | if (0 != c_strlen(title)) |
| 109 | c_strcat(szSubKey, title); |
| 110 | else |
| 111 | c_strcat(szSubKey, "Screen Test"); |
| 112 | c_strcat(szSubKey, "\\window"); |
| 113 | if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &key) == ERROR_SUCCESS) { |
| 114 | WINDOWPLACEMENT placement; |
| 115 | placement.length = sizeof(WINDOWPLACEMENT); |
| 116 | placement.flags = 0; |
| 117 | RegQueryValueEx(key, "show", 0, NULL, (BYTE*)&placement.showCmd, &size); |
| 118 | RegQueryValueEx(key, "xMin", 0, NULL, (BYTE*)&placement.ptMinPosition.x, &size); |
| 119 | RegQueryValueEx(key, "yMin", 0, NULL, (BYTE*)&placement.ptMinPosition.y, &size); |
| 120 | RegQueryValueEx(key, "xMax", 0, NULL, (BYTE*)&placement.ptMaxPosition.x, &size); |
| 121 | RegQueryValueEx(key, "yMax", 0, NULL, (BYTE*)&placement.ptMaxPosition.y, &size); |
| 122 | RegQueryValueEx(key, "left", 0, NULL, (BYTE*)&placement.rcNormalPosition.left, &size); |
| 123 | RegQueryValueEx(key, "right", 0, NULL, (BYTE*)&placement.rcNormalPosition.right, &size); |
| 124 | RegQueryValueEx(key, "top", 0, NULL, (BYTE*)&placement.rcNormalPosition.top, &size); |
| 125 | RegQueryValueEx(key, "bottom", 0, NULL, (BYTE*)&placement.rcNormalPosition.bottom, &size); |
| 126 | SetWindowPos(window, NULL, placement.rcNormalPosition.left, placement.rcNormalPosition.top, placement.rcNormalPosition.right - placement.rcNormalPosition.left, placement.rcNormalPosition.bottom - placement.rcNormalPosition.top, SWP_NOZORDER); |
| 127 | RegCloseKey(key); |
| 128 | } |
| 129 | SetTimer(window, 0, USER_TIMER_MINIMUM, NULL); |
| 130 | } break; |
| 131 | case WM_COPYDATA: { |
| 132 | COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam; |
| 133 | PiuView* piuView = (PiuView*)GetWindowLongPtr(window, 0); |
| 134 | xsBeginHost((*piuView)->the); |
| 135 | { |
| 136 | PiuApplication* application = (*piuView)->application; |
| 137 | xsVars(3); |
| 138 | xsVar(0) = xsReference((*application)->behavior); |
| 139 | if (xsFindResult(xsVar(0), xsID_onOpenFile)) { |
| 140 | xsVar(1) = xsReference((*application)->reference); |
| 141 | xsVar(2) = xsStringW((wchar_t*)cds->lpData); |
| 142 | (void)xsCallFunction2(xsResult, xsVar(0), xsVar(1), xsVar(2)); |
| 143 | } |
| 144 | PiuApplicationAdjust(application); |
| 145 | } |
| 146 | xsEndHost((*piuView)->the); |
| 147 | } break; |
| 148 | case WM_CLOSE: { |
| 149 | PiuView* piuView = (PiuView*)GetWindowLongPtr(window, 0); |
nothing calls this directly
no test coverage detected