|
-
Oct 1st, 2001, 01:09 PM
#1
Thread Starter
Fanatic Member
WindowProc Help Please!!!
I have 3 rtboxes. 2 of them follow the pos of the middle box. When the middle box scrolls left/right, the top box follows. when it scrolls up/down, the box on the left follows.
I'm have a couple of difficulties using this function. One problem is that it seems I can only use this code with one form at a time, I need to be able to use it with multiple forms. Here's the code:
Module:
Public Function WindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_VSCROLL Then
'Scroll the 2nd RTFBox in Unison
Call SendMessage(frmSearch.txtRecordNumbering.hwnd, WM_VSCROLL, wParam, ByVal lParam)
End If
If Msg = WM_HSCROLL Then
'Scroll the 3rd RTFBox in Unison
Call SendMessage(frmSearch.txtDumpNumbering.hwnd, WM_HSCROLL, wParam, ByVal lParam)
End If
WindowProc = CallWindowProc(lPrevWndProc, hwnd, Msg, wParam, ByVal lParam)
End Function
Form:
Private Sub Form_Load()
Dim iIndex As Integer
lPrevWndProc = SetWindowLong(txtResults.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(txtResults.hwnd, GWL_WNDPROC, lPrevWndProc)
End Sub
I need the frmSearch part to be dynamic in a way. I tried adding Form1 as Form and the substituting frmSearch with Form1, but it didn't work.
Also, a seperate problem is that once I go over about 2185 lines in a rtbox to the left, the boxes no longer stay in sync. any idea as to why this happens?
if you need more explanation on this, please ask! thanks
-
Oct 1st, 2001, 01:48 PM
#2
You can subclass one window at a time. Not two.
Each rtf box is a separate window.
Just get the hWnd of each rtbox and use SendMessage
-
Oct 1st, 2001, 02:38 PM
#3
Thread Starter
Fanatic Member
that's what I'm doing?
If Msg = WM_VSCROLL Then
'Scroll the 2nd RTFBox in Unison
Call SendMessage(frmSearch.txtRecordNumbering.hwnd, WM_VSCROLL, wParam, ByVal lParam)
End If
If Msg = WM_HSCROLL Then
'Scroll the 3rd RTFBox in Unison
Call SendMessage(frmSearch.txtDumpNumbering.hwnd, WM_HSCROLL, wParam, ByVal lParam)
End If
-
Oct 1st, 2001, 06:07 PM
#4
I don't know the names of all your txt boxes,
all you need is this:
Code:
Call SendMessage(frmSearch.txtRecordNumbering.hwnd,wparamsmessage I justgot, lParamI justgot)
Call SendMessage(frmSearch.txtDumpNumbering.hwnd,wparamsIjustGot,lParamsI just got)
The above assumes the names of the dependent boxes are
txtRecordNumbering & txtDumpNumbering. These names will change when the controlling window changes.
What you have to do is capture every keystroke and event for the active box, then send the corresponding message to the dependent box or boxes. The dependent boxes change.
What you are doing is synchronizing a set of windows (textboxes)
While what you did could be made to work just fine, it's only going to work on one input window at a time- controlling other windows. When the window loses focus, you have to re-do.
You should not change dependent boxes unless you turn off the hook for the current primary window when it loses focus.
You will need three versions of your code, one for each window (text box) that can get focus.
You will have unsubclass the textbox in the lostfocus event, and play the setwindowlong game with a different windowproc for the next textbox in the gotfocus event. Plus you will have to find a way to shut off any subclassing at image rundown (exit) or you WILL crash.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|