This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Newbie would like some help...


HiHiHi,

I am new to the discussion group. It seems as though I joined a day too
late.

I recently got 1.8 of the gnuwin c/c++/etc compiler. I want to learn to
write programs for win95/NT. My first program, which was supposed to
create a window and display some text, did not finish compiling. The
linker did not like the calls I made to create the window. I am at a
loss for what is going on. The code is at the end of this message, after
mine failed, I copied one from a book which also failed.

I have several good books about win95/nt programming, but I do not know
how compliant the gnu libraries are with the microsoft classes.

The linker reports that I make undefined calls and then aborts with an
error code 1. What is that??

Are there any sites which have good docs regarding the gnuwin32
libraries??

Thanx for your help.

the code, copied from a book...

// I do not even know if it will compile with the gcc tools.

#include <windows.h>

// prototype declaration
int   WINAPI WinMain(
      HINSTANCE   hInstance,
      HINSTANCE   hPrevInstance,
      LPSTR       pszCmdLine,
      int         nCmdShow
  );

LRESULT CALLBACK WindowProc(
      HWND     hWnd,
      UINT     uMsgId,
      WPARAM   wParam,
      LPARAM   lParam
  );

// Winmain is where all the action is
int   WINAPI WinMain(
      HINSTANCE   hInstance,
      HINSTANCE   hPrevInstance,
      LPSTR       pszCmdLine,
      int         nCmdShow
  )
{
   static char szAppName[] = "test-dummy";
   HWND  hWnd;
   MSG   msg;
   WNDCLASS wndClass;

   wndClass.style            = 0;
   wndClass.lpfnWndProc      = WindowProc;
   wndClass.cbClsExtra       = 0;
   wndClass.cbWndExtra       = 0;
   wndClass.hInstance        = hInstance;
   wndClass.hIcon            = LoadIcon(NULL,IDI_APPLICATION);
   wndClass.hCursor          = LoadCursor(NULL, IDC_ARROW);
   wndClass.hbrBackground    = GetStockObject(WHITE_BRUSH);
   wndClass.lpszMenuName     = NULL;
   wndClass.lpszClassName    = szAppName;
   if (RegisterClass(&wndClass) == 0) { return 0; }

   hWnd = CreateWindow(
      szAppName,
      szAppName,
      WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT,
      CW_USEDEFAULT,
      CW_USEDEFAULT,
      CW_USEDEFAULT,
      NULL,
      NULL,
      hInstance,
      NULL);

   if (hWnd == 0) { return 0; }
   ShowWindow(hWnd, nCmdShow);
   UpdateWindow (hWnd);

   while (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   return msg.wParam;
}

LRESULT CALLBACK WindowProc(
      HWND     hWnd,
      UINT     uMsgId,
      WPARAM   wParam,
      LPARAM   lParam
  )

{
   static char *pszHello = "Hello ";

   switch (uMsgId)

   {
   case WM_PAINT:
      HDC hDC;
      PAINTSTRUCT paintStruct;
      hDC = BeginPaint(hWnd, &paintStruct);

      TextOut(hDC, 0, 0, pszHello, lstrlen(pszHello));

      EndPaint(hWnd, &paintStruct);
      return 0;

   case WM_DESTROY:
      PostQuitMessage(0);
      return 0;

   default:
      return DefWindowProc(hWnd, uMsgId, wParam, lParam);
   }

}

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]