MoveWindow API causes the "A problem has occurred with gwes.exe" error for me
under the both PPC WM50 Emulator and real device. At the same time the
MoveWindow changes the target window size as it should to and it looks like
everything works ok except of the gwes error popped. The parameters passed to
the MoveWindow looks like correct. Below is a cut from source code:

-------------------------------------------------------------------------------------------
SHMENUBARINFO mbi;
RECT rc, rcMenuBar;

// Create the window
const TCHAR* name = _T("Dummy");
hwndMainFrame = CreateWindow((const TCHAR*)mainFrameClass.classAtom, name,
//WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
WS_MINIMIZEBOX,
WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
mainFrameClass.instance, this);
if (!hwndMainFrame)
{
throw rdr::SystemException("unable to create MainClient window
instance", GetLastError());
}

memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwndMainFrame;
mbi.nToolBarId = IDR_MENU;
mbi.hInstRes = ::GetModuleHandle(NULL);

if (!::SHCreateMenuBar(&mbi))
{
throw rdr::SystemException("unable to create menu bar", GetLastError());
}
m_hMenu = mbi.hwndMB;
::ShowWindow(m_hMenu, SW_HIDE);
::ShowWindow(hwndMainFrame, SW_HIDE);

GetWindowRect(hwndMainFrame, &rc);
GetWindowRect(m_hMenu, &rcMenuBar);
rc.bottom -= (rcMenuBar.bottom - rcMenuBar.top);

// The following MoveWindow caused the gwes error !!!!!!!!!!!!!!!!!!!!
::MoveWindow(hwndMainFrame, rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
FALSE)
------------------------------------------------------------------------------------------

Once the MoveWindow is commented out everything works with no errors.

Visual Studio Debugger doesn't stop when the error is popping. The
Application Verifier gives nothing regarding the error.

Is there any way to fix the problem, please?


Many thanks.

Re: MoveWindow causes problems under WM50 by r_z_aret

r_z_aret
Sat Dec 01 12:27:06 PST 2007

On Fri, 30 Nov 2007 01:15:00 -0800, Experienced Friar
<ExperiencedFriar@discussions.microsoft.com> wrote:

>MoveWindow API causes the "A problem has occurred with gwes.exe" error for me
>under the both PPC WM50 Emulator and real device.

I use MoveWindow a lot in programs that run under WM 5. So the problem
isn't MoveWindow itself.


> At the same time the
>MoveWindow changes the target window size as it should to and it looks like
>everything works ok except of the gwes error popped. The parameters passed to
>the MoveWindow looks like correct. Below is a cut from source code:
>
>-------------------------------------------------------------------------------------------
> SHMENUBARINFO mbi;
> RECT rc, rcMenuBar;
>
> // Create the window
> const TCHAR* name = _T("Dummy");
> hwndMainFrame = CreateWindow((const TCHAR*)mainFrameClass.classAtom, name,

I gather mainFrameClass is a C++ object, but don't see info about it.
I suspect this cast does _not_ properly translate from ASCII to TCHAR.
I know that such casts are usually very bad because they don't
translate. If I am right and you don't understand what I just said, I
_strongly_ recommend taking time to learn about UNICODE and related
issues. Otherwise you will waste a lot of your time. You can start by
using google (http://groups.google.com/advanced_group_search) to look
up
unicode
in this newsgroup.


> //WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
>WS_MINIMIZEBOX,
> WS_SYSMENU,
> CW_USEDEFAULT, CW_USEDEFAULT,
> CW_USEDEFAULT, CW_USEDEFAULT,
> NULL, NULL,
> mainFrameClass.instance, this);
> if (!hwndMainFrame)
> {
> throw rdr::SystemException("unable to create MainClient window
>instance", GetLastError());
> }
>
> memset(&mbi, 0, sizeof(SHMENUBARINFO));
> mbi.cbSize = sizeof(SHMENUBARINFO);
> mbi.hwndParent = hwndMainFrame;
> mbi.nToolBarId = IDR_MENU;
> mbi.hInstRes = ::GetModuleHandle(NULL);
>
> if (!::SHCreateMenuBar(&mbi))
> {
> throw rdr::SystemException("unable to create menu bar", GetLastError());
> }
> m_hMenu = mbi.hwndMB;
> ::ShowWindow(m_hMenu, SW_HIDE);
> ::ShowWindow(hwndMainFrame, SW_HIDE);
>
> GetWindowRect(hwndMainFrame, &rc);
> GetWindowRect(m_hMenu, &rcMenuBar);
> rc.bottom -= (rcMenuBar.bottom - rcMenuBar.top);

Is this an attempt to position the main window relative to the menu?

>
> // The following MoveWindow caused the gwes error !!!!!!!!!!!!!!!!!!!!
> ::MoveWindow(hwndMainFrame, rc.left, rc.top,
> rc.right - rc.left,
> rc.bottom - rc.top,
> FALSE);

I'm suspicious about the new coordinates you're trying to set, and
don't have the patience to work through your code. Are you mixing
coordinates relative to the screen (used with MoveWindow for top-level
windows) and coordinates relative to the owner (used with child
windows)?


>------------------------------------------------------------------------------------------
>
>Once the MoveWindow is commented out everything works with no errors.
>
>Visual Studio Debugger doesn't stop when the error is popping. The
>Application Verifier gives nothing regarding the error.
>
>Is there any way to fix the problem, please?
>
>
>Many thanks.
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com