Command Line compiling API and MFC programs

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);
}
 
J

jacob navia

Dr. Laurence Leff wrote:
[snip]
So I believe that I need to know what libraries are
[snip]

Yes. You have to tell the compiler the libraries you need.

If you read your compiler documentation, you will find the
name.

It is better when starting, to use the IDE provided by Microsoft
because it gives access to the documentation. For each function
the doc tells you which library is needed.

Besides, it shields the novice programmer from many complexities.

Load your program in the editor, and type F1 at the name
you want to investigate. Then, if the installation went OK,
the help system will display you the doc of that function.

I would ask further questions in the many support groups of the
compiler in the net.

jacob
 
F

Flash Gordon

Dr. Laurence Leff said:
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.")

<snip>

This is all very Windows MSVC specific and thus off topic in
comp.lang.c, it belongs somewhere in one of the MS specific news groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,034
Messages
2,570,356
Members
47,002
Latest member
RobertoLip

Latest Threads

Top