www.digitalmars.com         C & C++   DMDScript  

D - winsamp.d

reply "Kennedy" <kennedy oldnews.org> writes:
Has anyone else had trouble compiling winsamp.d in the samples directory?

Here is the error I get when I issue the "dmd winsamp.d" command:

winsamp.d(8): identifier 'WPARAM' is not defined

Thanks for any suggestions,
Kennedy

PS.
The file winsamp.d I'm using is unmodified from the samples supplied with
the compiler. But just in case, here it is:


import windows;
import c.stdio;

const int IDC_BTNCLICK = 101;
const int IDC_BTNDONTCLICK = 102;

extern(Windows)
int WindowProc(HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam)
{
 switch (uMsg)
 {
 case WM_COMMAND:
 {
  switch (LOWORD(wParam))
  {
  case IDC_BTNCLICK:
   if (HIWORD(wParam) == BN_CLICKED)
    MessageBoxA(hWnd, "Hello, world!", "Greeting",
     MB_OK | MB_ICONINFORMATION);
   break;
  case IDC_BTNDONTCLICK:
   if (HIWORD(wParam) == BN_CLICKED)
   {
    MessageBoxA(hWnd, "You've been warned...", "Prepare to die!",
     MB_OK | MB_ICONEXCLAMATION);
    *(cast(int*) null) = 666;
   }
   break;
  }
 } break;
 case WM_PAINT:
 {
  static char[] text = "D rules!";
  PAINTSTRUCT ps;
  HDC dc = BeginPaint(hWnd, &ps);
  RECT r;
  GetClientRect(hWnd, &r);
  HFONT font = CreateFontA(80, 0, 0, 0, FW_EXTRABOLD, FALSE, FALSE,
   FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
   DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
  HGDIOBJ old = SelectObject(dc, cast(HGDIOBJ) font);
  SetTextAlign(dc, TA_CENTER | TA_BASELINE);
  TextOutA(dc, r.right / 2, r.bottom / 2, text, text.length);
  SelectObject(dc, old);
  EndPaint(hWnd, &ps);
 } break;
 case WM_DESTROY:
  PostQuitMessage(0);
 }
 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}

int main(char[][] args)
{
 HINSTANCE hInst = GetModuleHandleA(null);
 WNDCLASS wc;
 wc.lpszClassName = "DWndClass";
 wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc = &WindowProc;
 wc.hInstance = hInst;
 wc.hIcon = LoadIconA(cast(HINST) null, IDI_APPLICATION);
 wc.hCursor = LoadCursorA(cast(HINST) null, IDC_CROSS);
 wc.hbrBackground = cast(HBRUSH) (COLOR_WINDOW + 1);
 wc.lpszMenuName = null;
 wc.cbClsExtra = wc.cbWndExtra = 0;
 assert(RegisterClassA(&wc));

 HWND hWnd, btnClick, btnDontClick;
 hWnd = CreateWindowA("DWndClass", "Just a window", WS_THICKFRAME |
  WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
  CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP,
  cast(HMENU) null, hInst, null);
 assert(hWnd);

 btnClick = CreateWindowA("BUTTON", "Click Me", WS_CHILD | WS_VISIBLE,
  0, 0, 100, 25, hWnd, cast(HMENU) IDC_BTNCLICK, hInst, null);

 btnDontClick = CreateWindowA("BUTTON", "DON'T CLICK!", WS_CHILD |
WS_VISIBLE,
  110, 0, 100, 25, hWnd, cast(HMENU) IDC_BTNDONTCLICK, hInst, null);

 MSG msg;
 while (GetMessageA(&msg, cast(HWND) null, 0, 0))
 {
  TranslateMessage(&msg);
  DispatchMessageA(&msg);
 }

 return 0;
}
Jul 11 2002
parent reply Patrick Down <pat codemoon.com> writes:
"Kennedy" <kennedy oldnews.org> wrote in news:agkkbl$2m25$1
 digitaldaemon.com:

 Has anyone else had trouble compiling winsamp.d in the samples directory?
 
It doesn't build. D doesn't have a complete Windows definition file yet. I have gotten it to build by bringing in Pavel's windows.d file which you can find in the links section of the D site.
Jul 11 2002
parent reply "Bryce Dooley" <bdooley123 yahoo.com> writes:
I downloaded Pavel's windows.d & the WPARAM error is gone but now I get a
slew of "Symbol Undefined" errors on _CreateFontA 56, _SelectObject 8, ...

Any ideas?

Thanks.
Bryce

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns92489A3CF2639patcodemooncom 63.105.9.61...
 "Kennedy" <kennedy oldnews.org> wrote in news:agkkbl$2m25$1
  digitaldaemon.com:

 Has anyone else had trouble compiling winsamp.d in the samples
directory?

 It doesn't build.  D doesn't have a complete Windows definition file yet.
 I have gotten it to build by bringing in Pavel's windows.d file which you
 can find in the links section of the D site.
Jul 11 2002
parent Patrick Down <pat codemoon.com> writes:
"Bryce Dooley" <bdooley123 yahoo.com> wrote in
news:aglk2o$krv$1 digitaldaemon.com: 

 I downloaded Pavel's windows.d & the WPARAM error is gone but now I
 get a slew of "Symbol Undefined" errors on _CreateFontA 56,
 _SelectObject 8, ... 
 
 Any ideas?
 
 Thanks.
 Bryce
You need to compile Pavel's windows.d with your program.
Jul 12 2002