diff --git a/meson.build b/meson.build index f00265c..a37701f 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,8 @@ project('scuffedcraft', 'c') cargs = [ '-std=c99', - '-Og' + '-Og', + '-g', ] if host_machine.system() == 'windows' cargs += [ @@ -15,5 +16,5 @@ endif executable( 'scuffedcraft', './src/main.c', - c_args: cargs + c_args: cargs, ) diff --git a/src/main.c b/src/main.c index def03c4..5d06504 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include // int _main() { @@ -32,7 +33,23 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (uMsg) { case WM_LBUTTONDOWN: + { printf("State: msg: %s, num: %d\n", pState->msg, pState->num); + + printf("lParam: %llx\n", lParam); + int mouse_x = GET_X_LPARAM(lParam); + printf("mouse_x: %x\n", mouse_x); + int mouse_y = GET_Y_LPARAM(lParam); + printf("mouse_y: %x\n", mouse_y); + printf("x: %d y: %d\n", mouse_x, mouse_y); + + return 0; + } + + case WM_KEYDOWN: + if (wParam == VK_ESCAPE) { + PostQuitMessage(0); + } return 0; case WM_DESTROY: @@ -74,49 +91,6 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, uMsg, wParam, lParam); } -void show_open_dialog(HWND hwnd) { - HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); - if (FAILED(hr)) { - printf("COM init failed\n"); - exit(1); - } - -#define OPEN_DIALOG_CHECK_ERR(msg) \ - if (FAILED((hr))) { \ - printf("%s:%d: %s", __FILE__, __LINE__, (msg)); \ - exit(1); \ - } - - IFileOpenDialog* pFileOpen; - hr = CoCreateInstance( - &CLSID_FileOpenDialog, - NULL, - CLSCTX_ALL, - &IID_IFileOpenDialog, - (void**) &pFileOpen - ); - OPEN_DIALOG_CHECK_ERR("ERROR: Failed to create FileOpenDialog\n"); - - hr = pFileOpen->lpVtbl->Show(pFileOpen, hwnd); - OPEN_DIALOG_CHECK_ERR("ERROR: Failed to show FileOpenDialog\n"); - - IShellItem* pItem; - hr = pFileOpen->lpVtbl->GetResult(pFileOpen, &pItem); - OPEN_DIALOG_CHECK_ERR("ERROR: Failed to get open file dialog result.\n") - - PWSTR pszFilePath; - hr = pItem->lpVtbl->GetDisplayName(pItem, SIGDN_FILESYSPATH, &pszFilePath); - OPEN_DIALOG_CHECK_ERR("ERROR: Failed to get path\n"); - - MessageBox(NULL, pszFilePath, L"File Path", MB_OK); - - CoTaskMemFree(pszFilePath); - pItem->lpVtbl->Release(pItem); - pFileOpen->lpVtbl->Release(pFileOpen); - - CoUninitialize(); -} - int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) { // Register the window class const wchar_t* CLASS_NAME = L"Sample Window Class"; @@ -156,8 +130,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, ShowWindow(hwnd, nCmdShow); - show_open_dialog(hwnd); - // Message loop MSG msg = { };