Page 1 of 1

Window close

Posted: Mon Mar 13, 2006 7:45 am
by pawelu
Antonio,

This is simple two window app code. When button '>>' in main window is pressed next window is create, but when press 'OK' button in next window, which will close window, next window stay visible. Second press 'OK' button destroy window. Use 'OK' button in right upper window corner move window in background mode.

Regards
Pawel

Code: Select all

#Include 'FwCe.Ch'

Function TestClose ()

   Local oWnd := Nil

   Define Window oWnd Title 'Test Close'
   @ 100,  10 Say 'This is main window' Size 150, 15 Pixel
   @ 200, 178 Button '>>' Size 60, 20 Pixel Action IIf (NextWindow (), Nil, oWnd : End ())
   Activate Window oWnd On Init EmptyMenu (oWnd : hWnd)

Return .T.

Function NextWindow ()

   Local oWnd := Nil
   Local lRet := .F.

   Define Window oWnd Title 'Next Window'
   @ 100,  10 Say 'This is next window' Size 150, 15 Pixel
   @ 200, 178 Button 'OK' Size 60, 20 Pixel Action (lRet := .T., oWnd : End ())
   Activate Window oWnd On Init EmptyMenu (oWnd : hWnd)

Return lRet

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>
#include <uniqueid.h>
#include <objbase.h>

HB_FUNC (EMPTYMENU)
{
   SHINITDLGINFO shidi;
   HWND hWnd = (HWND) hb_parnl (1);
   SHMENUBARINFO mbi;

   shidi.dwMask  = SHIDIM_FLAGS;
   shidi.hDlg    = hWnd;
   shidi.dwFlags = SHIDIF_DONEBUTTON;
   SHInitDialog (&shidi);

   memset(&mbi, 0, sizeof (SHMENUBARINFO));
   mbi.cbSize = sizeof (SHMENUBARINFO);
   mbi.hwndParent = hWnd;
   mbi.dwFlags = SHCMBF_EMPTYBAR;
   SHCreateMenuBar (&mbi);

}

#pragma ENDDUMP

Posted: Mon Mar 13, 2006 9:32 am
by Antonio Linares
Pawel,

The button in the second window is somehow firing again the main window button action. It can be checked doing this:

Code: Select all

   @ 200, 178 Button oBtn PROMPT '>>' Size 60, 20 Pixel ;
      Action ( oBtn:bAction := nil, NextWindow() )
We are searching what may be the reason for this curious behavior. Thanks.

Posted: Mon Mar 13, 2006 10:16 am
by Antonio Linares
Pawel,

Fixed. It was a bug in Class TButton. Please download FWPPC again.

Thanks for your feedback,