Merge branch 'work/no-console'
This commit is contained in:
commit
1e94cd9975
@ -10,6 +10,7 @@
|
|||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
// Windows XP look and feel. Seems to enable Vista look as well.
|
// Windows XP look and feel. Seems to enable Vista look as well.
|
||||||
#pragma comment(linker, \
|
#pragma comment(linker, \
|
||||||
@ -29,7 +30,31 @@ const char *mainWindowTitle = "GNU Rocket System";
|
|||||||
const wchar_t *mainWindowTitleW = L"GNU Rocket System";
|
const wchar_t *mainWindowTitleW = L"GNU Rocket System";
|
||||||
const char *keyName = "SOFTWARE\\GNU Rocket";
|
const char *keyName = "SOFTWARE\\GNU Rocket";
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
void verror(const char *fmt, va_list va)
|
||||||
|
{
|
||||||
|
char temp[4096];
|
||||||
|
vsnprintf(temp, sizeof(temp), fmt, va);
|
||||||
|
MessageBox(NULL, temp, mainWindowTitle, MB_OK | MB_ICONERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
verror(fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
void die(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
verror(fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
HINSTANCE hInst;
|
||||||
HWND hwnd = NULL;
|
HWND hwnd = NULL;
|
||||||
TrackView *trackView = NULL;
|
TrackView *trackView = NULL;
|
||||||
HWND trackViewWin = NULL;
|
HWND trackViewWin = NULL;
|
||||||
@ -204,7 +229,8 @@ void loadDocument(const std::wstring &_fileName)
|
|||||||
SendMessage(hwnd, WM_CURRVALDIRTY, 0, 0);
|
SendMessage(hwnd, WM_CURRVALDIRTY, 0, 0);
|
||||||
InvalidateRect(trackViewWin, NULL, FALSE);
|
InvalidateRect(trackViewWin, NULL, FALSE);
|
||||||
}
|
}
|
||||||
else MessageBox(hwnd, "failed to open file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
else
|
||||||
|
error("failed to open file");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileOpen()
|
void fileOpen()
|
||||||
@ -252,7 +278,8 @@ void fileSaveAs()
|
|||||||
mruFileList.update();
|
mruFileList.update();
|
||||||
DrawMenuBar(hwnd);
|
DrawMenuBar(hwnd);
|
||||||
}
|
}
|
||||||
else MessageBox(hwnd, "Failed to save file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
else
|
||||||
|
error("Failed to save file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +289,7 @@ void fileSave()
|
|||||||
else if (!document.save(fileName.c_str()))
|
else if (!document.save(fileName.c_str()))
|
||||||
{
|
{
|
||||||
document.sendSaveCommand();
|
document.sendSaveCommand();
|
||||||
MessageBox(hwnd, "Failed to save file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
error("Failed to save file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,17 +333,14 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
trackViewWin = trackView->create(hInstance, hwnd);
|
trackViewWin = trackView->create(hInst, hwnd);
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
statusBarWin = createStatusBar(hInstance, hwnd);
|
statusBarWin = createStatusBar(hInst, hwnd);
|
||||||
|
|
||||||
if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
||||||
{
|
{
|
||||||
if (ERROR_SUCCESS != RegCreateKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
if (ERROR_SUCCESS != RegCreateKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
||||||
{
|
die("failed to create registry key");
|
||||||
printf("failed to create reg key\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recent Files menu */
|
/* Recent Files menu */
|
||||||
@ -426,16 +450,18 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
case ID_EDIT_SETROWS:
|
case ID_EDIT_SETROWS:
|
||||||
{
|
{
|
||||||
int rows = int(trackView->getRows());
|
int rows = int(trackView->getRows());
|
||||||
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
||||||
if (FAILED(result)) MessageBox(hwnd, "unable to create dialog box", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
if (FAILED(result))
|
||||||
|
error("unable to create dialog box");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_EDIT_BIAS:
|
case ID_EDIT_BIAS:
|
||||||
{
|
{
|
||||||
int initialBias = 0;
|
int initialBias = 0;
|
||||||
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
|
INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
|
||||||
if (FAILED(result)) MessageBox(hwnd, "unable to create dialog box", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
if (FAILED(result))
|
||||||
|
error("unable to create dialog box");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -507,20 +533,6 @@ static ATOM registerMainWindowClass(HINSTANCE hInstance)
|
|||||||
return RegisterClassExW(&wc);
|
return RegisterClassExW(&wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
void die(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
char temp[4096];
|
|
||||||
va_list va;
|
|
||||||
va_start(va, fmt);
|
|
||||||
vfprintf(stderr, fmt, va);
|
|
||||||
vsnprintf(temp, sizeof(temp), fmt, va);
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
MessageBox(NULL, temp, mainWindowTitle, MB_OK | MB_ICONERROR);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
SOCKET clientConnect(SOCKET serverSocket, sockaddr_in *host)
|
SOCKET clientConnect(SOCKET serverSocket, sockaddr_in *host)
|
||||||
{
|
{
|
||||||
sockaddr_in hostTemp;
|
sockaddr_in hostTemp;
|
||||||
@ -546,7 +558,8 @@ SOCKET clientConnect(SOCKET serverSocket, sockaddr_in *host)
|
|||||||
return clientSocket;
|
return clientSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
|
LPSTR lpCmdLine, int nShowCmd)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||||
@ -556,23 +569,9 @@ int main(int argc, char* argv[])
|
|||||||
// _CrtSetBreakAlloc(254);
|
// _CrtSetBreakAlloc(254);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hInstance = GetModuleHandle(NULL);
|
hInst = hInstance;
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
DWORD test = 0xdeadbeef;
|
|
||||||
RegSetValueEx(key, "test2", 0, REG_DWORD, (BYTE *)&test, sizeof(DWORD));
|
|
||||||
|
|
||||||
DWORD type = 0;
|
|
||||||
DWORD test2 = 0;
|
|
||||||
DWORD size = sizeof(DWORD);
|
|
||||||
RegQueryValueEx(key, "test2", 0, &type, (LPBYTE)&test2, &size);
|
|
||||||
assert(REG_DWORD == type);
|
|
||||||
printf("%x\n", test2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WSADATA wsa;
|
WSADATA wsa;
|
||||||
if (0 != WSAStartup(MAKEWORD(2, 0), &wsa))
|
if (0 != WSAStartup(MAKEWORD(2, 0), &wsa))
|
||||||
die("Failed to init network");
|
die("Failed to init network");
|
||||||
@ -586,11 +585,9 @@ int main(int argc, char* argv[])
|
|||||||
sin.sin_addr.s_addr = INADDR_ANY;
|
sin.sin_addr.s_addr = INADDR_ANY;
|
||||||
sin.sin_port = htons( 1338 );
|
sin.sin_port = htons( 1338 );
|
||||||
|
|
||||||
puts("binding...");
|
|
||||||
if (SOCKET_ERROR == bind( serverSocket, (struct sockaddr *)&sin, sizeof(sin)))
|
if (SOCKET_ERROR == bind( serverSocket, (struct sockaddr *)&sin, sizeof(sin)))
|
||||||
die("Could not start server");
|
die("Could not start server");
|
||||||
|
|
||||||
puts("listening...");
|
|
||||||
while (listen(serverSocket, SOMAXCONN) == SOCKET_ERROR)
|
while (listen(serverSocket, SOMAXCONN) == SOCKET_ERROR)
|
||||||
; /* nothing */
|
; /* nothing */
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@
|
|||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateManifest="false"
|
GenerateManifest="false"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="2"
|
||||||
RandomizedBaseAddress="1"
|
RandomizedBaseAddress="1"
|
||||||
DataExecutionPrevention="0"
|
DataExecutionPrevention="0"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
@ -139,7 +139,7 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateManifest="false"
|
GenerateManifest="false"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="2"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
RandomizedBaseAddress="1"
|
RandomizedBaseAddress="1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user