Solved

Looking for DefWnd.C and DefDlg.c

Posted on 1998-04-09
28
739 Views
Last Modified: 2013-12-03
According to an (older) book I have, the windows SDK should have a dirrectory (\SAMPLES\DEFPROCS\) that contains source code for the default window procedures.  My SDK does not.  (My SDK is old, but the book is far older).  If you can e-mail me the files from there (or tell me where they might have been moved to/renamed to), I'll give you an A.  Two of the files are DefWnd.c and DefDlg.c.  However, there might be more, I don't know.

(If you e-mail the files be sure to answer the question so other's don't sent them.)
0
Comment
Question by:nietod
  • 9
  • 8
  • 6
  • +3
28 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1412637
No such files in the SDK.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412638
The default procedures are parts of the OS.  They change with the introduction of new messages.  no source is available.
0
 
LVL 22

Author Comment

by:nietod
ID: 1412639
Not according Andrew Schulman's "Undocumented Windows".  I'm sure they have changed somewhat over the years as new messages/or API's are added.  But they are (or at least were) available.  If an up-to-date version is not available, I'd accept an older version.  
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412640
Drop me a note if you get one.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1412641
The DefWinodwProc() and DefDlgProc() sources used to be available in the SDK, but that stopped in Win32. If you can find an old copy of VC++ 1.5, or an old Win16 SDK, you can find the files there. Their _general_ functionality is the same in Win32.

The files aren't available for Win32.

.B ekiM

0
 
LVL 22

Author Comment

by:nietod
ID: 1412642
I don't have a 16 bit SDK. That's why I'm looking for the files.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1412643
I don't know what the licensing agreement says about their redistribution without the SDK.

.B ekiM
0
 
LVL 22

Author Comment

by:nietod
ID: 1412644
Well I have the SDK.  Several versions.  Unfortunately they no longer include it...

Supposedly one of the reasons that they published them was because of the law suits that claimed that knowledge of the procedures gave Microsoft unfar advantage over other developers.  I interpret this to mean that it is now public domain.  (An interpretation that is based on my present need more than legal precedance.)
0
 
LVL 23

Expert Comment

by:chensu
ID: 1412645
Do you have access to the MSDN CDs? The MSDN Archive CDs published some time ago should contain Windows 3.1 SDK. And I remember Visual C++ 1.0 contains these files. There is a book with Visual C++ 1.0 included. I have forgotten the name of the book. It is something like "Learn Visual C++".
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412646
This is what the MS KB says ... (NOTE: This article says that it applied to the Win32 API !!! and says to find the info in the Windows 3.0 SDK)

Microsoft Knowledge Base
Default/Private Dialog Classes, Procedures, DefDlgProc
Last reviewed: December 2, 1996
Article ID: Q68566  
The information in this article applies to:
Microsoft Windows Software Development Kit (SDK) versions 3.0 and 3.1
Microsoft Win32 Application Programming Interface (API) included with:


    - Microsoft Windows NT versions 3.5 and 3.51
    - Microsoft Windows 95 version 4.0



SUMMARY
The information below explains the differences between default and private dialog classes, their associated dialog procedures, and using the DefDlgProc() function.

This information is organized as a comparison between private and default dialog classes, covering class registration, dialog templates, dialog creation, and message processing.

Note that the source to the DefDlgProc() function is provided with the Windows Software Development Kit (SDK) version 3.0. The code is supplied on the Sample Source 2 disk in the DEFDLG.C file. By default, DEFDLG.C is placed into the \SAMPLES\DEFPROCS directory if the SDK installation program copies the sample source code.

There are many functions and macros used in DefDlgProc() that are internal to Windows and cannot be used by applications. No additional information is available on these functions and macros.



MORE INFORMATION
All dialog classes are window classes, just as all dialog boxes are windows. All dialog classes must declare at least DLGWINDOWEXTRA in the cbWndExtra field of the WNDCLASS structure before the dialog class is registered. The Windows Dialog Manager uses this area to store special information for dialog boxes.

The default dialog class is registered by Windows at startup. The window procedure for this class is known as DefDlgProc(), which is located in Windows's USER module. DefDlgProc() calls the application- provided dialog function, which returns TRUE if it processes a message completely or FALSE if DefDlgProc should process the message further.

If an application registers a private dialog class, it provides a window procedure for the dialog box. The window procedure is the same as that for any other application window and returns a LONG value. Messages that are not processed by this window function are passed to DefDlgProc().




