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. Replace dialog in FormView

Replace dialog in FormView

Scheduled Pinned Locked Moved C / C++ / MFC
5 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.
  • J Offline
    J Offline
    jaknupp
    wrote on last edited by
    #1

    I have a SDI app using FormView that's not resizable but will have a large and small size. I would like to create small and large dialogs and then have the view display the correct dialog depending on user choice. I don't want to use multiple views because I don't want to recode handlers, etc. My plan is to i.e. have button ID_OK1 in small dialog and button ID_OK2 in large dialog both to to OnOK() so my code only has to be written once. Any ideas would be appreciated. Thanks, John

    L 1 Reply Last reply
    0
    • J jaknupp

      I have a SDI app using FormView that's not resizable but will have a large and small size. I would like to create small and large dialogs and then have the view display the correct dialog depending on user choice. I don't want to use multiple views because I don't want to recode handlers, etc. My plan is to i.e. have button ID_OK1 in small dialog and button ID_OK2 in large dialog both to to OnOK() so my code only has to be written once. Any ideas would be appreciated. Thanks, John

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If it is just about the size of the dialog, isn't resizing the child windows based on the user selection a simpler choice? I have seen articles on CP that show how to do that.

      ...byte till it megahertz... my donation to web rubbish

      J 1 Reply Last reply
      0
      • L Lost User

        If it is just about the size of the dialog, isn't resizing the child windows based on the user selection a simpler choice? I have seen articles on CP that show how to do that.

        ...byte till it megahertz... my donation to web rubbish

        J Offline
        J Offline
        jaknupp
        wrote on last edited by
        #3

        I was thinking about doing resizing but I have another app that allows resizing and it was a bit tedious to change control sizes, rearrange based on the new window size and update font sizes. I was hoping to layout 2 dialogs in the resource editor and then just switch between the two. Is there an easier way to resize controls instead of calc window size, scale controls then move to new relative positions?

        L 1 Reply Last reply
        0
        • J jaknupp

          I was thinking about doing resizing but I have another app that allows resizing and it was a bit tedious to change control sizes, rearrange based on the new window size and update font sizes. I was hoping to layout 2 dialogs in the resource editor and then just switch between the two. Is there an easier way to resize controls instead of calc window size, scale controls then move to new relative positions?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          TBH, I never had to do resizing seriously, so I can't say anything useful about that. :) About your original issue, I just felt that resizing would be a lot less code, and bloat, than mapping events from both the forms to some base class, friend class etc and processing them.

          ...byte till it megahertz... my donation to web rubbish

          J 1 Reply Last reply
          0
          • L Lost User

            TBH, I never had to do resizing seriously, so I can't say anything useful about that. :) About your original issue, I just felt that resizing would be a lot less code, and bloat, than mapping events from both the forms to some base class, friend class etc and processing them.

            ...byte till it megahertz... my donation to web rubbish

            J Offline
            J Offline
            jaknupp
            wrote on last edited by
            #5

            I actually did find something useful. Adding this line to the CFormView constructor lets you use any dialog for the form view: CMFCView::CMFCView() : CFormView(CMFCsdi2View::IDD) { m_lpszTemplateName = MAKEINTRESOURCE(View_IDD_TO_USE); } So at run time I can set View_IDD_TO_USE to the resource for IDD_DIALOG1 or IDD_DIALOG2. The form view then gets created with whichever of the resources I choose. I create the event handlers in the view, i.e. OnOK(). The controls in each dialog need to be the same including names so that when the view creates the handlers they can be mapped, i.e. there must be a control named ID_OK on each dialog so the view can correctly map ID_OK to OnOK(). That means no duplicated code, only two dialogs which doesn't add to much overhead. This works great for what I'm doing. Thanks to Scott McPhillips for the direction.

            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