MCPcopy Create free account
hub / github.com/WheretIB/nullc / WndProc

Function WndProc

SuperCalc.cpp:2094–2941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2092 return 0;
2093}
2094LRESULT CALLBACK WndProc(HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
2095{
2096 int wmId, wmEvent;
2097 PAINTSTRUCT ps;
2098 HDC hdc;
2099
2100 char fileName[512];
2101 fileName[0] = 0;
2102 OPENFILENAME openData = { sizeof(OPENFILENAME), hWnd, NULL, "NULLC Files\0*.nc\0All Files\0*.*\0\0", NULL, 0, 0, fileName, 512,
2103 NULL, 0, NULL, NULL, OFN_ALLOWMULTISELECT | OFN_EXPLORER, 0, 0, 0, 0, 0, 0, NULL, 0, 0 };
2104
2105 char result[1024];
2106
2107 __try
2108 {
2109 switch(message)
2110 {
2111 case WM_CREATE:
2112 runRes.finished = true;
2113 runRes.wnd = hWnd;
2114
2115 breakResponse = CreateEvent(NULL, false, false, "NULLC Debug Break Continue Event");
2116 break;
2117 case WM_DESTROY:
2118 if(hWnd == ::hWnd)
2119 {
2120 if(!runRes.finished)
2121 {
2122 TerminateThread(calcThread, 0);
2123 runRes.finished = true;
2124 }
2125
2126 FILE *tabInfo = fopen("nullc_tab.cfg", "wb");
2127 FILE *undoStorage = fopen("nullc_undo.bin", "wb");
2128 int ptrSize = sizeof(void*);
2129 fwrite(&ptrSize, sizeof(int), 1, undoStorage);
2130 for(unsigned int i = 0; i < richEdits.size(); i++)
2131 {
2132 char buf[1024];
2133 safeprintf(buf, 1024, "File '%s' was changed.\r\nSave changes?", TabbedFiles::GetTabInfo(hTabs, i).name);
2134 if(TabbedFiles::GetTabInfo(hTabs, i).dirty && TabbedFiles::GetTabInfo(hTabs, i).last[0] != '?' && MessageBox(hWnd, buf, "Warning", MB_YESNO) == IDYES)
2135 SaveFileFromTab(TabbedFiles::GetTabInfo(hTabs, i).name, RichTextarea::GetAreaText(TabbedFiles::GetTabInfo(hTabs, i).window), TabbedFiles::GetTabInfo(hTabs, i).window);
2136 fprintf(tabInfo, "%s\r\n", TabbedFiles::GetTabInfo(hTabs, i).name);
2137
2138 unsigned nameLength = (int)strlen(TabbedFiles::GetTabInfo(hTabs, i).name) + 1;
2139 fwrite(&nameLength, sizeof(unsigned), 1, undoStorage);
2140 fwrite(TabbedFiles::GetTabInfo(hTabs, i).name, 1, nameLength, undoStorage);
2141 RichTextarea::SaveHistory(richEdits[i], undoStorage);
2142
2143 DestroyWindow(richEdits[i]);
2144 }
2145 for(unsigned int i = 0; i < attachedEdits.size(); i++)
2146 DestroyWindow(attachedEdits[i]);
2147 fclose(undoStorage);
2148 fclose(tabInfo);
2149 RichTextarea::UnregisterTextarea();
2150 PostQuitMessage(0);
2151 }

Callers

nothing calls this directly

Calls 15

safeprintfFunction · 0.85
SaveFileFromTabFunction · 0.85
RefreshBreakpointsFunction · 0.85
FillVariableInfoTreeFunction · 0.85
nullcGetLastErrorFunction · 0.85
UpdateWatchedVariablesFunction · 0.85
nullcDebugTypeInfoFunction · 0.85
PipeSendRequestFunction · 0.85
PipeReceiveResponceFunction · 0.85
IsBadReadPtrFunction · 0.85
FillArrayVariableInfoFunction · 0.85
GetBasicVariableInfoFunction · 0.85

Tested by

no test coverage detected