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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Interesting Dialog problem

Interesting Dialog problem

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
5 Posts 3 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.
  • U Offline
    U Offline
    User 2382
    wrote on last edited by
    #1

    I have a program which will generate Images of different objects on the screen.If you choose a menu item (RSC,Folder for example) you are promted to enter a few parametrs related to the object.(Length,Width,Depth and flute) Since all of the objects need the same info I want to use one single dialog.However Each object manipulates the info in different ways..With a single dialog and hence a single "Render" button how can I determine Which object the dialog was called for in my OnRender Function...Is what Im trying to do possible???It has to be this is C++ :o). Any suggestions or hints would be greatly appreciated... Thanks for the time J.Prisco

    B L 2 Replies Last reply
    0
    • U User 2382

      I have a program which will generate Images of different objects on the screen.If you choose a menu item (RSC,Folder for example) you are promted to enter a few parametrs related to the object.(Length,Width,Depth and flute) Since all of the objects need the same info I want to use one single dialog.However Each object manipulates the info in different ways..With a single dialog and hence a single "Render" button how can I determine Which object the dialog was called for in my OnRender Function...Is what Im trying to do possible???It has to be this is C++ :o). Any suggestions or hints would be greatly appreciated... Thanks for the time J.Prisco

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      Make a base class for all the objects. Put a member variable in it to represent the current ype. Make an enumeration for all your types. Derive all your 'object' classes from this base type. Use the value of the 'type' data item to let your OnRender code know what was selected. The diaog can also use that 'type' variable to know what controls to display to user, or else how to limit the data ranges where user might be entering numbers. You could do the saem thing with C structures, always make the first element of the object structures this type. Then if you have a pointer to some of this memory, you can cast the pointer to this 'type' variable and access the data structure's object type.

      U 1 Reply Last reply
      0
      • B Blake Miller

        Make a base class for all the objects. Put a member variable in it to represent the current ype. Make an enumeration for all your types. Derive all your 'object' classes from this base type. Use the value of the 'type' data item to let your OnRender code know what was selected. The diaog can also use that 'type' variable to know what controls to display to user, or else how to limit the data ranges where user might be entering numbers. You could do the saem thing with C structures, always make the first element of the object structures this type. Then if you have a pointer to some of this memory, you can cast the pointer to this 'type' variable and access the data structure's object type.

        U Offline
        U Offline
        User 2382
        wrote on last edited by
        #3

        Although this sounds good Im still not to clear on how this is done..Thanks for the hint Ill investigate it further..

        1 Reply Last reply
        0
        • U User 2382

          I have a program which will generate Images of different objects on the screen.If you choose a menu item (RSC,Folder for example) you are promted to enter a few parametrs related to the object.(Length,Width,Depth and flute) Since all of the objects need the same info I want to use one single dialog.However Each object manipulates the info in different ways..With a single dialog and hence a single "Render" button how can I determine Which object the dialog was called for in my OnRender Function...Is what Im trying to do possible???It has to be this is C++ :o). Any suggestions or hints would be greatly appreciated... Thanks for the time J.Prisco

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

          I assume that you have one menu item for each object that you want to display. I also assume that each kind of display object is being abstracted as a class and all these classes have a common base class. In the menu handler for each of these menu items, you would probably instantiate an object of the dialog class and call its DoModal(). You can pass a 'C++ object' of the appropriate object to be displayed to the dialog's constructor. In the dialog's OnRender() method, you can call the Render() method of these objects, provided the Render() method of the base class is virtual.

          U 1 Reply Last reply
          0
          • L Lost User

            I assume that you have one menu item for each object that you want to display. I also assume that each kind of display object is being abstracted as a class and all these classes have a common base class. In the menu handler for each of these menu items, you would probably instantiate an object of the dialog class and call its DoModal(). You can pass a 'C++ object' of the appropriate object to be displayed to the dialog's constructor. In the dialog's OnRender() method, you can call the Render() method of these objects, provided the Render() method of the base class is virtual.

            U Offline
            U Offline
            User 2382
            wrote on last edited by
            #5

            Well I made my initial post when I first discovered the problem .At my fist observation it really seemed to be quite a problem..After a little though I figured a way to do what I needed but in fact What I was planning wasnt even necisarry at all.Once I began coding the app I found the problem was no problem at all...For each menu item handler I use DoModal and upon its return I assign the corresponding objects variables...Although a little inneficient it works just fine.. Thanks for the help I really appreciate all the help I can get and Ill probably need more help with this app which is probably a little too ambitious for me at this point.

            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