Loading ...
Sorry, an error occurred while loading the content.

Re: How to rename window class in dialog?

Expand Messages
  • v_s_ha
    Hi Dmitry, ... This is a dialog based application for changing name class. I hope it will be helpful fo you. Regards Valery //RenamedDlg.cpp
    Message 1 of 6 , Jul 1, 2006
    • 0 Attachment
      Hi Dmitry,

      > I am afraid you havn't got what I wrote. I mean the function
      > CDialogImpl::Create. This function calls API function
      > CreateDialogParam and my dialog was created. Then I start Spy++ and
      > see that name of the window class of my dialog is #32770. As I
      > understand it is default name for all dialogs. Can I change this name?
      >

      This is a dialog based application for changing name class. I hope it
      will be helpful fo you.

      Regards

      Valery

      //RenamedDlg.cpp
      ////////////////////////////////Start /////////////////////

      #include <windows.h>
      #include <windowsx.h>
      #include <tchar.h>


      #define IDD_RENAMED 101
      #define IDI_RENAMED 102

      ///////////////////////////////////////////////////////////

      #define HANDLE_DLGMSG(hwnd, msg, fcn) \
      case (msg): return (SetDlgMsgResult(hwnd, uMsg, \
      HANDLE_##msg((hwnd), (wParam), (lParam), (fcn))))

      ///////////////////////////////////////////////////////////////////

      inline void SetDlgIcons(HWND hwnd, int iconId)
      {
      SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM)
      LoadIcon((HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE),
      MAKEINTRESOURCE(iconId)));
      SendMessage(hwnd, WM_SETICON, FALSE, (LPARAM)
      LoadIcon((HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE),
      MAKEINTRESOURCE(iconId)));
      }

      //////////////////////////////////////////////////////////////////

      BOOL DlgOnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
      {
      SetDlgIcons(hwnd, IDI_RENAMED );

      return(TRUE);
      }

      ///////////////////////////////////////////////////////////////////


      void DlgOnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
      {
      switch (id)
      {
      case IDCANCEL:
      EndDialog(hwnd, id);
      }
      }

      ///////////////////////////////////////////////////////////////////


      INT_PTR WINAPI DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
      {
      switch (uMsg)
      {
      HANDLE_DLGMSG(hwnd, WM_INITDIALOG, DlgOnInitDialog);
      HANDLE_DLGMSG(hwnd, WM_COMMAND, DlgOnCommand);
      }
      return(FALSE);
      }

      ////////////////////////////////////////////////////////////////////

      BOOL DlgRegister(HINSTANCE hInst)
      {
      WNDCLASS wc;

      wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
      wc.lpfnWndProc = DefDlgProc;
      wc.cbClsExtra = 0;
      wc.cbWndExtra = DLGWINDOWEXTRA;
      wc.hInstance = hInst;
      wc.hIcon = NULL;
      wc.hCursor = LoadCursor(NULL, IDC_ARROW);
      wc.hbrBackground = NULL;
      wc.lpszMenuName = NULL;
      wc.lpszClassName = TEXT("MyDlgClass");

      if (!RegisterClass(&wc))
      return FALSE;

      return TRUE;
      }
      /////////////////////////////////////////////////////////////////////

      int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
      {
      DlgRegister( hinstExe );

      DialogBox(hinstExe, MAKEINTRESOURCE(IDD_RENAMED), NULL,
      (DLGPROC)DlgProc);

      return(0);
      }

      /////////////////////////// End /////////////////////////////////


      //RenamedDlg.rc

      //extract

      //////////////////////////////////////////////////////////////////
      //
      // Dialog
      //

      IDD_RENAMED DIALOGEX 0, 0, 256, 81
      STYLE DS_SETFONT | DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
      CLASS "MyDlgClass"
      CAPTION "RenamedDlgClass"
      FONT 8, "MS Sans Serif", 0, 0, 0x0
      BEGIN
      END
      ///////////////////////////////////////////////////////////////////
    • dmitry_golub
      ... [skipped] Valery, Thank you very much. This code is very useful for me. Thanks again,
      Message 2 of 6 , Jul 3, 2006
      • 0 Attachment
        --- In wtl@yahoogroups.com, "v_s_ha" <v_s_ha@...> wrote:
        >
        > Hi Dmitry,
        >
        > This is a dialog based application for changing name class. I hope it
        > will be helpful fo you.
        >
        > Regards
        >
        > Valery
        >
        [skipped]

        Valery,

        Thank you very much. This code is very useful for me.

        Thanks again,
      Your message has been successfully submitted and would be delivered to recipients shortly.