Dialog Class Registration
Windows registers the default dialog class, which is represented by the value 0x8002. Windows uses this class when an application creates a dialog box using the DialogBox() or CreateDialog() functions, but specifies no class in the dialog resource template.

To use a private dialog class, the application must specify the fields of a WNDCLASS structure and call RegisterClass(). This is the same procedure that Windows uses to register the default dialog class.

In either case, the value in the cbWndExtra field of the WNDCLASS structure must contain a value of at least DLGWINDOWEXTRA. These bytes are used as storage space for dialog-box specific information, such as which control has the focus and which button is the default.

When a dialog class is registered, the lpfnWndProc field of the WNDCLASS structure must contain a function pointer. For the default dialog class, this field points to DefDlgProc(). For a private class, the field points to application-supplied procedure that returns a LONG (as does a normal window procedure) and passes all unprocessed messages to DefDlgProc().



Dialog Templates
Resource scripts are almost identical whether used with a default or a private dialog class. Dialog boxes using a private class must use the CLASS statement in the dialog template. The name given in the CLASS statement must match the name of class that exists (is registered) when the dialog box is created.



Dialog Creation and the lpfnDlgFunc Parameter
Applications create dialog boxes using the function DialogBox(), CreateDialog(), or one of the variant functions such as DialogBoxIndirect(). The complete list of functions is found on page 1- 43 of the "Microsoft Windows Software Development Kit Reference Volume 1."

All dialog box creation calls take a parameter called lpfnDlgFunc, which can either be NULL or the procedure instance address of the dialog box function returned from MakeProcInstance(). When the application specifies a private dialog class and sets lpfnDlgFunc to a procedure instance address, the application processes each message for the dialog box twice. The message processing proceeds as follows:


Windows calls the dialog class procedure to process the message. To process a message in the default manner, this procedure calls DefDlgProc().

DefDlgProc() calls the procedure specified in the dialog box creation call.

The procedure specified in lpfnDlgFunc must be designed very carefully. When it processes a message, it returns TRUE or FALSE and does not call DefDlgProc(). These requirements are the same as for any other dialog procedure.
Using a dialog procedure in conjunction with a private dialog class can be very useful. Processing for the private dialog class can be generic and apply to a number of dialog boxes. Code in the dialog procedure is specific to the particular instance of the private dialog class.



Dialog Message Processing
In dialog boxes with the default class, the application provides a callback dialog function that returns TRUE or FALSE, depending on whether or not the message was processed. As mentioned above, DefDlgProc(), which is the window procedure for the default dialog class, calls the application's dialog function and uses the return value to determine whether it should continue processing the message.

In dialog boxes of a private class, Windows sends all messages to the application-provided window procedure. The procedure either processes the message like any other window procedure or passes it to DefDlgProc(). DefDlgProc() processes dialog-specific functions and passes any other messages to DefWindowProc() for processing.

Some messages are sent only to the application-supplied procedure specified in the call to CreateDialog() or DialogBox(). Two examples of functions that Windows does not send to the private dialog class function are WM_INITDIALOG and WM_SETFONT.

 


--------------------------------------------------------------------------------

Additional reference words: 3.00 3.10 3.50 3.51 4.00 95
KBCategory: kbui
KBSubcategory: UsrDlgs


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 2, 1996
)1997 Microsoft Corporation. All rights reserved. Legal Notices.
 

0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 50 total points
ID: 1412647
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412648
Those are WINE source files, not Windows.
0
 
LVL 22

Author Comment

by:nietod
ID: 1412649
Alexo, what is WINE?  What are the files?  They almost certainly aren't aren't THE default window procedure as they only handle a few messages.

Ronslow does your SDK have the files?  I installed all the sample code (or so I thought) and I do not seem to have the files.  I have no idea what version of the SDK I have, but it comes form MSDN from about 18 months ago.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412650
You need the Win3.1 SDK as opposed to the Win32 SDK - I am not at work now and so don't have my SDK disks.  Will check tomorrow (my time)

Of course, there is no guarantee that the Win3.1 DefDlgProc etc is going to be imlemented in the same way as the Win32 DefDlgProc, nor that this implemenation will be the same for all Win32 versions.

SO the WINE versions are probably as good as any ... ???

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 22

Author Comment

