A few days ago and a few of the friends of the beginner VC, one of which asked me, how to add pictures on a button
I thought, this is simple, set the button's style to Bitmap.
Then load pictures when you click Button, the code is as follows:
Void ctestdlgdlg :: onbutton4 ()
{
Hbitmap hbitmap;
Hbitmap = :: loadbitmap (:: afxgetinstancehandle (), makeintresource (idb_bmp_mybmp);
m_cbtnbmp.setBitmap (HBitmap);
}
The result is how pictures don't come out, I didn't get it for a long time, very depressed.
This is so forgotten, and the result suddenly remembered this, change the code.
Define HbitMap M_Hbitmap for member variables of CTestDLGDLG;
Void ctestdlgdlg :: onbutton4 ()
{
m_hbitmap = :: loadbitmap (: AFXGetInstanceHandle (), makeintResource (idb_bmp_mybmp);
m_cbtnbmp.setbitmap (m_hbitmap);
}
Get it ----
Think about it, I have made a very mentally wrong mistake, each variable has its own living space, only in this living space, the variable is effective
However, normal thinking should be on the set, unless you have uninstall it, don't change, don't know how Microsoft considers this? ? ?