From: Robby on
A MILLION SORRY'S .........

"ALT 179"  is not the same as "ALT124" |

I have replaced the bar symbol from  to |, this solved alot of the errors!

However here are the last three errors:

CPZ_P44 error LNK2019: unresolved external symbol __imp__PlaySoundA(a)12
referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned
int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

CPZ_P44 fatal error LNK1120: 1 unresolved externals

c:\DATASOURCE_EXTRA\Programming\VC++CodeTesting_WINDOWS\CPZ_P44\HELLOWIN.cpp(52):
warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of
data

I believe that I must make an addition to the object libraries. I need to
add the WINMM.LIB so that this program gets to function correctly, Mr.
Petzold shows how to do this, however its not shown for VS7.

I think that this is what the errors refer to. Does anyone know how to do
this?
All answers appreciated, so I can get through this innitial learning knot!

--
Best regards
Robert


"Robby" wrote:

> Hi,
>
> Trying the first windows program in Charles Petzold's book and getting many
> errors. Boy, this windows programming, not an easy world !
>
> Here is the code in its simplist nature:
>
> #include <windows.h>
>
> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
>
> int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
> PSTR szCmdLine, int iCmdShow)
> {
> static TCHAR szAppName[] = TEXT ("HelloWin");
> HWND hwnd;
> MSG msg;
> WNDCLASS 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;
>
> if (!RegisterClass (&wndclass))
> {
> MessageBox(NULL,TEXT ("This program requires Windows NT!"),
> szAppName, MB_ICONERROR);
> return 0;
> }
>
> hwnd = CreateWindow (szAppName,
> TEXT ("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 message, WPARAM wParam, LPARAM
> lParam)
> {
> HDC hdc;
> PAINTSTRUCT ps;
> RECT rect;
>
> switch(message)
> {
> case WM_CREATE:
> PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME  SND_ASYNC);
> return 0;
>
> case WM_PAINT:
> hdc = BeginPaint(hwnd, &ps);
> GetClientRect (hwnd,&rect);
> DrawText (hdc, TEXT ("Hello, Windows 98!"), -1,&rect,
> DT_SINGLELINE  DT_CENTER  DT_VCENTER);
> EndPaint (hwnd, &ps);
> return 0;
> case WM_DESTROY:
> PostQuitMessage (0);
> return 0;
> }
> return DefWindowProc(hwnd, message, wParam, lParam);
> }
>
> I don't know why I am getting all sorts of errors, can someone please take a
> look at this!
>
> Thanks
>
> --
> Best regards
> Robert
From: Jochen Kalmbach [MVP] on
Hi Robby!

> CPZ_P44 error LNK2019: unresolved external symbol __imp__PlaySoundA(a)12
> referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned
> int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
>
> CPZ_P44 fatal error LNK1120: 1 unresolved externals
>
> c:\DATASOURCE_EXTRA\Programming\VC++CodeTesting_WINDOWS\CPZ_P44\HELLOWIN.cpp(52):
> warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of
> data
>
> I believe that I must make an addition to the object libraries. I need to
> add the WINMM.LIB so that this program gets to function correctly, Mr.
> Petzold shows how to do this, however its not shown for VS7.

The easiest way is to add the following to your cpp or h-file:
#pragma comment(lib, "winmm.lib")


The problem with the warning is the check for x64-porting issues...
You can either disable this check (project settings, disable /Wp64) or
correct theconversion from WPARAM to int....

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
From: Robby on
Hey thats great! Thanks Jochen Kalmbach!

It compiles without an error! However I am a novice C++ Programmer with
virtually no Windows programming experience. Why doesn't Charles Petzold show
this in his example?

However my freind, unfortunately, I really don't understand by what you mean
by:

The problem with the warning is the check for x64-porting issues...
You can either disable this check (project settings, disable /Wp64) or
correct theconversion from WPARAM to int....


SORRY!
Also when I do project, I don't see settings?

I remember reading something about #pragma! I would have to look it up.
Since my examples don't include the pragma declaration, I was wondering if we
can add the library by going through VS7 menus without having to add the
following declaration in my code:

#pragma comment(lib, "winmm.lib")

--
Best regards
Robert

--
Best regards
Robert


"Jochen Kalmbach [MVP]" wrote:

> Hi Robby!
>
> > CPZ_P44 error LNK2019: unresolved external symbol __imp__PlaySoundA(a)12
> > referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned
> > int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
> >
> > CPZ_P44 fatal error LNK1120: 1 unresolved externals
> >
> > c:\DATASOURCE_EXTRA\Programming\VC++CodeTesting_WINDOWS\CPZ_P44\HELLOWIN.cpp(52):
> > warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of
> > data
> >
> > I believe that I must make an addition to the object libraries. I need to
> > add the WINMM.LIB so that this program gets to function correctly, Mr.
> > Petzold shows how to do this, however its not shown for VS7.
>
> The easiest way is to add the following to your cpp or h-file:
> #pragma comment(lib, "winmm.lib")
>
>
> The problem with the warning is the check for x64-porting issues...
> You can either disable this check (project settings, disable /Wp64) or
> correct theconversion from WPARAM to int....
>
> --
> Greetings
> Jochen
>
> My blog about Win32 and .NET
> http://blog.kalmbachnet.de/
>
From: Drew on
Right-click your project and select Properties.
Go to the Linker node of the tree control and select Input.
Additional libraries to link go in the Additional Dependencies edit box.

HTH,
Drew

"Robby" <Robby(a)discussions.microsoft.com> wrote in message
news:B7ED460A-F389-4BB1-8BFF-B23E5E185E7B(a)microsoft.com...
> Hey thats great! Thanks Jochen Kalmbach!
>
> It compiles without an error! However I am a novice C++ Programmer with
> virtually no Windows programming experience. Why doesn't Charles Petzold
> show
> this in his example?
>
> However my freind, unfortunately, I really don't understand by what you
> mean
> by:
>
> The problem with the warning is the check for x64-porting issues...
> You can either disable this check (project settings, disable /Wp64) or
> correct theconversion from WPARAM to int....
>
>
> SORRY!
> Also when I do project, I don't see settings?
>
> I remember reading something about #pragma! I would have to look it up.
> Since my examples don't include the pragma declaration, I was wondering if
> we
> can add the library by going through VS7 menus without having to add the
> following declaration in my code:
>
> #pragma comment(lib, "winmm.lib")
>
> --
> Best regards
> Robert
>
> --
> Best regards
> Robert
>
>
> "Jochen Kalmbach [MVP]" wrote:
>
>> Hi Robby!
>>
>> > CPZ_P44 error LNK2019: unresolved external symbol __imp__PlaySoundA(a)12
>> > referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned
>> > int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
>> >
>> > CPZ_P44 fatal error LNK1120: 1 unresolved externals
>> >
>> > c:\DATASOURCE_EXTRA\Programming\VC++CodeTesting_WINDOWS\CPZ_P44\HELLOWIN.cpp(52):
>> > warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible
>> > loss of
>> > data
>> >
>> > I believe that I must make an addition to the object libraries. I need
>> > to
>> > add the WINMM.LIB so that this program gets to function correctly, Mr.
>> > Petzold shows how to do this, however its not shown for VS7.
>>
>> The easiest way is to add the following to your cpp or h-file:
>> #pragma comment(lib, "winmm.lib")
>>
>>
>> The problem with the warning is the check for x64-porting issues...
>> You can either disable this check (project settings, disable /Wp64) or
>> correct theconversion from WPARAM to int....
>>
>> --
>> Greetings
>> Jochen
>>
>> My blog about Win32 and .NET
>> http://blog.kalmbachnet.de/
>>