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. how to use control

how to use control

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
9 Posts 4 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.
  • L Offline
    L Offline
    ladder
    wrote on last edited by
    #1

    I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?

    B E B 3 Replies Last reply
    0
    • L ladder

      I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?

      B Offline
      B Offline
      BirJas
      wrote on last edited by
      #2

      hello im not sure if im clear on what your asking but have your tried use if(!m_yourcontrol.Create()) { } under the doc or view mode depending on wich you need. Jason Bird

      L 1 Reply Last reply
      0
      • L ladder

        I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?

        E Offline
        E Offline
        ElCachubrey
        wrote on last edited by
        #3

        Hi Parameters for Create function of you control depend on by kind of you control. But generally first parameters its LPCTSTR lpszWindowName is name window of you control for instance for CommandButton its same Caption DWORD dwStyle this style of you control for more see CreateControl() function in MSDN const RECT& rect is rect in what you control appeared CWnd* pParentWnd is parent window (window what will belong you created control) UINT nID is handle of you control simple defined its as any number in "resource.h" file of you object [this number must be vary from already used for resource handling] Sorry for bad eanglish.

        L 1 Reply Last reply
        0
        • L ladder

          I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?

          B Offline
          B Offline
          Bob Stanneveld
          wrote on last edited by
          #4

          A control is placed on a dialog or form or... inside your doc/view classes you add some classes that contain information ABOUT the control. :confused: confused yet? :confused: for example: on your dialog you have a edit box, in the dialog class you'll need a CEdit member to obtain information about the edit control and it's contents. You don't need to call the create method! If you wan't to dynamically create the controls see the controlyouwant.Create() for details hope this helps...

          A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

          L 1 Reply Last reply
          0
          • B BirJas

            hello im not sure if im clear on what your asking but have your tried use if(!m_yourcontrol.Create()) { } under the doc or view mode depending on wich you need. Jason Bird

            L Offline
            L Offline
            ladder
            wrote on last edited by
            #5

            I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );

            1 Reply Last reply
            0
            • E ElCachubrey

              Hi Parameters for Create function of you control depend on by kind of you control. But generally first parameters its LPCTSTR lpszWindowName is name window of you control for instance for CommandButton its same Caption DWORD dwStyle this style of you control for more see CreateControl() function in MSDN const RECT& rect is rect in what you control appeared CWnd* pParentWnd is parent window (window what will belong you created control) UINT nID is handle of you control simple defined its as any number in "resource.h" file of you object [this number must be vary from already used for resource handling] Sorry for bad eanglish.

              L Offline
              L Offline
              ladder
              wrote on last edited by
              #6

              I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );

              E 1 Reply Last reply
              0
              • B Bob Stanneveld

                A control is placed on a dialog or form or... inside your doc/view classes you add some classes that contain information ABOUT the control. :confused: confused yet? :confused: for example: on your dialog you have a edit box, in the dialog class you'll need a CEdit member to obtain information about the edit control and it's contents. You don't need to call the create method! If you wan't to dynamically create the controls see the controlyouwant.Create() for details hope this helps...

                A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

                L Offline
                L Offline
                ladder
                wrote on last edited by
                #7

                I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );

                B 1 Reply Last reply
                0
                • L ladder

                  I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );

                  B Offline
                  B Offline
                  Bob Stanneveld
                  wrote on last edited by
                  #8

                  Classwizard generated classes are derived from CObject and support dynamic creation! If you look inside the class you should see that the default constructor is protected! You can't create it with the new operator. You should make it a RUNTIME_CLASS and use CreateObject to create the control. Second you should initialize it with the Create() method. exemple: CRuntimeClass *pClass = RUNTIME_CLASS(CSampleControl); CSampleControl *pControl = (CSampleControl*) pClass->CreateObject(); pControl->Create(); the runtime class contains the RTTI (RunTime Type Information). hope this helps :)

                  A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

                  1 Reply Last reply
                  0
                  • L ladder

                    I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );

                    E Offline
                    E Offline
                    ElCachubrey
                    wrote on last edited by
                    #9

                    Do you create this control on class method??? If yes where placed define you control and use new operator If for instance you declared you control in some method of you class and after used new operator and create function then after exit from this method you recieve exactly you trouble. I.e bool YouClass::SomeMethod(){ CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 ); return true;//exit from method and recived exception } Also you may not call AfxEnableControlContainer(); on InitInstaced method of you application

                    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