Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

c - Alternative to HWND_BROADCAST?

We have a suite of programs (pure, native 64 bit C) that share a common database. When a database record is changed, we currently use a posted HWND_BROADCAST to alter all of our programs to the change. This works great, but...

If the user has lots of OTHER programs (i.e. top level windows) running AND a program is required to make a very large number of changes (e.g. changing a field in 5,000 records) that flood of broadcasts appears to the cause of the entire Windows system behaving sluggishly. Typically, user inputs end up stored until the changes complete and then a big flurry of activity occurs. Since Windows rarely (if ever) records the mouse position when a click is recorded and/or uses the current mouse position when a click is processed, this often has very undesirable effects.

We could post a series of messages directly to each of our programs, but that, too, seems like a poor solution. I have been (unsuccessfully) searching for something between many PostMessage() calls and HWND_BROADCAST. I'm imagining something like a Window Message equivalent of UDP MultiCast where the programs "register for a message group" and then a single message may be sent to the group.

Does such a thing exist? It seems like it would be very useful.

EDIT: Thanks for the comments that confirm my fear that the functionality I hoped for doesn't exist: Windows does not provide a way to send a registered window message to all of (but also only) the applications that have registered it.

We now have a change/feature request awaiting implementation that will allow us to post a message to all programs that are registered with our task management program. This won't be difficult as the Task Manager already has all of the registered window (and process) handles.

We just try to use already existing system features rather than creating them ourselves, when possible. This seemed so mind numbingly obvious that we were surprised that we were unable to find the function, so I asked here hoping that I was just missing the necessary keyword for my search.

Oh well, thanks again for the answers!

question from:https://stackoverflow.com/questions/65921926/alternative-to-hwnd-broadcast

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...