CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Graphics Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Graphics Programming Discussion graphics programming using C++. Valid topics include OpenGL, DirectX, GDI/GDI+, Aero, and more.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old April 7th, 2004, 12:10 PM
    srinatvc srinatvc is offline
    Junior Member
     
    Join Date: Jun 2003
    Posts: 10
    srinatvc is an unknown quantity at this point (<10)
    Unhappy LPPICTUREDISP -- CPictureHolder --- How to release memory?

    Hi,

    I've been working on an image based application. I'm using VB and VC++ to work with the images. Both are activex controls. I created a property like Get/SetActivePicture(LPPICTUREDISP pPicture). The code is given below.

    I'm facing memory problems. Can someone help me how can I release the memory from VC++ after I use the picture object? Thanks in advance .. I can't release the component until I solve this issue. Pls. somebody help me.

    The implemenation in VB is like this ...

    ....
    PicEd.Open("C:\Temp.bmp")
    set PicEd.ActivePicture = Picture1.Picture
    PicEd.RotateBy(90)
    set Picture1.Picture = PicEd.ActivePicture()
    ....


    //----------------------------------------------------------------------
    //NOTE: m_Pic is of type CPictureHolder
    // image is of type CxImage [ a class library found on CodeProject]

    void CPicEdCtrl::SetActivePicture(LPPICTUREDISP newValue)
    {
    // TODO: Add your property handler here
    if (newValue == NULL) return;

    try
    {
    HBITMAP hBMP;
    HRESULT lResult;

    newValue->AddRef ();
    m_Pic.SetPictureDispatch(newValue);
    newValue->Release();

    lResult = m_Pic.m_pPict->get_Handle((OLE_HANDLE FAR *) &hBMP);

    //CxImage* image;
    image->CreateFromHBITMAP((HBITMAP)hBMP);

    }catch (CException e)
    {
    e.ReportError();
    e.Delete();
    }
    SetModifiedFlag();
    }

    // ------------ ---------------------- --------------- ------

    LPPICTUREDISP CPicEdCtrl::GetActivePicture()
    {
    // TODO: Add your property handler here
    if (image == NULL)
    {
    m_Pic.CreateEmpty();
    goto EndProp;
    }

    try
    {
    m_Pic.CreateFromBitmap (image->MakeBitmap(0));

    }catch (CException e)
    {
    //Suppress any exceptions
    e.Delete();
    m_Pic.CreateEmpty();
    }
    EndProp:
    //return the IPicture dispatch interface
    return m_Pic.GetPictureDispatch();
    }
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Graphics Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 09:49 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009