Home > Software engineering >  MFC OCX Statictext update text control problems
MFC OCX Statictext update text control problems

Time:10-06

VS2008 wrote a control that USES a Statictext shows several running state of the text, in the process of plug-in run to update a few times,
Now is the time to use VS debugging debugging container no problem, but the use of browser calls, collapse, remove run several times in the process of updating will not collapse, so doubt is caused by the control,

This is the control of the attribute


In the interface class showwindows news get inside the handle
 void DialogMain: : OnShowWindow (BOOL bShow, UINT nStatus) 
{
CDialog: : OnShowWindow (bShow nStatus);

//TODO: add message handler code here

//of five button area as a whole, the relative coordinates of 0 0
//each button aperture of 5

Int X=0 + 820;//the initial 820
Int Y=0 + 150;//the initial 150

The size and location//
The CWnd * pWnd=GetDlgItem (IDC_BUTTON_UP);
PWnd - & gt; SetWindowPos (NULL, X + 55, Y, 50, 50, NULL);

PWnd=GetDlgItem (IDC_BUTTON_LEFT);
PWnd - & gt; SetWindowPos (NULL, X, Y + 55,50,50, NULL);

PWnd=GetDlgItem (IDC_BUTTON_RIGHT);
PWnd - & gt; SetWindowPos (NULL, X + 110, Y + 55,50,50, NULL);

PWnd=GetDlgItem (IDC_BUTTON_DOWN);
PWnd - & gt; SetWindowPos (NULL, X + 55, Y + 110,50,50, NULL);

PWnd=GetDlgItem (IDC_BUTTON_AUTO);
PWnd - & gt; SetWindowPos (NULL, X + 55, Y + 55,50,50, NULL);

//load the picture
HBITMAP HBITMAP=LoadBitmap (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDB_BITMAP_UP));
CButton * CButton=(CButton *) GetDlgItem (IDC_BUTTON_UP);
Cbutton - & gt; SetBitmap (hBitmap);

HBitmap=LoadBitmap (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDB_BITMAP_LEFT));
Cbutton=(cbutton *) GetDlgItem (IDC_BUTTON_LEFT);
Cbutton - & gt; SetBitmap (hBitmap);

HBitmap=LoadBitmap (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDB_BITMAP_RIGHT));
Cbutton=(cbutton *) GetDlgItem (IDC_BUTTON_RIGHT);
Cbutton - & gt; SetBitmap (hBitmap);

HBitmap=LoadBitmap (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDB_BITMAP_DOWN));
Cbutton=(cbutton *) GetDlgItem (IDC_BUTTON_DOWN);
Cbutton - & gt; SetBitmap (hBitmap);

HBitmap=LoadBitmap (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDB_BITMAP_AUTO));
Cbutton=(cbutton *) GetDlgItem (IDC_BUTTON_AUTO);
Cbutton - & gt; SetBitmap (hBitmap);


//load the background picture
CBitmap BMP.
BMP. LoadBitmap (IDB_BITMAP_BK);
M_brush. CreatePatternBrush (& amp; BMP);

//video load control
PIC=GetDlgItem (IDC_ANIMATE_VIDEO);
PIC - & gt; SetWindowPos (NULL, 5,5,790,490, NULL);

TEXT=GetDlgItem (IDC_STATIC_TEXT);
The TEXT - & gt; SetWindowPos (NULL, 50, 820400190, NULL);
//CFont font;
//font. CreatePointFont (20, _T (" black "), NULL);
//TEXT - & gt; The SetFont (& amp; The font);
}


The last few lines of TEXT is is the control that the interface class defined in the header file CWnd * TEXT ;

Then the control of the engineering class homevideoCtrl. CPP invoked inside

 int ChomevideoCtrl: : OnCreate (LPCREATESTRUCT LPCREATESTRUCT) 
{
If (COleControl: : OnCreate (lpCreateStruct)==1)
return -1;


//TODO: here to add your special creation code

//load
Dialogmain. Create (IDD_DIALOG2, this);
//dialogvideo. Create (IDD_DIALOG1, this);//parent form a pointer for dialogmain
//dialogvideo. SetParent (FromHandle (dialogmain m_hWnd));
//
//dialogvideo. SetWindowPos (NULL, 0, 0, 800, 500, SWP_NOMOVE);//the first parameter set-top
Dialogmain. SetWindowPos (NULL, 0,0,1000,500, NULL);


Dialogmain. TEXT - & gt; SetWindowText (" are connected camera please later ");
YSY_SDK_Init (" ats. 3 su9cbc6557jegmwbngb0dby401p0ury - 58 ykujg9 e7ip1m8q - 1-8 itg914wb ", "640033347");

return 0;
}


Control class OnCreate function calls a dialogmain. The TEXT - & gt; SetWindowText also normal
But problems in YSY_SDK_Init function call again

//SDK initialization 
Void ChomevideoCtrl: : YSY_SDK_Init (char * accesstoken, char * deviceseriak)
{
//JS incoming parameters
SzAccessToken=accesstoken;
SzDeviceSerial=deviceseriak;

//SDK interface
Int result=OpenSDK_Init (g_szAppKey);

//result=YSY_SDK_DEVINFO ();
//result=YSY_SDK_AllocSession ();
//result=YSY_SDK_Real ();

//dialogmain. TEXT - & gt; SetWindowText (" 11111 ");
If (result==0)
{
//dialogmain. TEXT - & gt; SetWindowText (" video library initialization success ");

//equipment information
Result=YSY_SDK_DEVINFO ();
If (result==0)
{
//dialogmain. TEXT - & gt; SetWindowText (" camera information success ");

//distribution session
Result=YSY_SDK_AllocSession ();
If (result==0)
{
//dialogmain. TEXT - & gt; SetWindowText (" distribution session success ");

//the preview
Result=YSY_SDK_Real ();
If (result==0)
{
Dialogmain. TEXT - & gt; SetWindowText (" began to broadcast video ");
UpdateWindow ();
}
The else
{
//dialogmain. TEXT - & gt; SetWindowText (" video start-up failure, refresh try ");
}
}
The else
{
//dialogmain. TEXT - & gt; SetWindowText (" distribution session failed ");
}
}
The else
{
//dialogmain. TEXT - & gt; Failed to get camera information SetWindowText (" ");
}
}
The else
{
//dialogmain. TEXT - & gt; SetWindowText (" video library initialization failed ");
}
}


The code in the debug container no problem, on a browser will collapse, test of 360 browser,
Aunt to see, don't know if I describe clear enough

CodePudding user response:

Add some debug information, see if the front have failed API
The second is in the IE browser to try,

CodePudding user response:

Logically rigorous again some
The CWnd * pWnd=GetDlgItem (IDC_BUTTON_UP);
If (pWnd)
PWnd - & gt; nullnullnullnullnullnullnull
  • Related