by:nietod
ID: 1412651
Thanks.  
I don't need 100% accuracy.  I just want to have an idea how some things are handled.  This isn't for a particular need it is just to get an idea so the procedures aren't quite so black a black box.  
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412652
Nietod, WINE is a windows emulator that runs under Unix.
RONSLOW, please let me take a peek at the files too.
0
 
LVL 22

Author Comment

by:nietod
ID: 1412653
alexo, post your e-mail address (if you don't want it public, e-mail it to me) and I'll send you the files (assuming I get them).  (But then, you owe me half the points :- )  )
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412654
Thanx!
My email address is on my info.  Emailing to you might prove challenging without an email address.
About the points, I thought that the files would be considered PAQ status but, what the hell, how much do you want?
0
 
LVL 22

Author Comment

by:nietod
ID: 1412655
Man I was sure I had put my e-mail address on the original question!  I guess I forgot.  its

nietod@theshop.net
0
 
LVL 22

Author Comment

by:nietod
ID: 1412656
RONSLOW,
   Haven't heard from from you for a while (here that is, I heard from you elswhere! :-)  ).  Were you not able to find the files?  
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412657
Sorry, not yet .. had a busy day at work yesterday .. I'm just in this morning (I'm in australia, so its 10:08am here) .. I'll try to track down my old SDK disks (hope they're not on 5 1/4" floppies, I don't havea drive for them anymore).

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412658
I've emailed them to you .. but here are the sources as comments

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412659
/*--------------------------------------------------------------------------*/
/*                                                                          */
/*  DefDlgProc() -                                                          */
/*                                                                          */
/*--------------------------------------------------------------------------*/

