Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

syncronize scroll bars

Posted on 1999-08-02
11
Medium Priority
?
230 Views
Last Modified: 2013-12-03
hello ,

suppose i'm having any windows app. running say Word running . then my application starts .now the requirement is ..when ever document in first app. ( word in our case ) is scrolled ..my app. also srcolls by same area .

please help !!!!

Thanks in advance ..

regards ,
aggarwal

0
Comment
Question by:Aggarwal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 800 total points
ID: 1404293
What you have to do is to capture the scrollbar messages in Word (such as SBM_SETPOS, SBM_SETSCROLLINFO etc.) and notify your application when changes occur.

You can do the monitoring using a windows hook (either system-level or thread-specific, depends on your app) but be advised that this is a complicated proceture with lots of pitfalls.

Start by reading the documentation of SetWindowsHookEx() and the following article by Microsoft:
    http://msdn.microsoft.com/library/techart/msdn_hooks32.htm

When you feel comfortable with the notion of hooks, read the following:
    http://www.experts-exchange.com/Q.10063288 (costs 5 points)
    http://www.experts-exchange.com/Q.10069661 (costs 4 points)

Good luck!
0
 
LVL 11

Expert Comment

by:alexo
ID: 1404294
One more thing.  Personal experience shows that system-level hooks are almost non-debuggable.  Prepare for lots of aggravation...
0
 
LVL 1

Author Comment

by:Aggarwal
ID: 1404295
thanks for the info .

current status :

i installed WH_SYSMSGFILTER ..

i tried using WH_GETMESSAGE ..but its not catching any SCROLL msg. its recieving WM_PAINT msg ..but not scroll ..

using WH_SYSMSGFILTER ...i'm getting there is something happening with the Scroll bar as nCode = MSGH_SCROLLBAR .. now the problem is getting the scroll info ..like nPos , nTrackPos , nMin , nMax ..

i tried using lParam of the msg to get lpsi( LPSCROLLINFO) ..its not working ..

can u please help me !!!

regards ,
aggarwal

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 11

Expert Comment

by:alexo
ID: 1404296
lparam is a pointer to an MSG structure.  Try the something like following (not tested):

MSG* pMsg = (MSG*)lparam;
if ((pMsg->hwnd == /* handle to the desired scrollbar */) &&
    (pMsg->message == SBM_SETSCROLLINFO))
{
    SCROLLINFO* pInfo =  (SCROLLINFO*)pMsg->lParam;
    // Do the rest...
}

If you cannot make it work, try the WH_CALLWNDPROC or WH_CALLWNDPROCRET filters.  However they will waste more CPU so I'll suggest you do your best to stick with WH_SYSMSGFILTER.

One more suggestion, try writing a *local* WH_MSGFILTER hook with a test application.  It is easier to debug and you can "graduate" to a sustemwide WH_SYSMSGFILTER when things work OK.

WH_GETMESSAGE is for *posted* messages.  Scrollbar messages are *sent*.

0
 
LVL 1

Author Comment

by:Aggarwal
ID: 1404297
i have tested this ..

MSG* pMsg = (MSG*)lparam;
if ((pMsg->hwnd == /* handle to the desired scrollbar */) && 
    (pMsg->message == SBM_SETSCROLLINFO))
{
    SCROLLINFO* pInfo =  (SCROLLINFO*)pMsg->lParam;
    // Do the rest...
}

same code i have already tried ..no use ..it doesn't recieve this "SBM_SETSCROLLINFO" msg.

anyways ..i'll try other suggestions and post here .

thanks a lot

regards ,
aggarwal

0
 
LVL 11

Expert Comment

by:alexo
ID: 1404298
WH_CALLWNDPROC or WH_CALLWNDPROCRET will catch this message (guaranteed!).  More overhead though so the hook proc needs to be as efficient as possible.
0
 
LVL 1

Author Comment

by:Aggarwal
ID: 1404299
yeah WH_CALLWNDPROC  is catching this message , now i got nPos , nMin , nMax basically LPSCROLLINFO , now i need to apply that information to my app. scroll bar ..

any suggestions .

thanks
aggarwal
0
 
LVL 11

Expert Comment

by:alexo
ID: 1404300
You need to transfer the info to your application.  Easiest way is to keep the handle to your app's window in the DLL (in a shared section!) and send (or post) it a message from inside the hook.  Just remember that sent messages may be also caught by your hook so take care to avoid an infinite loop.

When your app receives the message, it can adjust your scrollbars according to the received info.

One thing to remember is not to pass pointers between different address spaces.  It *may* work but it can also crash the target app (or just pass wrong data).  You can use WM_COPYDATA for safe copying.
0
 
LVL 1

Author Comment

by:Aggarwal
ID: 1404301
hello ,

now in my application i got all the information regarding scrollbar of the other app.

basically in my app. i got lpsi , and scrollbar handle ..

now i need to apply in my application ..now i need ur help ..

my app. is MFC application ..derived from CScrollView ..nothing added to the app. ritenow ..how to apply this information ..as i dun know size of the doc.

please help me ..

regards ,
aggarwal
0
 
LVL 11

Expert Comment

by:alexo
ID: 1404302
>> my app. is MFC application
Sorry Aggarwal, I can't help you with MFC.

>> as i dun know size of the doc.
Well, you can query the "original" scrollbar.
SBM_GETSCROLLINFO sounds right but you can also try SBM_GETRANGE.
Or, if you prefer the functions: GetScrollInfo() and GetScrollRange().
0
 
LVL 1

Author Comment

by:Aggarwal
ID: 1404303
thanks !!!

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question