Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. case statement in DLGPROC [SOLVED]

case statement in DLGPROC [SOLVED]

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goldenrose9
    wrote on last edited by
    #1

    LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    case WM_INITDIALOG:
    return FALSE;
    case WM_COMMAND:
    return FALSE;
    case WM_CLOSE:
    return FALSE;
    }

    LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    case WM_INITDIALOG:
    return TRUE;
    case WM_COMMAND:
    return TRUE;
    case WM_CLOSE:
    return TRUE;
    }

    LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    case WM_INITDIALOG:
    break;
    case WM_COMMAND:
    break;
    case WM_CLOSE:
    break;
    }

    LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    case WM_INITDIALOG:
    return 0;
    case WM_COMMAND:
    return 0;
    case WM_CLOSE:
    return 0;
    }

    out of these four examples, which one is correct and more accurate, and why.

    Some Day I Will Prove MySelf :: GOLD

    modified on Sunday, March 6, 2011 12:19 PM

    A 1 Reply Last reply
    0
    • G goldenrose9

      LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
      {
      case WM_INITDIALOG:
      return FALSE;
      case WM_COMMAND:
      return FALSE;
      case WM_CLOSE:
      return FALSE;
      }

      LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
      {
      case WM_INITDIALOG:
      return TRUE;
      case WM_COMMAND:
      return TRUE;
      case WM_CLOSE:
      return TRUE;
      }

      LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
      {
      case WM_INITDIALOG:
      break;
      case WM_COMMAND:
      break;
      case WM_CLOSE:
      break;
      }

      LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
      {
      case WM_INITDIALOG:
      return 0;
      case WM_COMMAND:
      return 0;
      case WM_CLOSE:
      return 0;
      }

      out of these four examples, which one is correct and more accurate, and why.

      Some Day I Will Prove MySelf :: GOLD

      modified on Sunday, March 6, 2011 12:19 PM

      A Offline
      A Offline
      Andrew Brock
      wrote on last edited by
      #2

      None of them are correct. The message determines what you must do. At the bottom of the DlgProc function there would be a call to DefWndProc() or the original window procedure. Read the MSDN pages for what the return should be. WM_INITDIALOG[^]: "The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control specified by wParam. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus." Generally you would break and let the default procedure take care of this, but you can return either TRUE or FALSE. WM_COMMAND[^]: "If an application processes this message, it should return zero." implies that you should break the switch and call the original procedure if you don't handle it. WM_CLOSE[^]: "If an application processes this message, it should return zero."

      LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
      switch (Msg) {
      case WM_INITDIALOG:
      break; //You can do whatever here

          case WM\_COMMAND:
              switch (LOWORD(wParam)) {
                  case IDC\_MYBUTTON:
                      return 0; //something happened to MYBUTTON
              }
              break; //We havn't handled it, use default handler
      
          case WM\_CLOSE:
              //cleanup
              return 0;
      }
      return pOriginalProcedure(hwnd, Msg, wParam, lParam); //This is set as GetWindowLong(GWL\_MSGPROC) before changing the procedure.
      

      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups