in the attachments, there is a video about my problem. it is not easy to express, so I recorded this video.
in the video, you can find that, the dialog in the bottom of the CAD frame, is a modeless dialog. First, I select a line in the viewport, then I click a button in this dialog, I guess now the focus is on this dialog. then I double click the item of the listview in the dialog. I intened to position a line in the viewport, you can see, I have zoomed to the line, in my code, I have selected the line,too.
void MakeEntsSelected(ads_name ssName)
{
acedSSSetFirst( NULL , NULL );
int es=acedSSSetFirst(ssName,NULL);
}
the function above is the code used to make entities selected by code. but you can see that ,only if I clicked the viewport, then the entities show selected. it seems that the viewport do not get focus. I have used functions like ,
actrTransactionManager->flushGraphics();
acedUpdateDisplay();
but it does not work.
I what context is your MakeEntsSelected() function executing? It should be in a document context command handler. In some cases, it might work outside the document context if you set focus to the document window then send a WM_MOUSEACTIVATE message:
PostMessage( hwndDoc, WM_MOUSEACTIVATE, 0, MAKELPARAM(HTCLIENT,WM_LBUTTONDOWN) );
like this, PostMessage( curDoc(), WM_MOUSEACTIVATE, 0, MAKELPARAM(HTCLIENT,WM_LBUTTONDOWN) );
but it can not be compiled and error come out,
error C2660: “CWnd::PostMessageW” do not accept four parameters.
I am sure that MakeEntsSelected() has been executed.
If you want to call CWnd:: PostMessage(), you'll need to change the arguments accordingly.
//position a feature.
void CFeaturePropDlg::OnBnClickedBtnPosFeature()
{
CMineFeature* pMF = GetCurrentMineFeatureProp();
if (NULL == pMF) return;
PosFeature(pMF);
//PostMessage( curDoc(), WM_MOUSEACTIVATE, 0, MAKELPARAM(HTCLIENT,WM_LBUTTONDOWN) );
acedGetAcadDwgView()->SendMessage(WM_MOUSEACTIVATE, 0, MAKELPARAM(HTCLIENT,WM_LBUTTONDOWN));
}
above is the fuction. I used acedGetAcadDwgView(), but it still does not work. only when I click the viewport, then the selected entities show.
You need to first set focus to the window, and post the message instead of sending. As I said, I don't know if that will work in your case, but it does work in some cases.
Can't find what you're looking for? Ask the community or share your knowledge.