Index: base/applications/fontview/display.c =================================================================== --- base/applications/fontview/display.c (revision 55005) +++ base/applications/fontview/display.c (working copy) @@ -224,7 +224,7 @@ /* Create data structure */ pData = malloc(sizeof(DISPLAYDATA)); ZeroMemory(pData, sizeof(DISPLAYDATA)); - + /* Set the window's GWLP_USERDATA to our data structure */ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pData); Index: base/applications/fontview/fontview.c =================================================================== --- base/applications/fontview/fontview.c (revision 55005) +++ base/applications/fontview/fontview.c (working copy) @@ -92,21 +92,47 @@ WNDCLASSEXW wincl; HINSTANCE hDLL; PGFRI GetFontResourceInfoW; + LPCWSTR fileName; g_hInstance = hThisInstance; - + /* Get unicode command line */ argv = CommandLineToArgvW(GetCommandLineW(), &argc); if (argc < 2) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_BADCMD, argv[1]); - return -1; + OPENFILENAMEW fontOpen; + WCHAR szFileName[MAX_PATH] = L""; + + ZeroMemory(&fontOpen, sizeof(fontOpen)); + + fontOpen.lStructSize = sizeof(fontOpen); + fontOpen.hwndOwner = hMainWnd; + fontOpen.lpstrFilter = L"TrueType Font (*.ttf)\0*.ttf\0" + L"All Files (*.*)\0*.*\0"; + fontOpen.lpstrFile = szFileName; + fontOpen.lpstrTitle = L"Open Font..."; + fontOpen.nMaxFile = MAX_PATH; + fontOpen.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + fontOpen.lpstrDefExt = L"ttf"; + + /* Opens up the Open File dialog box in order to chose a font file. */ + if(GetOpenFileNameW(&fontOpen)) + { + fileName = fontOpen.lpstrFile; + } else { + /* If the user decides to close out of the open dialog */ + return 0; + } } - - /* Try to add the font resource */ - if (!AddFontResourceW(argv[1])) + else { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + /* Try to add the font resource from command line */ + fileName = argv[1]; + } + + if (!AddFontResourceW(fileName)) + { + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } @@ -116,16 +142,16 @@ /* Get the font name */ dwSize = sizeof(g_ExtLogFontW.elfFullName); - if (!GetFontResourceInfoW(argv[1], &dwSize, g_ExtLogFontW.elfFullName, 1)) + if (!GetFontResourceInfoW(fileName, &dwSize, g_ExtLogFontW.elfFullName, 1)) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } dwSize = sizeof(LOGFONTW); - if (!GetFontResourceInfoW(argv[1], &dwSize, &g_ExtLogFontW.elfLogFont, 2)) + if (!GetFontResourceInfoW(fileName, &dwSize, &g_ExtLogFontW.elfLogFont, 2)) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } @@ -290,13 +316,13 @@ { case WM_CREATE: return MainWnd_OnCreate(hwnd); - + break; case WM_PAINT: return MainWnd_OnPaint(hwnd); - + break; case WM_SIZE: return MainWnd_OnSize(hwnd); - + break; case WM_COMMAND: switch(LOWORD(wParam)) { @@ -305,7 +331,33 @@ break; case IDC_PRINT: - MessageBox(hwnd, TEXT("This function is unimplemented"), TEXT("Unimplemented"), MB_OK); + { + PRINTDLG pfont; + + /* Clears the memory before using it */ + ZeroMemory(&pfont, sizeof(pfont)); + + pfont.lStructSize = sizeof(pfont); + pfont.hwndOwner = hwnd; + pfont.hDevMode = NULL; + pfont.hDevNames = NULL; + pfont.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; + pfont.nCopies = 1; + pfont.nFromPage = 0xFFFF; + pfont.nToPage = 0xFFFF; + pfont.nMinPage = 1; + pfont.nMaxPage = 0xFFFF; + + if(PrintDlg(&pfont)) + { + /* TODO: Actually print the document. */ + MessageBox(hwnd, TEXT("This function is unimplamented"), TEXT("Unimplemented"), MB_OK); + + DeleteDC(pfont.hDC); + } else { + break; + } + } break; } break; @@ -316,6 +368,7 @@ default: /* for messages that we don't deal with */ return DefWindowProcW(hwnd, message, wParam, lParam); + break; } return 0; Index: base/applications/fontview/fontview.rbuild =================================================================== --- base/applications/fontview/fontview.rbuild (revision 55005) +++ base/applications/fontview/fontview.rbuild (working copy) @@ -3,6 +3,7 @@ . gdi32 + comdlg32 user32 shell32 fontview.c