Hi
I have this modeless, frameless, color-transparent popup (quite a moutful) dialog and I can't get the
WM_LBUTTONDOWN messages for it (it can though get other messages e.g. WM_NCHITTEST).
Is this an Autocad issue?
Thanks
alex
Solved! Go to Solution.
Alex. I never had problems with this. I think, you create your own component, based on CWnd, if it's so, it's your bug.
Nevertheless, to check it create function "pretranslatemessage" within your class. It have to be like this one 🙂
h file
virtual BOOL PreTranslateMessage(MSG* pMsg);
cpp file
BOOL CMyWnd : : PreTranslateMessage(MSG* pMsg)
{
switch (pMsg->message)
{
case WM_LBUTTONDOWN:
{
acedAlert(L"It's my bug!!!");
break;
}
// ... some more flags
}
return CWnd : : PreTranslateMessage(pMsg);
}
if you see the message after clicking your dialog, you did something wrong.
Hi Nick1983
Thanks for replying.
I just implemented the snippet you posted and:
1. It responds
2. It started responding only after I moved and clicked the dialog a few times.
3. It completely took over the I/O from Acad, to the extent that Acad stopped responding to anything (even picks on the menu, screen outside the dialog fired off the message) including keyboard.
It is strange though that the implementation of NCHITTEST worked fine (I mean before this).
I could post the class here?
alex
Here it is
and Thanks
alex
Notes:
1. the CButtonST class is just for cosmetics; see comments
2. we never get the WM_LBUTTONDOWN message (by Spy++) but we get WM_NCHITTEST and WM_MOVE
3. Acad2008, VS2005, WinXP
I compiled an arx using your class. And I had to make some changes to make it works.
That's what I changed:
// need to change base class of your dialog. change it from CDialog to CAcUiDialog.
// need to add to H
public:
BOOL Create( CWnd* pParent = NULL ); // ->ADD THIS FUNCTION
LRESULT OnAcadKeepFocus(WPARAM, LPARAM); // ->ADD THIS FUNCTION
//need to add to CPP
// change acedAlert to acutPrintf, because acedAlert takes focus
// for example acutPrintf(L"\nOnLButtonUp");
BOOL KNMainMenu::Create( CWnd* pParent )
{
return CAcUiDialog::Create(KNMainMenu::IDD, pParent);
}
LRESULT KNMainMenu::OnAcadKeepFocus(WPARAM, LPARAM)
{
return (TRUE);
}
// insert in BEGIN_MESSAGE_MAP
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
dialog creation:
// I did it in acrxEntryPoint, Because I don't know how do you use your dialog.
static KNMainMenu * newDlg = NULL; //<- after all "#include"
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt)
{
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
if (newDlg == NULL)
{
if ((newDlg = new KNMainMenu) == NULL) {;/*you must react if something is wrong. in such cases, I unload arx file*/}
if (!newDlg->Create(acedGetAcadFrame())){;/*you must react if something is wrong. in such cases, I unload arx file*/}
}
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt)
{
if (newDlg)delete newDlg; // free comp memory
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
return (retCode) ;
}
static void asdfDlgTesttestdlg(void)
{
newDlg->ShowWindow(SW_SHOW); // show your window to user
}
Thanks for the reply.
I wasn't aware of OnAcadKeepFocus().
PreTranslateMessage() works OK now.
The problem is, it reacts to WM_LBUTTONUP only when user presses one of the dialog buttons, never when clicking on the dialog area (which is what I need).
I find the problem is a WM_NCHITTEST handler, which is needed to enable moving the dialog, so it seems they are mutually exclusive..
Any idea how to receive and react to both WM_LBUTTONUP and WM_NCHITTEST?
Thanks
alex
Sorry, can't help you with WM_NCHITTEST. I don't like to use it 🙂
Tell me what you want from HitTest? Might be there is another way get what you want 🙂
The dialog is w/o title bar, so I use NCHITTEST as a simple way of moving it:
UINT hit = CAcUiDialog:: OnNcHitTest(pt);
if ( hit == HTCLIENT )
{
return HTCAPTION;
}
else return hit;
There are other, more complicated, ways of accomplishing this.
There is probably some interference between HITTEST and BUTTONDOWN, haven't been able to find any docu on this though.
Thanks
alex
http://www.codeproject.com/KB/dialog/Move_no-caption_dialog.aspx
might be this can help you.
Can't find what you're looking for? Ask the community or share your knowledge.