Re: SetWindowPos unhandled exception only in release system

Tech-Archive recommends: Fix windows errors by optimizing your registry



put a try catch block around the code and see what the exception is


try
{
CRect ParentRect;
GetParent()->GetClientRect (&ParentRect);

CRect OurRect;
GetClientRect (&OurRect);

// compute position for this window

int Column = (m_Number - 1) % MAX_COLUMNS;
int Row = (m_Number - 1) / MAX_COLUMNS;

int xOffset = X_OFFSET_START + (Column * (OurRect.Width() +
COLUMN_SPACE));
int yOffset = Y_OFFSET_START + (Row * (OurRect.Height() +
ROW_SPACE));

SetWindowPos(GetParent(),
ParentRect.left + xOffset,
ParentRect.top + yOffset,
0, 0, // ignores size arguments
SWP_NOSIZE | SWP_NOZORDER);
}
catch (CException *E)
{
E->ReportError();
}

AliR.

"NYC Lou" <louseitchikorders@xxxxxxxxxxxxx> wrote in message
news:1141785531.891768.148170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a class derived from CDialog. In its OnInitDialog(), I call
SetWindowPos() as shown below. Under debug, it works fine. In the
release version, I get an unhandled exception access violation in
MFC42.DLL.

Any ideas?

Thanks so much.

BOOL CDlgPortStatus::OnInitDialog()
{
CDialog::OnInitDialog();

// place the window based on its number

CRect ParentRect;
GetParent()->GetClientRect (&ParentRect);

CRect OurRect;
GetClientRect (&OurRect);

// compute position for this window

int Column = (m_Number - 1) % MAX_COLUMNS;
int Row = (m_Number - 1) / MAX_COLUMNS;

int xOffset = X_OFFSET_START + (Column * (OurRect.Width() +
COLUMN_SPACE));
int yOffset = Y_OFFSET_START + (Row * (OurRect.Height() +
ROW_SPACE));

SetWindowPos(GetParent(),
ParentRect.left + xOffset,
ParentRect.top + yOffset,
0, 0, // ignores size arguments
SWP_NOSIZE | SWP_NOZORDER);



.



Relevant Pages

  • Re: SetWindowPos unhandled exception only in release system
    ... Just give NULL for the first parameter and try. ... ParentRect.left + xOffset, ... ParentRect.top + yOffset, ... // place the window based on its number ...
    (microsoft.public.vc.mfc)
  • Re: 64b Windows - crashes not detected
    ... // call testMe on the NULL Pointer ... Crash is right there at 01112528. ... First-chance exception at 0x01112528 in crashTest.exe: 0xC0000005: ... in the output window. ...
    (microsoft.public.vc.mfc)
  • Re: Child Window Creation
    ... What this boils down to is that you cannot create a window in PreSubclassWindow if it is ... create the child controls in PreSubclassWindow. ... try/catch will not catch this because it is not an MFC exception or C++ ...
    (microsoft.public.vc.mfc)
  • Re: CWnd::CreateEx fails with GetLastError 0
    ... I didnt mean that SDK CreateEx is throwing exception. ... all the window handles, and all that happened was CreateEx returned FALSE. ... Can this error be due to parent window process OR it is due to child window ...
    (microsoft.public.vc.mfc)
  • Re: Child Window Creation
    ... of the window looks like a valid value, it cannot be used as the parent to ... create the child controls in PreSubclassWindow. ... try/catch will not catch this because it is not an MFC exception or C++ ...
    (microsoft.public.vc.mfc)