Home > Back-end >  (MFC) GetDlgItem (IDB_BITMAP1) -> ShowWindow (SW_SHOW); This code is an executable program crash
(MFC) GetDlgItem (IDB_BITMAP1) -> ShowWindow (SW_SHOW); This code is an executable program crash

Time:10-11

(the front is the code system, please look from the middle code, only one line of code ()

 BOOL CtextDlg: : OnInitDialog () 
{
CDialog: : OnInitDialog ();
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);
CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
Cstrings strAboutMenu;
StrAboutMenu. LoadString (IDS_ABOUTBOX);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}

SetIcon (m_hIcon, TRUE);//Set the big icon
SetIcon (m_hIcon, FALSE);//Set the small icon
//the code system at above is
//the code system at above is
//the code system at above is
//the code system at above is
//the code system at above is
//the code system at above is
//the code system at above is
//the code system at above is

GetDlgItem (IDB_BITMAP1) - & gt; ShowWindow (SW_SHOW);

//the code system at below is
//the code system at below is
//the code system at below is
//the code system at below is
//the code system at below is
//the code system at below is
//the code system at below is
//TODO: Add extra initialization here

Return TRUE;//return TRUE unless you set the focus to a control
}



The above procedure is first put the position of the initialization time, program opened immediately stop work


 void CtextDlg: : OnButton2 () 
{
GetDlgItem (IDB_BITMAP1) - & gt; ShowWindow (SW_SHOW);

}



This is put in a button, a button the program immediately stop running,


Here is my header file:

 # include "stdafx. H" 
# include "text. H"
# include "textDlg. H"



My system is Windows 7 32 bit, the compiler is vc + + 6.0
Once compiled on XP, still not

Online didn't find similar example,


Please give advice or comments

CodePudding user response:

MFC run here to do
  • Related