The sample code in the following figure shows how the window procedure for the calendar is registered with the application. Also, it shows how the window is created and associated with the notebook page. The example ends by showing the window procedure for the associated window.
/*********************************************************************/ /* Registration of window procedure for calendar. */ /*********************************************************************/ WinRegisterClass(hab, /* Register a page window class */ "Calendar Page", /* Class name */ PageWndProc, /* Window procedure */ CS_SIZEREDRAW, /* Class style */ 0); /* No extra bytes reserved */ /*********************************************************************/ /* Create the window. */ /*********************************************************************/ hwndPage = WinCreateWindow(hwndNotebook, /* Parent */ "Calendar Page", /* Class */ NULL, /* Title text */ 0L, /* Style */ 0, 0, 0, 0, /* Origin and size */ hwndNotebook, /* Owner */ HWND_TOP, /* Z-order */ ID_WIN_CALENDAR_PAGE, /* ID */ NULL, /* Control data */ NULL); /* Presparams */ /*********************************************************************/ /* Associate window with the inserted notebook page. */ /*********************************************************************/ WinSendMsg(hwndBook, BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId), MPFROMHWND(hwndPage)); /*********************************************************************/ /* Window procedure. */ /*********************************************************************/ MRESULT EXPENTRY PageWndProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { HPS hps; switch (msg) { /*******************************************************************/ /* WM_CREATE is sent when the window is created. */ /*******************************************************************/ case WM_CREATE: /*****************************************************************/ /* Place window initialization code here. */ /*****************************************************************/ break; case WM_PAINT: hps = WinBeginPaint(hwnd, NULL, NULL); /*****************************************************************/ /* Draw the calendar for the selected year and month. */ /*****************************************************************/ . . . WinEndPaint(hps); break; default: return (WinDefWindowProc(hwnd, msg, mp1, mp2)); break; } return (FALSE); }