Friday, October 20th 2017, 11:24pm UTC+2

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.

ScaleMan

Beginner

Date of registration: May 14th 2014

Posts: 9

1

Thursday, June 19th 2014, 1:59am

Cannot execute line drawing functions in any other window other than the Desktop Window.

Hello,

I am simulating an EMWIN application using Visual Studio using a 320x240 display.

I am having trouble with line drawing functions.
I can only get line drawing functions to work in the default desktop window.

In the example below I create a second window. I try and draw a diagonal line across the window. All drawing actions are drawing on the default window below, as expected.

Example 1 below draws a line on the main Desktop window underneath that new window as expected.


// create a blank window
hWindow = WINDOW_CreateEx(10,10,300,180, WM_HBKWIN, WM_CF_SHOW,0,100,NULL);


GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
GUI_SetColor(GUI_RED);
GUI_DrawLine(0,0 ,320,240 );


Example 2 Try and draw a diagonal line in the new window defined in example 1

// create a blank window
hWindow = WINDOW_CreateEx(10,10,300,180, WM_HBKWIN, WM_CF_SHOW,0,100,NULL);
WM_SelectWindow(hWindow);


GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
GUI_SetColor(GUI_RED);
GUI_DrawLine(0,0 ,320,240 );



This results in no drawing activity in the desktop window, and no line drawing at all in the new Window.

So what am I doing wrong?

Thanks you.

This post has been edited 1 times, last edit by "ScaleMan" (Jun 19th 2014, 2:04am)


ScaleMan

Beginner

Date of registration: May 14th 2014

Posts: 9

2

Thursday, June 19th 2014, 5:59pm

I understand what I am doing wrong.
Reading through the manual again I discovered I am declaring the window as a widget by using the WINDOW_CreateEX function.
Even though it is a window per say, it is a widget, and you cannot set this window as an active window for drawing.

Using the WM_CreateWindow function will create a window where drawing functions can be executed right away.

Using WINDOW_CreateEX, drawing functions are executed using WMcallback doing all drawing on WM_PAINT.



Thanks again.

SM.

This post has been edited 5 times, last edit by "ScaleMan" (Jun 20th 2014, 2:07am)


SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 994

3

Tuesday, July 1st 2014, 11:14am

Hello ScaleMan,

Please note that the intended and recommended way to perform drawing operations is to react to the WM_PAINT message in the according callback function. No matter which kind of window should be used.

Please find details on how to create a custom callback function in the chapter "The Window Manager" in the emWin user manual.

Best regards,
Adrian