PocketMatrix forums

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

How to "maximize" EdgeLib

Hi all,

on windows mobile, I want to use the MessageBox Win32 function in one EdgeLib application. My code is below (it is just a test). On stylus down event, I display a message box. On OK I want to quit and on Cancel I want to resume.

Code:
void ClassMain::OnStylusDown(POINT pnt)
{
HWND hwnd = (HWND) GetWindowHandle ();
int msgboxID = MessageBox(hwnd,
(LPCWSTR)L"Voulez-vous vraiment quitter ?",
(LPCWSTR)L"",
MB_OKCANCEL);

switch (msgboxID)
{
case IDCANCEL:
break;
case IDOK:
Quit();
break;
}
}

My problem is that on Cancel, the EdgeLib window is no longer active. Of course it works if, in OnFrameworkConfig, I add:
Code:
config->focusminimize = false;

But I don't want to have this option false all the time. So do you know a solution to add in the IDCANCEL case to reactivate/maximize the EdgeLib window ?

I already tried SetForegroundWindow (hwnd), SendMessage (...) and PostMessage (...) without success.

Many thanks.
Hi again,

I found one way. I no longer modify the focusminimize attribute in the OnFrameworkConfig method. I modify it to false locally in the OnStylusDown method before the MessageBox call. And just after I modify it to true in the Cancel case. The code is below:

Code:
//Callback: Called when the user points the stylus down or clicks the left mouse button
void ClassMain::OnStylusDown(POINT pnt)
{
ecd.maincfg->focusminimize = false;

HWND hwnd = (HWND) GetWindowHandle ();
int msgboxID = MessageBox(hwnd,
(LPCWSTR)L"Voulez-vous vraiment quitter ?",
(LPCWSTR)L"",
MB_OKCANCEL);

switch (msgboxID)
{
case IDCANCEL:
ecd.maincfg->focusminimize = true;
break;
case IDOK:
Quit();
break;
}
}


Is it a good solution ?

Is there a better one ?

Many thanks.
Hi,

Your solutions works nicely. A minor improvement could be setting the focusminimize option to false just when the message box appears (instead after clicking a button).