draw method of activex
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: draw method of activex

  1. #1
    Join Date
    Mar 2007
    Posts
    238

    draw method of activex

    HI Gurus,
    Is it possible to attach a dialog class in the draw method of activx ctrl class?
    Code:
    void CRotaryCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
    
    pdc->......//(attach an cdialog subclass)
    thanks

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: draw method of activex

    Please elaborate on "attach". It can mean different things, so it's good to hear from you instead of guessing

  3. #3
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    By attach i mean, i have a dialog class which I created in the activex project which has combobox, edit box etc.
    I want to display this dialog box in the activex control draw method.
    Is it possible?

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: draw method of activex

    It is possible, but not the right approach. Draw is for drawing , not for creating dialog box.

  5. #5
    Join Date
    Apr 1999
    Posts
    3,585

    Re: draw method of activex

    Is this what you're trying to do?
    Gort...Klaatu, Barada Nikto!

  6. #6
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    Exactly Mike, that's what i am trying to do.
    But when i do exactly what the article says i get error :winocc.cpp line 307. Basically it doesn't like the movewindow method. I tested the control using visual studio activex test control container. Tried with IE as the article says same error message.

    Any suggestion?
    Last edited by tarunk; February 15th, 2008 at 04:58 AM. Reason: adding

  7. #7
    Join Date
    Apr 1999
    Posts
    3,585

    Re: draw method of activex

    It's probably a timing issue. That error indicates that the window is not valid at that time. You may need to restructure the sequence of code that creates the control.
    Gort...Klaatu, Barada Nikto!

  8. #8
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    hi! You are right. I was trying different things,i put the code to create the dialog in the constructor of the control and it wouldn't error now and it wouldn't display the content of my dialog also.
    Code:
    CReportXCtrl::CReportXCtrl()
    {
    	InitializeIIDs(&IID_DReportX, &IID_DReportXEvents);
    	
    	// TODO: Initialize your control's instance data here.
    	 m_reportDlg.Create(IDD_XDIALOG , this);
    }
    no changes in oncreate.
    in draw method the same as the article says....
    Code:
    m_reportDlg.MoveWindow(rcBounds, TRUE);
    This is surely more than jsut vc2003 and vc2005 issue... can't believe i am having problem one after another. Has anyone made a dialog frame to display in a mfcactivex ctrl porgram?

  9. #9
    Join Date
    Apr 1999
    Posts
    3,585

    Re: draw method of activex

    I'm using Visual Studio 2005 and I followed the sample program in the article above. I was able to build and display the control in the test container. Make sure you set the resource flags for the dialog as stated in the article.
    Gort...Klaatu, Barada Nikto!

  10. #10
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    That's strange. I tried again exactly with the resources and everything mentioned. Didn't work. Point no 5. says using classwizard create oncreate(wm_create) , i don't know if it sounds silly. But i created a virtual OnCreate(LPCREATESTRUCT lpCreateStruct) in the ctrl.h and cpp and added the code.
    Here is a .h and .cpp file as i can't attach the entire project(too big). if you can help to find out what is wrong.
    thanks
    Attached Files Attached Files

  11. #11
    Join Date
    Apr 1999
    Posts
    3,585

    Re: draw method of activex

    Two differences:

    My code uses afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); as a public message handler. And,

    I include OLEMISC_SIMPLEFRAME for the control type information.
    Gort...Klaatu, Barada Nikto!

  12. #12
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    Corrected the virutal to afx_msg...that was a silly mistake.
    isn't OLEMISC_STATUS for ATL activex ctrl... i tried to add it, but the compiler complains. I believe i need to add the atl header files. Documentation says OLEMISC_SIMPLEFRAME(miscstatus) but my code is happy with void. Bit confusing. Also if i try with the second addition, the activex container complaines there is an unknown error. Not easy isn't it?
    Attached Files Attached Files

  13. #13
    Join Date
    Apr 1999
    Posts
    3,585

    Re: draw method of activex

    Actually, it was easy for me. I used the project wizard to create the skeleton code. The "frame" option was provided via the wizard. The only changes I made were those recommended by the article.
    Gort...Klaatu, Barada Nikto!

  14. #14
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    I used the project wizard too, mfc activex control wizard. If i edit just the first part you mentioned, making it afx-msg, my container says unspecified error(i wrongly wrote only after the second addition). I wish i could get this done.

  15. #15
    Join Date
    Mar 2007
    Posts
    238

    Re: draw method of activex

    Would you mind attaching me the .cpp and .h ctrl ? I tried again now and i get the old winocc.cpp 307 error again .... strange.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center