Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

stooge_dev

PlaySound and Dev-c++

This topic is 5613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m using Dev-c++ v4.0 and when compiling this example it gives the errors: 62 c:\mydocu~1\untitl~1.c (Each undeclared identifier is reported only once 62 c:\mydocu~1\untitl~1.c for each function it appears in.) 62 c:\mydocu~1\untitl~1.c `SND_ASYNC'' undeclared (first use in this function) 62 c:\mydocu~1\untitl~1.c (Each undeclared mydocu~1\untitl~1.c:62: (Each undeclared I have tried putting -lwinmm, but it still didn''t work. When I comment out PlaySound then I get the linker error: C:\WINDOWS\TEMP\ccRMrgPa.o(.text+0x90):untitl~1.c: undefined reference to `GetStockObject@4'' I have been able to get Borland to compile it successfully.
  
#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);
}
[/source  

Share this post


Link to post
Share on other sites
Advertisement
Throw a -lgdi32 in the linkage options. I found the answer to this with a grep of the MinGW libraries for GetStockObject, by the way.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!