duilib / duilib

MIT License
5.72k stars 1.96k forks source link

Is there something similar to SetWindowText to work with duilib #215

Closed itsho closed 4 years ago

itsho commented 4 years ago

Hello.

First - this is an AMAZING project. kudus!. Second - Is there anything similar/equivalent to SetWindowText or WM_SETTEXT that works on Applications created with duilib?

Thanks in advance! ๐Ÿ˜„

Apologies for not writing in Chinese...

daviyang35 commented 4 years ago

Text label have setText method.

itsho commented 4 years ago

Yes, I've seen that, but my question is regarding a different process

daviyang35 commented 4 years ago

Don't understand your intent. Describe what you want. Use a story describe it may be

itsho commented 4 years ago

I have two EXE files:

  1. app A written with duilib with
  2. app B written with any other UI infrastructure.

if app B wants to change the text in app A, naturally, it would use a WINAPI like SetWindowText or WM_SETTEXT but, it would only work if app A is written with a Windows GUI library like MFC or WinForms.

now, that app A is using guilib, the mentioned WINAPI no longer works since app A does not have Handles to the inner parts.

so my question is: is it possible to change any text in app A from app B like we use to do with the mentioned WINAPI? the common case that I'm referring to is translating a running application to a different language.

Thank you very much in advance!

daviyang35 commented 4 years ago

You can use the WM_COPYDATA message or other custom IPC protocol. B send WM_COPYDATA message to A. payload describe target label control id and new message content.

A receive message and handle it.

Other solution Maybe: A create a Win32 label with specific id and hide it. filter message to set duilib control. B use SetWindowText with A hide label hwnd.

itsho commented 4 years ago

Thank you.

Although very helpful, communication between two apps is not working well for my case - translating a duilib app without changing the first app code.

is there anything else I can do?

thanks again!

daviyang35 commented 4 years ago

you mean that A is duilib app, B is any other implement app. want change A's label and not modify A ?

itsho commented 4 years ago

yes. exactly. just like SetWindowText is working for old apps without changing them.

daviyang35 commented 4 years ago

Canโ€˜t do that. Duilib is handleless framework. Can not change it's own control behavior with Window Message.

If you must doing this. try to use windows process injection tech.