PDA

Click to See Complete Forum and Search --> : can someone compile this in VC++?


softwareguy74
Jan 3rd, 2001, 01:29 PM
Hi,

Here is the source file I'm trying to compile from my last message I posted. For some reason, it keeps giving me an end of file error in VC++6.0. What's wrong with the file?


// win.cpp: Implementation of the structure win;
// After compiling, link with application-file

#include "win.h"

win::win(HINSTANCE hInstance0, int iCmdShow0,
PSTR szAppName0, PSTR szWindowCaption0)
{ iCmdShow = iCmdShow0;

//store the arguments for CreateWindow in the structure win:
szAppName = szAppName0;
szWindowCaption = szWindowCaption0;
dwStyle = WS_OVERLAPPEDWINDOW;
x = y = 0;
nWidth = GetSystemMetrics(SM_CXSCREEN);
nHeight = GetSystemMetrics(SM_CYSCREEN);
hWndParent = NULL;
hMenu = NULL;
hInstance = hInstance0;
lpParam = NULL;

//Fill wndclass just for now:
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
hDlg=0;
szAccel = NULL;
}

int win::result()
{ RegisterClassEx(&wndclass);
hWnd = CreateWindow(szAppName, szWindowCaption, dwStyle,
x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
MSG msg;
HACCEL hAccel = (szAccel ? LoadAccelerators(hInstance, szAccel) : 0);
while (GetMessage(&msg, NULL, 0, 0))
{ if (hDlg == 0 || !IsDialogMessage(hDlg, &msg))
{ if (hAccel == 0 || !TranslateAccelerator(hWnd, hAccel, &msg))
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return msg.wParam;
}



Any help would be greatly appreciated..

DAn

Krushstone
Jan 3rd, 2001, 02:04 PM
If you want us to try to compile it, you should also post the file win.h...

softwareguy74
Jan 3rd, 2001, 02:22 PM
Woops! Sorry 'bout that...


//win.h
#define STRICT
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam);

struct win
{ win (HINSTANCE hInstance0, int iCmdShow0,
PSTR szAppName0, PSTR szWindowCaption0);
int result ();

int iCmdShow; //For passing through ShowWindow
WNDCLASSEX wndclass;
HWND hWnd, //Handle for mainwindow
hDlg; //Handle for modeless dialogbox
PSTR szAccel; //Name accelerator table

//Arguments for CreateWindow:
PSTR szAppName; //registered classname
PSTR szWindowCaption; //address of windowname
DWORD dwStyle; //windowstyle
int x; //horizontal position of window
int y; //vertical position of window
int nWidth; //width
int nHeight; //height
HWND hWndParent; //parent-window
HMENU hMenu; //menuhandle
HINSTANCE hInstance; //application-instance
LPVOID lpParam; //window-creation-data
};