问题描述
CWnd*getWnd=newCWnd();GetId(getWnd,IDC_STATIC_MainPLAY);CStatic*getDlg=(CStatic*)getWnd;voidCVideoClientDlg::GetId(CWnd*objectWnd,UINTId){HWNDhwnd=mainForm->m_hWnd;CWnd*cWnd=FromHandle(hwnd);objectWnd=cWnd->GetDlgItem(Id);}getWnd无法取到值,请指教!
解决方案
解决方案二:
这怎么可能拿得到呢,getWnd这个窗口上又没有IDC_STATIC_MainPLAY这个控件
解决方案三:
//DynamicallycreatestaticcontrolusingCWnd::Create,//insteadofwithCStatic::Create,whichdoesn't//needthe"STATIC"classname.voidCMyDlg::OnCreateStatic(){//m_pWndStaticisaCWnd*memberofCMyDlgm_pWndStatic=newCWnd;m_pWndStatic->Create(_T("STATIC"),_T("Hi"),WS_CHILD|WS_VISIBLE,CRect(0,0,20,20),this,1234);}
解决方案四:
修改一下:CWnd*getWnd;getWnd=newCWnd();getWnd->Create(WS_CHILD|WS_VISIBLE,CRect(30,30,200,200),this,105);
解决方案五:
利用函数指针数组调用每个函数int(*pfun[3])(int,int);intAdd(intone,inttwo){returnone+two;}intsub(intone,inttwo){returnone-two;}intdivnumber(intone,inttwo){returnone/two;}intmain(intargc,char*argv[]){pfun[0]=Add;pfun[1]=sub;pfun[2]=divnumber;intresult;for(inti=0;i<3;i++){result=pfun[i](20,10);printf("%d",result);printf("n");}return0;}//运行结果是:30,10,2
解决方案六:
那个打酱油的修改的对
解决方案七:
CWnd*getWnd;getWnd=newCWnd();