Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Layout and Paint event processing
Layout and Paint event processing [message #14313] Fri, 22 February 2008 12:08 Go to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hi,

I have a problem with attached program, in which I overwrite a ctrl Paint method as well as its Layout method.
What I am trying to achieve is that when the TopWindow is resized I process the Layout event first and afterwords the Paint event.
But this is only working as expected if I call Layout function explicitly inside Paint function.

So my question is: What is the event sequence?

Example package is attached.

WinXP, Mingw 3.4.2

Matthias
Re: Layout and Paint event processing [message #14314 is a reply to message #14313] Fri, 22 February 2008 12:56 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Your example works perfectly (MSVC). Layout is called, followed by GLPaint, so I'm not sure what the problem is?
Re: Layout and Paint event processing [message #14315 is a reply to message #14314] Fri, 22 February 2008 13:06 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Are you able to see the points, 'cause I only see the black background?

Matthias
Re: Layout and Paint event processing [message #14316 is a reply to message #14315] Fri, 22 February 2008 13:39 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
You are right I Use MSVC too, but can't see dots unless I de-comment the Layout() line in the GLPaint in your example

In Win32GLCtrl.cpp, line 92:
LRESULT GLCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if(message == WM_PAINT && hDC && hRC) {
		wglMakeCurrent(hDC, hRC);
		GLPaint();
		SwapBuffers(hDC);
		wglMakeCurrent(NULL, NULL);
		PAINTSTRUCT ps;
		BeginPaint(GetHWND(), &ps);
		EndPaint(GetHWND(), &ps);
		return 0;
	}
	return DHCtrl::WindowProc(message, wParam, lParam);
}


It seems that Layout() is called AFTER GLPaint(). I'm not sure if this is intentional or a bug.


[Updated on: Fri, 22 February 2008 13:47]

Report message to a moderator

Re: Layout and Paint event processing [message #14317 is a reply to message #14316] Fri, 22 February 2008 13:51 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Sorry, my mistake.

The problem is that the rendering context isn't being made current before Layout is called, so your projection matrix calls have no effect.

If you change it like so:
void Layout()
{
    wglMakeCurrent(GLCtrl::GetDC(), GLCtrl::GetHGLRC());

    ....Projection stuff

    wglMakeCurrent(NULL, NULL);
}

it almost fixes the problem, but you need to force a call to Layout AFTER the window has openned as well (Layout is normally called before). So add the following function:
void State(int reason) 
{
    GLCtrl::State(reason);
    Layout();
}


This should really all be done by GLCtrl (with a GLLayout function).

James
Re: Layout and Paint event processing [message #14332 is a reply to message #14317] Fri, 22 February 2008 16:53 Go to previous message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Thank you both, I have modified GLCtrl to switch context before calling Layout and also to call Layout after Open.

Matthias
Previous Topic: Key in DropList cannot be same
Next Topic: window resized has no CALLBACK?
Goto Forum:
  


Current Time: Sun Apr 28 05:33:08 CEST 2024

Total time taken to generate the page: 0.05502 seconds