Detecting LButtonUp LButtonDown over RMChart

Started by dacarle, June 23, 2005, 04:35:30 PM

Previous topic - Next topic

dacarle

control kill prior to calling the chart with the new size and the recreating the subclass works.  Thanks.

TechSupport

It may work but that certainly doesn't seem like the best solution. I guess that internally RMChart is resetting its window procedure when it redraws the new chart. I'll try some tests later to see what exactly happens. You should be able to resize the control without having to kill it and re-apply the subclass.

Have you seen Rainier's post in his form about the beta that he has ready. Apparantly, it handles the mouse messages for you now.

TechSupport

Scratch that last post... looks like you have already posted in the RMChart forum about the beta. I hope that it will solve the problem more elagantly than having to go through this subclass route.

dacarle

Agreed about Rainer's updates.  However, just making sure I have backup in case he run's into some delays.

TechSupport

David,

I just tried an extremely simple experiment by resizing the chart in the Form's WM_SIZE message handler. The chart resized and it did not affect the subclassing at all. I did not have to destroy or re-create the control at all. Are you doing something strange that I am not aware of? :)


Function FORM1_WM_SIZE ( _
                      hWndForm      As Dword, _  ' handle of Form
                      fwSizeType    As Long,  _  ' type of resizing request
                      nWidth        As Long,  _  ' new width of client area
                      nHeight       As Long   _  ' new height of client area
                      ) As Long


'resize chart to 75% of the Form's width and height
SetWindowPos GetDlgItem(hWndForm, %ID_RMC1), 0, 0, 0, nWidth * .75, nHeight * .75, %SWP_NOZORDER


End Function

dacarle

Will try your example in a few.  As far as strange goes, odds are extremely likely.  I tend to prefer to think of myself as unique, which when all is said and done is just a fancy word for strange.  Thanks again.

-David

dacarle

Paul-

The challenge is going to be to be able to pass data to the form.  I am using the button up to detect moving a global variable onto the graph which adds or changes price data.  This is detected in the subclass perfectly, however, how can I redraw or modify the chart while I am in the subclass?

-David

TechSupport

Off the top of my head:

Create a user defined message (place at the top of the Form).

%USR_RECREATE_CHART = %WM_USER + 1000


In your subclass mouse code, simply post your user message to the Form with the appropriate variable value (or store the value in your global variable like you are doing now). You could pass your value via the wParam or lParam parameter of the PostMessage....

PostMessage HWND_FORM1, %USR_RECREATE_CHART, 0, 0


To get the user defined message, use the CUSTOM message handler for the FORM:

Function FORM1_CUSTOM ( _
                     hWndForm      As Dword, _  ' handle of Form
                     wMsg          As Long,  _  ' type of message
                     wParam        As Dword, _  ' first message parameter
                     lParam        As Long   _  ' second message parameter
                     ) As Long

If wMsg = %USR_RECREATE_CHART Then
 
  'destroy the existing chart
  RMC_DeleteChart %ID_RMC1     'or, maybe simply: DestroyWindow GetDlgItem(hWndForm, %ID_RMC1)
  Call Show_BarsImage( HWND_FORM1, aData() )    
 
      ' Set a new class handler (Subclass procedure. Do this immediately after you create your control).
      gOrigSubClassProc = SetWindowLong(GetDlgItem(hWndForm, %ID_RMC1), %GWL_WNDPROC, CodePtr(NewWndProc))
End If

End Function


I haven't tested this, but it should work.  :)

dacarle

Will try this morning.  You are the Man!!!!!!!!

dacarle

Paul-

Works the first time like it should, in appearance.  However, does not work after the first time and the app becomes unstable.  Closing the chart window closes the entire application.  

-David

TechSupport

Okay, I tested it on a live project.

Replace:

RMC_DeleteChart %ID_RMC1

With:

DestroyWindow GetDlgItem( hWndForm, %ID_RMC1)

No GPF's now.

It looks like the RMC_DeleteChart does not actually destroy the control (no WM_DESTROY is sent).