Monday, December 11th 2017, 12:59am UTC+1

You are not logged in.

  • Login
  • Register

FerhatYOL

Beginner

Date of registration: Nov 22nd 2017

Posts: 5

1

Thursday, December 7th 2017, 9:42pm

WM_SetCallback problem?

Hello there

I am creating an event with the WM_Set_Callback function to write something to the screen.


The function is running but there is a problem. I called this function, the event occurs 3 times in the target function.

I use it as follows.

Source code

1
WM_SetCallback(WM_HBKWIN, DrawFingerVals);


this is target function

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*********************************************************************
*
* DrawFingerVals
*/
static void DrawFingerVals(WM_MESSAGE * pMsg);
static void DrawFingerVals(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
  switch (pMsg->MsgId) { 
    case WM_PAINT:
      hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
      MULTIEDIT_AddText(hItem,write_buffer);
    break;
    default:
      WM_DefaultProc(pMsg);
    break;
  }
}


Every time I call the function, the same verb is written to the screen 3 times.

How can I solve this?

Thank You

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 438

2

Friday, December 8th 2017, 3:25pm

Hi,

AS the name of WM_PAINT suggests, this message is send if a window/widget/dialog should be drawn. Please do not call any other functions than those related to drawing. Setting properties (like MULTIEDIT_AddText()) or (in the worst case) creating windows or widgets within WM_PAINT can lead to unexpected behavior.

For example, if you are within WM_PAINT and set a text for a transparent widget, it gets invalidated. A transparent widget causes the background to be redrawn. If the text was set within WM_PAINT of the background window you will create an endless loop.

The reason why it gets called three times is the tiling algorithm of emWin. If a background of an opaque window gets drawn the area of the foreground window gets omitted. WM_PAINT of the background window gets called several times to draw the rectangles around the foreground window on by one.

Please refer to chapter 18.2.5 'Tiling mechanism' of the emWin user manual (UM03001_emWin5.pdf) for more information about the tiling mechanism.

Regards
Sven

FerhatYOL

Beginner

Date of registration: Nov 22nd 2017

Posts: 5

3

Saturday, December 9th 2017, 6:05pm

Thank you for the reply.

So How should it be?
I need the pMsg object for the WM_GetDialogItem function to work. But I don't know how to access this object in the main program. Could you show me an example in this regard?


Best Regards.