Archived

This topic is now archived and is closed to further replies.

Design question (GUI)

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making my own gui framework in C(rendered with opengl). The way it works is pretty much like win32, each window has a window proc, etc. It''s going great except for one problem. To do a hit-test, I have a window message called WM_HITTEST. This is used in several functions, for instance WindowFromPoint. The problem is, if one of these functions are called from inside a WM_HITTEST callback, it enters an infinite loop and stack overflow quickly ensues. How can I solve this problem in an elegant way? Any tips/ideas are much appreciated, and remember this is with C, not C++. Thanks, Melekor

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Even the Windows API tells you not to change the focus in response to a set focus message. The same problem as yours will occur. It is up to the user to avoid these situations.

Share this post


Link to post
Share on other sites
hm, really? Where does it say that in the docs?
I tried the setfocus thing with win32 and it doesn''t make my app crash. I also tried sizing the window in response to a WM_SIZE message, and that didn''t crash it either. Obviously windows is somehow handling this problem, but I don''t know how.

Share this post


Link to post
Share on other sites
Bump. Can I get a second or third opinion? (even if only to confirm what the AP said)
Thanks.

edit: missing letter

[edited by - Melekor on May 19, 2004 5:56:56 PM]

Share this post


Link to post
Share on other sites
I am trying to design my own GUI right now but its probally not as advanced as yours ( or as pretty )

I have been infulenced much by the simplicity of java sctipt events applied to webpage objects and each of my gui objects must have a similar inter face.

Events include
OnLbuttonDown
OnLbuttonUp
OnMouseOver
etc...
These are the most common and usefull. I have a struct with a call back function and an argument so I can do something like this:

Button::OnLbuttonUp( point& p )
{
if( collide_with_button(p) )
{
m_ButtonUpCallBack.Call();
}
}


I dont have to worry about any infinate loop with the way I am designing it.

Mabe you send messages to the parent window and that causes an infinate loop. I dont need to send any messages. Sorry I couldnt be of more help. Mabe you could post some code.





gdipong

oglpong Online (43% complete)


If you got any requests or suggestions post here

[edited by - try_catch_this on May 19, 2004 6:30:03 PM]

Share this post


Link to post
Share on other sites
I''ve designed my own GUI as well and don''t quite follow the problem, having never faced and loops like this

. Is the problem that when an event occurs that causes another event the code loops?

Answer: Post new events to a seperate event list and handle them on the next iteration(frame etc)?

Thats if I read your problem properly...

Share this post


Link to post
Share on other sites