D
Dr. Laurence Leff
How does not compile a Windows API and a Windows MFC program from the
command line with Visual.net. (I can do the former, at least, with Visual
Studio by creating a "Win32 Project.")
However, I tried the same thing on the command line.
(In the days of Visual C++ 4.0 through Visual C++ 6.0, I had some
make files and stuff that did this.
So, I typed CL hellowin.C
There were no compile time erors; only errors from the linker
such as error LNK2019: unreasolved external symbol
___imp__DispatchMessageA4
I got similar errors from other basic Windows API functions such
as Show Window, DrawText and BeginPaint.
So I believe that I need to know what libraries are needed and how to
specify these. The "CL" command does not accept the "/LIBRARY" option
from Visual C++ 4.0
Thanks for any help that can be provided.
Dr. Laurence Leff Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX: 309-298-2302
Secretary: eContracts Technical Committee OASIS Legal XML Member Section
Here is the helowin.c file:
#include "c:\progra~1\micros~1.net\Vc7\PlatformSDK\Include\Windows.h"
#include "stdio.h"
int count;
HINSTANCE ghInstance;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASSEX wndclass;
static char szAppName[] = "HelloWin";
ghInstance = hInstance;
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 (hInstance,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);
RegisterClassEx (&wndclass);
hWnd = CreateWindow (
szAppName,
"The Hello Program",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hWnd, iCmdShow);
UpdateWindow (hWnd);
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
char str[100];
switch (iMessage)
{
case WM_CREATE:
return 0;
count = 0;
case WM_PAINT:
hDC = BeginPaint (hWnd, &ps);
GetClientRect (hWnd,&rect);
sprintf(str,"%d",count);
DrawText (hDC, str, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint (hWnd, &ps);
return 0;
case WM_LBUTTONDOWN:
count++;
InvalidateRect(hWnd,NULL,TRUE);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hWnd, iMessage, wParam, lParam);
}
return (0L);
}
command line with Visual.net. (I can do the former, at least, with Visual
Studio by creating a "Win32 Project.")
However, I tried the same thing on the command line.
(In the days of Visual C++ 4.0 through Visual C++ 6.0, I had some
make files and stuff that did this.
So, I typed CL hellowin.C
There were no compile time erors; only errors from the linker
such as error LNK2019: unreasolved external symbol
___imp__DispatchMessageA4
I got similar errors from other basic Windows API functions such
as Show Window, DrawText and BeginPaint.
So I believe that I need to know what libraries are needed and how to
specify these. The "CL" command does not accept the "/LIBRARY" option
from Visual C++ 4.0
Thanks for any help that can be provided.
Dr. Laurence Leff Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX: 309-298-2302
Secretary: eContracts Technical Committee OASIS Legal XML Member Section
Here is the helowin.c file:
#include "c:\progra~1\micros~1.net\Vc7\PlatformSDK\Include\Windows.h"
#include "stdio.h"
int count;
HINSTANCE ghInstance;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASSEX wndclass;
static char szAppName[] = "HelloWin";
ghInstance = hInstance;
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 (hInstance,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);
RegisterClassEx (&wndclass);
hWnd = CreateWindow (
szAppName,
"The Hello Program",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hWnd, iCmdShow);
UpdateWindow (hWnd);
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
char str[100];
switch (iMessage)
{
case WM_CREATE:
return 0;
count = 0;
case WM_PAINT:
hDC = BeginPaint (hWnd, &ps);
GetClientRect (hWnd,&rect);
sprintf(str,"%d",count);
DrawText (hDC, str, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint (hWnd, &ps);
return 0;
case WM_LBUTTONDOWN:
count++;
InvalidateRect(hWnd,NULL,TRUE);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hWnd, iMessage, wParam, lParam);
}
return (0L);
}