Click to See Complete Forum and Search --> : ID.


August 23rd, 1999, 01:58 AM
How can I give ID to a bitmap file?

Not using resource editor..

Burlacu Ovidiu
August 23rd, 1999, 02:07 AM
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 -:)

August 23rd, 1999, 04:56 AM
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

Burlacu Ovidiu
August 23rd, 1999, 05:07 AM
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 -:)

shkim77
August 23rd, 1999, 07:43 PM
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..

Burlacu Ovidiu
August 24th, 1999, 02:11 AM
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

shkim77
August 24th, 1999, 03:19 AM
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?

Burlacu Ovidiu
August 24th, 1999, 03:36 AM
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