LRESULT API IDefDlgProc(HWND hwnd, WORD message, WPARAM wParam, LPARAM lParam)
{
    HWND hwndT1;
    HWND hwndT2;
    BOOL result;

    ((PDLG)hwnd)->resultWP = 0L;
    result = FALSE;
    //
    // Call the dialog proc if it exists
    //
    if (((PDLG)hwnd)->lpfnDlg == NULL ||
            !(result = CallDlgProc(hwnd, message, wParam, lParam)))
        {

        // Make sure window still exists.
        if (!IsWindow(hwnd))
        {
            DebugErr(DBF_ERROR, "Dialog window destroyed in dialog callback");
            goto ReturnIt;
        }

        switch (message)
        {
        case WM_ERASEBKGND:
            FillWindow(hwnd, hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_DLG);
            return((LRESULT)(LONG)TRUE);

        case WM_SHOWWINDOW:
            // If hiding the window, save the focus. If showing the window
            // by means of a SW_* command and the fEnd bit is set, do not
            // pass to DWP so it won't get shown.
            //
            if (!wParam)
                SaveDlgFocus(hwnd);
            else if (LOWORD(lParam) && pdlg->fEnd)
                break;
            return(DefWindowProc(hwnd, message, wParam, lParam));

        case WM_SYSCOMMAND:
            //
            // If we're minimizing and a dialog control has the focus,
            // save the hwnd for that control
            //
            if ((int) wParam == SC_MINIMIZE)
                SaveDlgFocus(hwnd);
            return(DefWindowProc(hwnd, message, wParam, lParam));

        case WM_ACTIVATE:
            if (fDialog = (wParam != 0))
                RestoreDlgFocus(hwnd);
            else
                SaveDlgFocus(hwnd);
            break;

        case WM_SETFOCUS:
            if (!pdlg->fEnd && !RestoreDlgFocus(hwnd))
                DlgSetFocus(GetFirstTab(hwnd));
            break;

        case WM_CLOSE:
            // Make sure cancel button is not disabled before sending the
            // IDCANCEL.  Note that we need to do this as a message instead
            // of directly calling the dlg proc so that any dialog box
            // filters get this.
            //
            hwndT1 = GetDlgItem(hwnd, IDCANCEL);
            if (hwndT1 && TestWF(hwndT1, WFDISABLED))
                MessageBeep(0);
            else
                PostMessage(hwnd, WM_COMMAND, (WPARAM)IDCANCEL, MAKELPARAM(hwndT1, BN_CLICKED));
            break;

        case WM_NCDESTROY:
            fDialog = FALSE;      /* clear this flag */

            // Make sure we are going to terminate the mode loop, in case
            // DestroyWindow was called instead of EndDialog.  We'll RIP
            // in DialogBox2.
            //
            ((PDLG)hwnd)->fEnd = TRUE;

            if (!(hwnd->style & DS_LOCALEDIT))
            {
                if (((PDLG)hwnd)->hData)
                {

                    GlobalUnlock(((PDLG)hwnd)->hData);

                    ReleaseEditDS(((PDLG)hwnd)->hData);
                    ((PDLG)hwnd)->hData = NULL;
                }
            }

            // Delete the user defined font if any
            if (((PDLG)hwnd)->hUserFont)
            {
                DeleteObject((HANDLE)((PDLG)hwnd)->hUserFont);
                ((PDLG)hwnd)->hUserFont = NULL;
            }

            // Always let DefWindowProc do its thing to ensure that
            // everything associated with the window is freed up.
            //
            DefWindowProc(hwnd, message, wParam, lParam);
            break;

        case DM_SETDEFID:
            if (!(((PDLG)hwnd)->fEnd))
            {
                // Make sure that the new default button has the highlight.
                // We need to ignore this if we are ending the dialog box
                // because hwnd->result is no longer a default window id but
                // rather the return value of the dialog box.
                //
                // Catch the case of setting the defid to null or setting
                // the defid to something else when it was initially null.
                //
                CheckDefPushButton(hwnd,
                     (((PDLG)hwnd)->result ? GetDlgItem(hwnd, ((PDLG)hwnd)->result) : NULL),
                     (wParam               ? GetDlgItem(hwnd, (int) wParam        ) : NULL) );
                ((PDLG)hwnd)->result = (int)wParam;
            }
            return((LRESULT)(DWORD)TRUE);

        case DM_GETDEFID:
            if (!((PDLG)hwnd)->fEnd && ((PDLG)hwnd)->result)
                return(MAKELRESULT(((PDLG)hwnd)->result, DC_HASDEFID));
            else
                return(0L);

        case WM_NEXTDLGCTL:
            // This message is so TAB-like operations can be properly handled
            // (simple SetFocus won't do the default button stuff)
            //
            hwndT2 = hwndFocus;
            if (LOWORD(lParam))
            {
                if (hwndT2 == NULL)
                    hwndT2 = hwnd;

                // wParam contains the hwnd of the ctl to set focus to
                hwndT1 = (HWND)wParam;
            }
            else
            {
                if (hwndT2 == NULL)
                {
                    // Set focus to the first tab item.
                    hwndT1 = GetFirstTab(hwnd);
                    hwndT2 = hwnd;
                }
                else
                {
                    // If window with focus not a dlg ctl, ignore message.
                    if (!IsChild(hwnd, hwndT2))
                        return((LRESULT)(LONG)TRUE);

                    // wParam = TRUE for previous, FALSE for next
                    hwndT1 = GetNextDlgTabItem(hwnd, hwndT2, (BOOL)wParam);
                }
            }
            DlgSetFocus(hwndT1);
            CheckDefPushButton(hwnd, hwndT2, hwndT1);
            return((LRESULT)(LONG)TRUE);

        case WM_ENTERMENULOOP:
        case WM_LBUTTONDOWN:
        case WM_NCLBUTTONDOWN:
            //
            // PLEASE NOTE: The following code is a VERY UGLY compatibility
            // hack.  NEVER write code that looks at the window proc address
            // in order to determine the window type.  The following code will
            // not work with subclassed combo or edit controls.
            //
            if (hwndT1 = hwndFocus)
            {
                if (hwndT1->pcls->lpfnWndProc == ComboBoxCtlWndProc)
                {
                    // If user clicks anywhere in dialog box and a combo box (or
                    // the editcontrol of a combo box) has the focus, then hide
                    // it's listbox.
                    //
                    SendMessage(hwndT1, CB_SHOWDROPDOWN, FALSE, 0L);
                }
                else
                {
                    if (hwndT1->pcls->lpfnWndProc == EditWndProc &&
                        hwndT1->hwndParent->pcls->lpfnWndProc==ComboBoxCtlWndProc)
                    {
                        SendMessage(hwndT1->hwndParent,CB_SHOWDROPDOWN, FALSE, 0L);
                    }
                }
            }
            return(DefWindowProc(hwnd, message, wParam, lParam));

        case WM_GETFONT:
            return (LRESULT)(DWORD)(WORD)((PDLG)hwnd)->hUserFont;

        // We don't want to pass the following messages to DefWindowProc:
        // instead, return the value returned by the dialog proc (FALSE)
        //
        case WM_VKEYTOITEM:
        case WM_COMPAREITEM:
        case WM_CHARTOITEM:
        case WM_INITDIALOG:
            break;

        default:
            return(DefWindowProc(hwnd, message, wParam, lParam));
        }
    }

ReturnIt:
    // These messages are special cased in an unusual way: the return value
    // of the dialog function is not BOOL fProcessed, but instead it's the
    // return value of these messages.
    //
    if (message == WM_CTLCOLOR ||
        message == WM_COMPAREITEM ||
        message == WM_VKEYTOITEM ||
        message == WM_CHARTOITEM ||
        message == WM_QUERYDRAGICON ||
        message == WM_INITDIALOG)
    {
        return((LRESULT)(DWORD)result);
    }

    return(((PDLG)hwnd)->resultWP);
}

