PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Process inside EDGE lib messages

Hello!
I want to make my own MODAL dialog box. It made only from images (no standard controls). At PocketHAL I have used code construction like this:
Code:

bool isCanWork = win->Visible();
while(isCanWork)
{
...
MSG msg;
if (::PeekMessage( &msg;, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
Hide();
exit(0);
break;
}

::TranslateMessage( &msg; );
::DispatchMessage( &msg; );
}
else
GameLoop();

isCanWork = win->Visible();
}

At EDGE Lib (evaluation version) construction with PeekMessage doesn't works :(
Is there some another way to process inside messages of EDGELIB engine in my loop?
Is my question really hard or nobody knows how to do own modal windows that not based on standart controls?
Hi Maskin,

If you'd like to create your own windows controls, we recommend using the existing EDGELIB framework and window as a base. To handle window messages, implement the OnNativeEvent callback, as described here: http://www.edgelib.com/index.php?node=1146
He doesn't want to create a window control, he wants to control the message loop.
Kzinti wrote:He doesn't want to create a window control, he wants to control the message loop.

Exactly!
I shows part of my code as example of needed implementation.
I don't know why you want to control the message loop, but you could implement your loop in the first OnNextFrame call of the EDGELIB framework. Make sure to flip the display manually and include a few Sleep calls to make sure it doesn't use 100% of your processor.
edge wrote:I don't know why you want to control the message loop, but you could implement your loop in the first OnNextFrame call of the EDGELIB framework. Make sure to flip the display manually and include a few Sleep calls to make sure it doesn't use 100% of your processor.

I need control message loop to implement code. Code should execute on all platforms and implemented like modal MessageBox.
For example, is should make usage of my dialog box (let's name it like YesNoMessage) in sample code below:
Code:

void CheckUserAnswer()
{
if (!YesNoMessage("Bla-Bla-Bla"))
return;

// do something
}

I think, that construction with OnNativeEvent will be NOT works in my example.
Hi Maskin,

Can you tell me why OnNativeMessage wouldn't work? You could also directly use the window handle and message information when you are implementing your own message loop in OnNextFrame.
edge wrote:Hi Maskin,

Can you tell me why OnNativeMessage wouldn't work? You could also directly use the window handle and message information when you are implementing your own message loop in OnNextFrame.

As I see - we can't understand to each other :).
Can you give me example code how to implement your idea with OnNativeMessage in OnNextFrame with my "modal" window?
I wan't to see how that construction can I use for my task.
Hi Maskin,

Here is an example how to implement the OnNativeEvent callback:

Code:

bool ClassMain::OnNativeEvent(ENATIVETYPE winhandle, ENATIVETYPE msg, ENATIVETYPE param1, ENATIVETYPE param2)
{
#if defined(DEVICE_WIN32)
HWND hwnd = (HWND)winhandle;
UINT wmsg = (UINT)msg;
WPARAM wparam = (WPARAM)param1;
LPARAM wparam = (LPARAM)param1;
switch(wmsg)
{
//handle your messages here
default:
break;
}
return(false);
#else
return(false);
#endif
}


In the example above, you can safely typecast the window handle and parameters. The window handle can also be retrieved from the framework with the GetWindowHandle() function. This code may be suitable for your application, but if you really need to control the message loop you can paste your code directly into OnNextFrame:

Code:

bool isCanWork = true;
while(isCanWork)
{
MSG msg;
if (::PeekMessage( &msg;, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
Hide();
exit(0);
break;
}

::TranslateMessage( &msg; );
::DispatchMessage( &msg; );
}
else
{
GameLoop();
display->Flip();//You may need to call this function as well
}

isCanWork = win->Visible();
}


I hope this helps.