Friday, November 17th 2017, 6:31pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mjanas10

Beginner

Date of registration: Oct 5th 2017

Posts: 19

1

Thursday, October 5th 2017, 2:53pm

Window to Window comms - Parent to Parent

Dear all
I wondered if you could help me solve this puzzle. Scenario is as follows: there are two unrelated windows (i.e. both windows are parents to different children), defined in two different source files.
For example, I have a main window and a footer window, both visible. Then how do I communicate to the main window that the footer window wants to, for example, display something else on the main window?

I know I can use WM_SendMessageNoPara(hWinMain, WM_FOOTER_BUTTON_BACK); in the footer callback. However that relies on having the main window handle (hWinMain) declared as global. Is there a way to communicate between the two parents without using globals? What's the best way?

Thanks

This post has been edited 1 times, last edit by "mjanas10" (Oct 5th 2017, 3:11pm)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 410

2

Friday, October 6th 2017, 3:21pm

Hi,

Yes, it is possible without global variables. You can simply react on WM_GET_ID in the callback of a window and write a unique ID into pMsg->Data.v. This way you can use WM_GetDialogItem() to get the window handle via the ID.

Attached is an example on how to do this.

As long you know the IDS you could also get the handle of a child window of another window, like:

C/C++ Source code

1
2
3
4
hItem = WM_GetDialogItem(WM_HBKWIN, ID_MAINWIN);
hItem = WM_GetDialogItem(hItem, ID_CHILD);
hItem = WM_GetDialogItem(hItem, ID_CHILD_OF_CHILD);
hItem = WM_GetDialogItem(hItem, ID_CHILD_OF_CHILD_OF_CHILD);


Regards
Sven
SEGGER - Schoenen has attached the following file: