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. How to change place of activex control at run time

How to change place of activex control at run time

Scheduled Pinned Locked Moved C / C++ / MFC
delphicom
7 Posts 3 Posters 2 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.
  • A Offline
    A Offline
    adityarao31
    wrote on last edited by
    #1

    I am having windows media player as activex control in my application. I am trying to use create method for same but I am not able to use. Some where I am missing something. CWMPPlayer4 m_lplayer; void CApl2IEDlg::OnButton1() { RECT lprect; lprect.bottom = 0; lprect.left = 0; lprect.right = 100; lprect.top = 100; RegisterWindow(); CWMPPlayer4 cwmp; cwmp.Create(m_lplayer,mediaclass,0,lprect,(CWnd*)m_hWnd,0,NULL); } LRESULT FAR PASCAL WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { return (DefWindowProc(hWnd, Message, wParam, lParam)); } void CApl2IEDlg::RegisterWindow() { mediaclass = "mediaclass"; WNDCLASS wndclass; wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = AfxGetInstanceHandle(); wndclass.hIcon = LoadIcon(NULL,_T("")); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = mediaclass; }

    || Lust Causes Sorrow ||

    M 2 Replies Last reply
    0
    • A adityarao31

      I am having windows media player as activex control in my application. I am trying to use create method for same but I am not able to use. Some where I am missing something. CWMPPlayer4 m_lplayer; void CApl2IEDlg::OnButton1() { RECT lprect; lprect.bottom = 0; lprect.left = 0; lprect.right = 100; lprect.top = 100; RegisterWindow(); CWMPPlayer4 cwmp; cwmp.Create(m_lplayer,mediaclass,0,lprect,(CWnd*)m_hWnd,0,NULL); } LRESULT FAR PASCAL WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { return (DefWindowProc(hWnd, Message, wParam, lParam)); } void CApl2IEDlg::RegisterWindow() { mediaclass = "mediaclass"; WNDCLASS wndclass; wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = AfxGetInstanceHandle(); wndclass.hIcon = LoadIcon(NULL,_T("")); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = mediaclass; }

      || Lust Causes Sorrow ||

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      It looks like you might be using the wrong Create() for an activex control. Make sure you're calling a Create() method from the wrapper class for the control. To create the wrapper class (if you haven't already), you can use Project Menu/Add Class/MFC/ MFC Class from ActiveX Control. Mark

      Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

      S 1 Reply Last reply
      0
      • A adityarao31

        I am having windows media player as activex control in my application. I am trying to use create method for same but I am not able to use. Some where I am missing something. CWMPPlayer4 m_lplayer; void CApl2IEDlg::OnButton1() { RECT lprect; lprect.bottom = 0; lprect.left = 0; lprect.right = 100; lprect.top = 100; RegisterWindow(); CWMPPlayer4 cwmp; cwmp.Create(m_lplayer,mediaclass,0,lprect,(CWnd*)m_hWnd,0,NULL); } LRESULT FAR PASCAL WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { return (DefWindowProc(hWnd, Message, wParam, lParam)); } void CApl2IEDlg::RegisterWindow() { mediaclass = "mediaclass"; WNDCLASS wndclass; wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = AfxGetInstanceHandle(); wndclass.hIcon = LoadIcon(NULL,_T("")); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = mediaclass; }

        || Lust Causes Sorrow ||

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Also... The title of your post is "How to change place of activex control at run time". Are you just wanting to change the position/size of the control or create the control at runtime? Mark

        Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

        A 1 Reply Last reply
        0
        • M Mark Salsbery

          It looks like you might be using the wrong Create() for an activex control. Make sure you're calling a Create() method from the wrapper class for the control. To create the wrapper class (if you haven't already), you can use Project Menu/Add Class/MFC/ MFC Class from ActiveX Control. Mark

          Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

          S Offline
          S Offline
          shivditya
          wrote on last edited by
          #4

          I am using create method which is there in .cpp file which gets loaded once we insert control from registered controls. We can use other methods, Cant we use create? Anyway I will try your suggestion tomorrow. But every time I try to create window for control this problem comes. I am really fed up of ActiveX controls but I have to use.

          || ART OF LIVING ||

          M 1 Reply Last reply
          0
          • S shivditya

            I am using create method which is there in .cpp file which gets loaded once we insert control from registered controls. We can use other methods, Cant we use create? Anyway I will try your suggestion tomorrow. But every time I try to create window for control this problem comes. I am really fed up of ActiveX controls but I have to use.

            || ART OF LIVING ||

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            shivditya wrote:

            I am using create method which is there in .cpp file which gets loaded once we insert control from registered controls

            Hmm - I don't know what version of Visual Studio you're using, but I get two Create methods in a wrapper class on Visual C++ 2003:

            virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
            const RECT& rect, CWnd* pParentWnd, UINT nID,
            CCreateContext* pContext = NULL);

            BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
            UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
            BSTR bstrLicKey = NULL);

            Neither of these match the parameters you are passing to Create(). Mark

            Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

            1 Reply Last reply
            0
            • M Mark Salsbery

              Also... The title of your post is "How to change place of activex control at run time". Are you just wanting to change the position/size of the control or create the control at runtime? Mark

              Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

              A Offline
              A Offline
              adityarao31
              wrote on last edited by
              #6

              I am using version of VC++ version 6.0. I dont understand your concept of wrapper class. The classes gets automatically created once you place activex control. So I feel version in not required. The defination of create() which I have written is one which comes in Active X controls self generated classes. Any way I done one mistake I dont need to create control at runtime. I just need to change place at runtime so that I can save my text display. I got my own answer I have to get window then rect and change place. My current problem is diverted,but still these create remains problem. #if !defined(AFX_WMPPLAYER4_H__29950495_92A5_48C7_A665_14C10BA68140__INCLUDED_) #define AFX_WMPPLAYER4_H__29950495_92A5_48C7_A665_14C10BA68140__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. // Dispatch interfaces referenced by this interface class CWMPControls; class CWMPSettings; class CWMPMedia; class CWMPMediaCollection; class CWMPPlaylistCollection; class CWMPNetwork; class CWMPPlaylist; class CWMPCdromCollection; class CWMPClosedCaption; class CWMPError; class CWMPDVD; class CWMPPlayerApplication; ///////////////////////////////////////////////////////////////////////////// // CWMPPlayer4 wrapper class class CWMPPlayer4 : public CWnd { protected: DECLARE_DYNCREATE(CWMPPlayer4) public: CLSID const& GetClsid() { static CLSID const clsid = { 0x6bf52a52, 0x394a, 0x11d3, { 0xb1, 0x53, 0x0, 0xc0, 0x4f, 0x79, 0xfa, 0xa6 } }; return clsid; } virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey); } // Attributes public: // Operations public: void close(); CString GetUrl(); void SetUrl(LPCTSTR lpszNewValue); long GetOpenState(); long GetPlayState(); CWMPControls G

              M 1 Reply Last reply
              0
              • A adityarao31

                I am using version of VC++ version 6.0. I dont understand your concept of wrapper class. The classes gets automatically created once you place activex control. So I feel version in not required. The defination of create() which I have written is one which comes in Active X controls self generated classes. Any way I done one mistake I dont need to create control at runtime. I just need to change place at runtime so that I can save my text display. I got my own answer I have to get window then rect and change place. My current problem is diverted,but still these create remains problem. #if !defined(AFX_WMPPLAYER4_H__29950495_92A5_48C7_A665_14C10BA68140__INCLUDED_) #define AFX_WMPPLAYER4_H__29950495_92A5_48C7_A665_14C10BA68140__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. // Dispatch interfaces referenced by this interface class CWMPControls; class CWMPSettings; class CWMPMedia; class CWMPMediaCollection; class CWMPPlaylistCollection; class CWMPNetwork; class CWMPPlaylist; class CWMPCdromCollection; class CWMPClosedCaption; class CWMPError; class CWMPDVD; class CWMPPlayerApplication; ///////////////////////////////////////////////////////////////////////////// // CWMPPlayer4 wrapper class class CWMPPlayer4 : public CWnd { protected: DECLARE_DYNCREATE(CWMPPlayer4) public: CLSID const& GetClsid() { static CLSID const clsid = { 0x6bf52a52, 0x394a, 0x11d3, { 0xb1, 0x53, 0x0, 0xc0, 0x4f, 0x79, 0xfa, 0xa6 } }; return clsid; } virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey); } // Attributes public: // Operations public: void close(); CString GetUrl(); void SetUrl(LPCTSTR lpszNewValue); long GetOpenState(); long GetPlayState(); CWMPControls G

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                In a dialog, you can add a control variable to the class just like any other control: // Add the member to the class declaration CWMPPlayer4 m_MediaPlayer; ... // Add this line to DoDataExchange() (where IDC_PLAYER is the ID of the control resource) DDX_Control(pDX, IDC_PLAYER, m_MediaPlayer); Then any time after the control is created (after the base class OnInitDialog() has been called) you can access it like any other window (CWMPPlayer4 is a CWnd-derived class)... m_MediaPlayer.GetWindowRect(...) m_MediaPlayer.MoveWindow(...) etc. Mark

                Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

                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