ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WM_LBUTTONDOWN

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
alex_b
1433 Views, 10 Replies

WM_LBUTTONDOWN

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

10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: alex_b

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.

Message 3 of 11
alex_b
in reply to: Anonymous

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

Message 4 of 11
Anonymous
in reply to: alex_b

ok. post your class and I'll try to help.

Message 5 of 11
alex_b
in reply to: Anonymous

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

Message 6 of 11
Anonymous
in reply to: alex_b

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
}

Message 7 of 11
alex_b
in reply to: Anonymous

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

Message 8 of 11
Anonymous
in reply to: alex_b

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 🙂

 

Message 9 of 11
alex_b
in reply to: Anonymous

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

 

 

Message 10 of 11
Anonymous
in reply to: alex_b

Message 11 of 11
alex_b
in reply to: Anonymous

The 1st way looks promising. I'll try it out.

Thanks

alex

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report