Just a bit of touching up
Changelog
+ Fix obsolete comments about windowsx, commdlg
+ Increase filename length to MAX_PATH
+ Set the windows extent before playing the metafile
+ Don't hardcode logpixels to 96
diff -u -r programs/view/view.c programs/view/view.c
--- programs/view/view.c 2003-06-19 06:53:14.000000000 +0100
+++ programs/view/view.c 2003-12-09 21:00:06.000000000 +0000
@@ -17,16 +17,8 @@
*/
#include <windows.h>
-#include "resource.h"
-
-/*
#include <windowsx.h>
- Wine doesn't have windowsx.h, so we use this
-*/
-#define GET_WM_COMMAND_ID(wp,lp) LOWORD(wp)
-
-/* Wine seems to need this */
-#include <commdlg.h>
+#include "resource.h"
#include "globals.h"
#include <stdio.h>
@@ -34,8 +26,6 @@
BOOL FileIsPlaceable( LPCSTR szFileName );
HMETAFILE GetPlaceableMetaFile( HWND hwnd, LPCSTR szFileName );
-#define FN_LENGTH 80
-
HMETAFILE hmf;
int deltax = 0, deltay = 0;
int width = 0, height = 0;
@@ -69,11 +59,12 @@
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
SetMapMode(ps.hdc, MM_ANISOTROPIC);
+ /* Set the window extent to a sane value in case the metafile doesn't */
+ SetWindowExtEx(ps.hdc, width, height, NULL);
SetViewportExtEx(ps.hdc, width, height, NULL);
SetViewportOrgEx(ps.hdc, deltax, deltay, NULL);
if(hmf) PlayMetaFile(ps.hdc, hmf);
EndPaint(hwnd, &ps);
-
}
break;
@@ -86,8 +77,8 @@
case IDM_OPEN:
{
- char filename[FN_LENGTH];
- if (FileOpen(hwnd, filename, FN_LENGTH)) {
+ char filename[MAX_PATH];
+ if (FileOpen(hwnd, filename, sizeof(filename))) {
isAldus = FileIsPlaceable(filename);
if (isAldus) {
hmf = GetPlaceableMetaFile(hwnd, filename);
@@ -178,6 +169,7 @@
HFILE fh;
HMETAFILE hmf;
WORD checksum, *p;
+ HDC hdc;
int i;
if( (fh = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR ) return 0;
@@ -218,8 +210,10 @@
height = APMHeader.bbox.Bottom - APMHeader.bbox.Top;
/* printf("Ok! width %d height %d inch %d\n", width, height, APMHeader.inch); */
- width = width*96/APMHeader.inch;
- height = height*96/APMHeader.inch;
+ hdc = GetDC(hwnd);
+ width = width * GetDeviceCaps(hdc, LOGPIXELSX)/APMHeader.inch;
+ height = height * GetDeviceCaps(hdc,LOGPIXELSY)/APMHeader.inch;
+ ReleaseDC(hwnd, hdc);
deltax = 0;
deltay = 0 ;