This function retrieves a pointer value from the memory of the reserved window word.

MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MYINSTANCEDATA *InstanceData;  /* application defined structure */

    switch (msg) {
    case WM_CREATE:
       DosAllocMem(&InstanceData, sizeof(MYINSTANCEDATA), fALLOC);
       /* WindowProcedure initializes instance data for this window */
       .
       .
       /* set pointer to instance in window words */
       WinSetWindowPtr(hwnd, 0, InstanceData);
       break;

    case WM_USER + 1: /* application defined message */
       /* Window procedure retrieves instance data to   */
       /* process this message                          */

       InstanceData = WinQueryWindowPtr(hwnd, 0);
       .
       .

       break;
       .
       .


[Back] [Next]