warning C28183: 'HWND_FG' could be '0', and is a copy of the value found in 'HWND_PP':...

  • Thread starter Thread starter Chuckie72
  • Start date Start date
C

Chuckie72

Guest
Here is another interesting issue. My code:

void CChristianLifeMinistryHtmlView::DoPrintPreview()
{
HWND HWND_PP, HWND_FG ;
TCHAR szClassName[256] ;
ULONGLONG t1, t2 ;
RECT workArea;

ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER, NULL, NULL);

HWND_PP = NULL ;
t1 = ::GetTickCount64();
t2 = ::GetTickCount64(); // Extra line required for while rearrangement.
while (HWND_PP == NULL && t2 - t1 <= 6000) // if found or Timeout reached...
{
HWND_FG = ::GetForegroundWindow(); // Get the ForeGroundWindow
::GetClassName(HWND_FG, szClassName, 256 );
if (lstrcmp(szClassName, IE_PPREVIEWCLASS) == 0) // Check for Print Preview Dialog
HWND_PP = HWND_FG ;

theApp.PumpMessage();
t2 = ::GetTickCount64();
}

if (HWND_PP != NULL)
{
// AJT V3.01 BUG Fix - showing maximized crops bottom of preview dialog
::SystemParametersInfo( SPI_GETWORKAREA, 0, &workArea, 0 );
::MoveWindow(HWND_PP, workArea.left, workArea.top,
workArea.right - workArea.left, workArea.bottom - workArea.top, TRUE);

}

}

The code analysis warning this time is:

warning C28183: HWND_FG could be 0, and is a copy of the value found in HWND_PP: this does not adhere to the specification for the function GetClassNameW.

It mentions two things there. But, for the first one, according to the documentation it states:

The return value is a handle to the foreground window. The foreground window can be NULL in certain circumstances, such as when a window is losing activation.

So I assume that NULL is going to be OK in some instances. And I confess I am unsure about the second part of the warning and why it is raised as an issue. My HTML View works. But if this can be fixed I am interested in learning what to do.

Thanks.

Continue reading...
 
Back
Top