在对话框放了一个按钮为IDC_BUTTON1..Dlg类中加入了CBitmapButton m_button然后画了一个位图ID为"COPYU",又画了一个为"COPYD"在OnInitDialog()中加入了VERIFY(m_button.AutoLoad(IDC_BUTTON1,this));为什么执行时会出现异常?

解决方案 »

  1.   

    你的 m_button应该不是控件变量
    而且你的Button样式应该是Owner Draw
      

  2.   

    我设置成了Owner Draw 了我的m_button,就是一个CBitmapButton 变量呀
      

  3.   

    你可以这样做,用ClassWizard建立一个基于控件的CButton变量
    CButton m_button;
    然后把手动CButton改为CBitmapButton 
    其他的地方不需要如InitialDialog里不用AutoLoad
      

  4.   

    CBitmapButton的AutoLoad()函数是怎么识别位图资源的呀
      

  5.   

    没有加载位图。To include a bitmap-button control in a dialog box, follow these steps: Create one to four bitmap images for the button.
    Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
    Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
    In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
    In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
    In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer. 
    .
    Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
      

  6.   

    建议不要AutoLoad  m_button.LoadBitmaps(COPYU,COPYD);
      

  7.   

    the brother upstairs',you'd better show how to call the CBitmapButton object’s AutoLoad function,or how to using as parameters the button’s control ID and the CDialog object’s this pointer.