BOOL SaveDlgFocus(HWND hwnd)
{
    if (hwndFocus && IsChild(hwnd, hwndFocus) && !((PDLG)hwnd)->hwndFocusSave)
    {
        ((PDLG)hwnd)->hwndFocusSave = hwndFocus;
        RemoveDefaultButton(hwnd, hwndFocus);
        return(TRUE);
    }
    return(FALSE);
}

BOOL RestoreDlgFocus(HWND hwnd)
{
    BOOL fRestored = FALSE;

    if (((PDLG)hwnd)->hwndFocusSave && !TestWF(hwnd, WFMINIMIZED))
    {
        if (IsWindow(((PDLG)hwnd)->hwndFocusSave))
        {
            CheckDefPushButton(hwnd, hwndFocus, ((PDLG)hwnd)->hwndFocusSave);
            SetFocus(((PDLG)hwnd)->hwndFocusSave);
            fRestored = TRUE;
        }

        ((PDLG)hwnd)->hwndFocusSave = NULL;
    }
    return(fRestored);
}

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412660
/*--------------------------------------------------------------------------*/
/*                                                                          */
/*  DefWindowProc() -                                                       */
/*                                                                          */
/*--------------------------------------------------------------------------*/

LRESULT API IDefWindowProc(HWND hwnd, WORD message, WPARAM wParam, LPARAM lParam)
{
    int     i;
    HBRUSH  hbr;
    HWND    hwndT;

    switch (message)
    {
    case WM_NCCREATE:
      // If WS_HSCROLL or WS_VSCROLL, initialize storage for scroll positions.
      //
      // NOTE: Scroll bar storage and text storage will be freed automatically
      // by Windows during CreateWindow()
      //
      if (TestWF(hwnd, (WFHSCROLL | WFVSCROLL)))
      {
          // Initialize extra storage for

          if (InitPwSB(hwnd) == NULL)
            return((LONG)FALSE);
      }
      // Store window text if present.
      //
      return((LRESULT)(LONG)DefSetText(hwnd, ((LPCREATESTRUCT)lParam)->lpszName));

    case WM_NCCALCSIZE:
      //
      // wParam = fCalcValidRects
      // lParam = LPRECT rgrc[3]:
      //        lprc[0] = rcWindowNew = New window rectangle
      //    if fCalcValidRects:
      //        lprc[1] = rcWindowOld = Old window rectangle
      //        lprc[2] = rcClientOld = Old client rectangle
      //
      // On return:
      //        rgrc[0] = rcClientNew = New client rect
      //    if fCalcValidRects:
      //        rgrc[1] = rcValidDst  = Destination valid rectangle
      //        rgrc[2] = rcValidSrc  = Source valid rectangle
      //
      CalcClientRect(hwnd, (LPRECT)lParam);
      break;

    case WM_NCHITTEST:
      //
      // Determine what area the passed coordinate is in.
      //
      return((LRESULT)(DWORD)FindNCHit(hwnd, (LONG)lParam));

    case WM_NCPAINT:
      //
      // Do non-client area drawing.
      //
      DWP_DoNCPaint(hwnd, (HRGN)wParam);
      break;

    case WM_NCACTIVATE:
      //
      // Do non-client drawing in response to
      // activation or deactivation.
      //
      DWP_DoNCActivate(hwnd, (BOOL)wParam);
      return (LRESULT)(DWORD)TRUE;

    case WM_CANCELMODE:
      //
      // Terminate any modes the system might
      // be in, such as scrollbar tracking, menu mode,
      // button capture, etc.
      //
      DWP_DoCancelMode(hwnd);
      break;

    case WM_SETTEXT:
      // Set the new text and redraw the caption or icon title window.
      //
      DefSetText(hwnd, (LPCSTR)lParam);
      DWP_RedrawTitle(hwnd);
      break;

    case WM_GETTEXT:
      //
      // If the buffer size is > 0, copy as much of the window text as
      // will fit (making sure to zero terminate the result).
      //
      if (wParam)
      {
          if (hwnd->hName)
            return (LRESULT)(LONG)TextCopy(hwnd->hName, (LPSTR)lParam, (int)wParam);

          // No string: make sure we return an empty string.
          //
          ((LPSTR)lParam)[0] = 0;
      }
      return (0L);

    case WM_GETTEXTLENGTH:
      //
      // Just return the length of the window text (excluding 0 terminator)
      //
      if (hwnd->hName)
          return((LRESULT)(LONG)lstrlen(TextPointer(hwnd->hName)));
      return(0L);

    case WM_PAINT:
    case WM_PAINTICON:
      DWP_Paint(message, hwnd);
      break;

    case WM_ERASEBKGND:
    case WM_ICONERASEBKGND:
      return (LRESULT)(LONG)DWP_EraseBkgnd(hwnd, message, (HDC)wParam);

    case WM_SYNCPAINT:
      //
      // This message is sent when SetWindowPos() is trying
      // to get the screen looking nice after window rearrangement,
      // and one of the windows involved is of another task.
      // This message avoids lots of inter-app message traffic
      // by switching to the other task and continuing the
      // recursion there.
      //
      // wParam         = flags
      // LOWORD(lParam) = hrgnClip
      // HIWORD(lParam) = hwndSkip  (not used; always NULL)
      //
      // hwndSkip is now always NULL.
      //
      // NOTE: THIS MESSAGE IS FOR INTERNAL USE ONLY! ITS BEHAVIOR
      // IS DIFFERENT IN 3.1 THAN IN 3.0!!
      //
      DoSyncPaint(hwnd, NULL, ((WORD)wParam | DSP_WM_SYNCPAINT));
      break;

    case WM_SYSCOMMAND:
      SysCommand(hwnd, (int)wParam, lParam);
      break;

    case WM_ACTIVATE:
      //
      // By default, windows set the focus to themselves when activated.
      //
      if ((BOOL)wParam)
          SetFocus(hwnd);
      break;

    case WM_SETREDRAW:
      //
      // Set or clear the WS_VISIBLE bit, without invalidating the window.
      // (Also performs some internal housekeeping to ensure that window
      // DC clip regions are computed correctly).
      //
      DWP_SetRedraw(hwnd, (BOOL)wParam);
      break;

    case WM_WINDOWPOSCHANGING:
      //
      // If the window's size is changing, and the window has
      // a size border (WS_THICKFRAME) or is a main window (WS_OVERLAPPED),
      // then adjust the new width and height by sending a WM_MINMAXINFO message.
      //
      #define ppos ((WINDOWPOS FAR *)lParam)
      if (!(ppos->flags & SWP_NOSIZE))
          AdjustSize(hwnd, &ppos->cx, &ppos->cy);
      #undef ppos
      break;

    case WM_WINDOWPOSCHANGED:
      //
      // If (!(lpswp->flags & SWP_NOCLIENTMOVE)
      //    send WM_MOVE message
      //
      // If (!(lpswp->flags & SWP_NOCLIENTSIZE)
      //    send WM_SIZE message with wParam set based on
      //    current WS_MINIMIZED/WS_MAXIMIZED style.
      //
      // If DefWindowProc() is not called, WM_MOVE and WM_SIZE messages
      // will not be sent to the window.
      //
      HandleWindowPosChanged(hwnd, (WINDOWPOS FAR *)lParam);
      break;

    case WM_CTLCOLOR:
      //
      // Set up the supplied DC with the foreground and background
      // colors we want to use in the control, and return a brush
      // to use for filling.
      //
      switch (HIWORD(lParam))
      {
      case CTLCOLOR_SCROLLBAR:
          //
          // Background = white
          // Foreground = black
          // brush = COLOR_SCROLLBAR.
          //
          SetBkColor((HDC)wParam, RGB(255, 255, 255));
          SetTextColor((HDC)wParam, RGB(0, 0, 0));
          hbr = sysClrObjects.hbrScrollbar;

          // The scroll bar color may be dithered, so unrealize it.
          //
          UnrealizeObject(hbr);
          break;

      default:
          //
          // Background = COLOR_WINDOW
          // Foreground = COLOR_WINDOWTEXT
          // Brush = COLOR_WINDOW
          //
          SetBkColor((HDC)wParam, sysColors.clrWindow);
          SetTextColor((HDC)wParam, sysColors.clrWindowText);
          hbr = sysClrObjects.hbrWindow;
      }
      return((LRESULT)(DWORD)(WORD)hbr);

    case WM_SETCURSOR:
      //
      // wParam  == hwndHit == hwnd that cursor is over
      // lParamL == codeHT  == Hit test area code (result of WM_NCHITTEST)
      // lParamH == msg     == Mouse message number (may be 0)
      //
      // Strategy: First forward WM_SETCURSOR message to parent.  If it
      // returns TRUE (i.e., it set the cursor), just return.  Otherwise,
      // set the cursor based on codeHT and msg.
      //
      return (LRESULT)(LONG)DWP_SetCursor(hwnd, (HWND)wParam,
            LOWORD(lParam), HIWORD(lParam));

    case WM_MOUSEACTIVATE:
      //
      // First give the parent a chance to process the message.
      //
      hwndT = GetChildParent(hwnd);
      if (hwndT)
      {
          i = (int)(DWORD)SendMessage(hwndT, WM_MOUSEACTIVATE,
            wParam, lParam);

          if (i != 0)
            return (LRESULT)(LONG)i;
      }

      // If the user clicked in the title bar, don't activate now:
      // the activation will take place later when the move or size
      // occurs.
      //
      if (LOWORD(lParam) == HTCAPTION)
          return((LRESULT)(LONG)MA_NOACTIVATE);

      return((LRESULT)(LONG)MA_ACTIVATE);

    case WM_SHOWWINDOW:
      //
      // If we are being called because our owner window is being shown,
      // hidden, minimized, or un-minimized, then we must hide or show
      // show ourself as appropriate.
      //
      // This behavior occurs for popup windows or owned windows only.
      // It's not designed for use with child windows.
      //
      if (LOWORD(lParam) != 0 && (TestwndPopup(hwnd) || hwnd->hwndOwner))
      {
          // The WFHIDDENPOPUP flag is an internal flag that indicates
          // that the window was hidden because its owner was hidden.
          // This way we only show windows that were hidden by this code,
          // not intentionally by the application.
          //
          // Go ahead and hide or show this window, but only if:
          //
          // a) we need to be hidden, or
          // b) we need to be shown, and we were hidden by
          //    an earlier WM_SHOWWINDOW message
          //
          if ((!wParam && TestWF(hwnd, WFVISIBLE)) ||
             (wParam && !TestWF(hwnd, WFVISIBLE) && TestWF(hwnd, WFHIDDENPOPUP)))
          {
            // Remember that we were hidden by WM_SHOWWINDOW processing
            //
            ClrWF(hwnd, WFHIDDENPOPUP);
            if (!wParam)
                SetWF(hwnd, WFHIDDENPOPUP);

            ShowWindow(hwnd, (wParam ? SW_SHOWNOACTIVATE : SW_HIDE));
          }
      }
      break;

    case WM_NCLBUTTONDOWN:
    case WM_NCLBUTTONUP:
    case WM_NCLBUTTONDBLCLK:
    case WM_NCMOUSEMOVE:
      //
      // Deal with mouse messages in the non-client area.
      //
      DWP_NCMouse(hwnd, message, wParam, lParam);
      break;

    case WM_KEYDOWN:
      // Windows 2.0 backward compatibility:
      // Alias F10 to the menu key
      // (only for apps that don't handle WM_KEY* messages themselves)
      //
      if ((WORD)wParam == VK_F10)
          fF10Status = TRUE;
      break;

    case WM_SYSKEYDOWN:
      // Is the ALT key down?
      if (HIWORD(lParam) & SYS_ALTERNATE)
      {
          // Toggle only if this is not an autorepeat key
          //
          if ((HIWORD(lParam) & SYS_PREVKEYSTATE) == 0)
          {
            if (((WORD)wParam == VK_MENU) && (!fMenuStatus))
                fMenuStatus = TRUE;
            else
                fMenuStatus = FALSE;
          }

          fF10Status = FALSE;

          DWP_ProcessVirtKey((WORD)wParam);
      }
      else
      {
          if ((WORD)wParam == VK_F10)
          {
            fF10Status = TRUE;
          }
          else
          {
            if ((WORD)wParam == VK_ESCAPE)
            {
                if (GetKeyState(VK_SHIFT) < 0)
                {
                  SendMessage(hwnd, WM_SYSCOMMAND,
                        (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)MENUSYSMENU);
                }
            }
          }
      }
      break;

    case WM_KEYUP:
    case WM_SYSKEYUP:
      // Press and release F10 or ALT. Send this only to top-level
      // windows, otherwise MDI gets confused.  The fix in which
      // DefMDIChildProc() passed up the message was insufficient in the
      // case a child window of the MDI child had the focus.
      //
      if ( ((WORD)wParam == VK_MENU && (fMenuStatus == TRUE)) ||
            ((WORD)wParam == VK_F10 && fF10Status) )
      {
          SendMessage(GetTopLevelWindow(hwnd), WM_SYSCOMMAND,
                (WPARAM)SC_KEYMENU, 0L);
      }
      fF10Status = fMenuStatus = FALSE;
      break;

    case WM_SYSCHAR:
      // If syskey is down and we have a char... */
      fMenuStatus = FALSE;

      if ((WORD)wParam == VK_RETURN && TestWF(hwnd, WFMINIMIZED))
      {
          // If the window is iconic and user hits RETURN, we want to
          // restore this window.
          //
          PostMessage(hwnd, WM_SYSCOMMAND, (WPARAM)SC_RESTORE, 0L);
          break;
      }

      if ((HIWORD(lParam) & SYS_ALTERNATE) && wParam)
      {
          if ((WORD)wParam == VK_TAB || (WORD)wParam == VK_ESCAPE)
            break;

          // Send ALT-SPACE only to top-level windows.
          if (((WORD)wParam == MENUSYSMENU) && (TestwndChild(hwnd)))
            SendMessage(hwnd->hwndParent, message, wParam, lParam);
          else
            SendMessage(hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)(WORD)wParam);
      }
      else
      {
          // Ctrl-Esc produces a WM_SYSCHAR, but should not beep
          if ((WORD)wParam != VK_ESCAPE)
            MessageBeep(0);
      }
      break;

    case WM_CLOSE:
      //
      // Default WM_CLOSE handling is to destroy the window.
      //
      DestroyWindow(hwnd);
      break;

    case WM_QUERYOPEN:
    case WM_QUERYENDSESSION:
      return((LRESULT)(LONG)TRUE);

    case WM_ISACTIVEICON:
      return ((LRESULT)(DWORD)(BOOL)(TestWF(hwnd, WFFRAMEON) != 0));

    case WM_CHARTOITEM:
    case WM_VKEYTOITEM:
      //
      // Return -1 to cause default processing
      //
      return((LRESULT)-1L);

    case WM_DRAWITEM:
      #define lpdis   ((LPDRAWITEMSTRUCT)lParam)
      if (lpdis->CtlType == ODT_LISTBOX)
          LBDefaultListboxDrawItem(lpdis);
      #undef  lpdis
      break;

    case WM_GETHOTKEY:
      return((LRESULT)(LONG)DWP_GetHotKey(hwnd));
      break;

    case WM_SETHOTKEY:
      return((LRESULT)(LONG)SetHotKey(hwnd, (WORD)wParam));
      break;

    case WM_QUERYDRAGICON:
      return((LRESULT)(DWORD)(WORD)DWP_QueryDragIcon(hwnd));
      break;

    case WM_QUERYDROPOBJECT:
      //
      // If the application is WS_EX_ACCEPTFILES, return TRUE.
      //
      if (TestWF(hwnd, WEFACCEPTFILES))
          return (LRESULT)(DWORD)TRUE;

      return (LRESULT)(DWORD)FALSE;

    case WM_DROPOBJECT:
      return (LRESULT)(DWORD)DO_DROPFILE;

    }   // end switch
    return(0L);
}

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1412661
These came from VC1.52 samples (I got them from the MSDN Library Archive CD)

0
 
LVL 22

Author Comment

by:nietod
ID: 1412662
Thanks!
0
 
LVL 1

Expert Comment

by:mite51
ID: 6513110
RONSLOW ,

Do you have new links of the defwndproc source links?

Thanks
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 6518956
As I explained (correctly, though my answer was still strangely rejected) the only publication of these functions was in the WIN16 SDK. You'll not find newer versions, period.

.B ekiM
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now