CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: ID.

  1. #1
    Guest

    ID.

    How can I give ID to a bitmap file?

    Not using resource editor..


  2. #2
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: ID.

    Id are associated to bitmap resource only.
    You cannot obtain an ID for a bmp file but u can obtain his HBITMAP if this help u using LoadImage function

    Regards,
    Ovidiu

    fight to be the best of the rest because I am the best of the best -

  3. #3
    Guest

    Re: ID.

    Thanks, Ovidiu

    Then how can I get the HBITMAP of the bitmap file?

    Regards,
    Sheon

    p.s. : I'm sorry, but I encountered a problem when I rate your advice


  4. #4
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: ID.

    Try this:

    HBITMAP Bitmap = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);




    Regards,
    Ovidiu

    To rate me u must login with a user. If u don't have an user to codeguru you can make one at New User.
    It's best for you when u asking the people know it your name
    Best wish
    The same Ovidiu


    fight to be the best of the rest because I am the best of the best -

  5. #5
    Join Date
    Aug 1999
    Posts
    51

    Re: ID.

    Hi, Ovidiu..
    As you advise, I coded like the following:

    DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_BORDER|BS_OWNERDRAW;
    CRect rect(5,20,35,50); // 30 x 30
    UINT nID = 2000;

    m_btn->SubclassDlgItem( nID, this);
    m_btn->Create(NULL, dwStyle, rect, this, nID);
    HBITMAP hBitmap = (HBITMAP) LoadImage(NULL, "D:\\work\\envelope.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    m_btn->SetBitmap(hBitmap);

    but, "assertion failed" occurred at 72 line. winctrl1.cpp.

    I don't know the reason.

    please..


  6. #6
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: ID.

    The assertion it's cause by SubClassDlgItem. The reason is because the control doesn't exist and not defined in resource.h. Look what says in MSDN about SubClassDlgItem:

    BOOL SubclassDlgItem( UINT nID, CWnd* pParent );

    Return Value

    Nonzero if the function is successful; otherwise 0.

    Parameters

    nID

    The control’s ID.

    pParent

    The control’s parent (usually a dialog box).

    Remarks

    Call this member function to “dynamically subclass” a control created from a dialog template and attach it to this CWnd object. When a control is dynamically subclassed, windows messages will route through the CWnd’s message map and call message handlers in the CWnd’s class first. Messages that are passed to the base class will be passed to the default message handler in the control.


    Hope this help u
    Regards,
    Ovidiu


  7. #7
    Join Date
    Aug 1999
    Posts
    51

    Re: ID.

    Thank you for your concern, Ovidiu..

    I overviewed my code, but I don't know what is the problem.

    The first parameter(nID) of the SubclassDlgItem in my code is the button's ID. As you know, it was made by the following:

    m_btn->Create(NULL, dwStyle, rect, this, nID);
    // nID = 2000

    And the second is 'this'.
    As you know, this indicates 'CBitOnBtnView' and
    CBitOnBtnView was derived by CFormView.

    Any idea?



  8. #8
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: ID.

    Hi,
    All I know is that u must have a dialog template created in memory who contain your button
    I not used this thing never but u can read at dialog template in MSDN
    Or better why don't y create the button with resource editor and show him only u need?

    Regards,
    Ovidiu


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured