Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modal window Close on Xp doesn’t work if network have problem

Status
Not open for further replies.

Stanislava

Programmer
Jun 23, 2005
2
0
0
AT
Hi!
If pc have some short network problems, window Close of a modal window doesn’t work on Windows Xp (on Windows 2000 it works fine).

I run my application on WindowsXp. The application opens from one window with ShowModal() another one. On Click event in a modal window, application does some network activites (Datebase or File access) and finally close the modal window.

If computer have some short network problems before user Clicks a button, and user clicks in the window again after network problems disapper, it doesn’t get any exception, application do network activites sucessfully, call Close() of the modal window (I ‘am quite sure about it because I log it), but modal window doesn’t close realy and also doesn’t react on all events ???? My work around in the moment is to set a compatibility mode to Windows 2000 but I don’t feel well with it becase that shoud be a Windows Xp application. Any ideas ?

Thanks for any help.
 
I've never had any problems with modal vs. non-modal windows on XP. Can you show us the code you use to open and close the windows?


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Hi!
Here is my code:
project files : SimpleWinClose.*
main window files : TMainWinFile1.*
modal window files : TModalWinFile1.*
To simulate some network activities I create and delete some files on network disk L:.
To simulate work with network problems I pull out network cable, click a button, wait for a few seconds, pull cable again in and click in the window again.

SimpleWinClose.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("TMainWin1File.cpp", MainWin1);
USEFORM("tModalWin1File.cpp", ModalWin1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TMainWin1), &MainWin1);
Application->CreateForm(__classid(TModalWin1), &ModalWin1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------



SimpleWinClose.bpr
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.06.00"/>
<PROJECT value="SimpleWinClose.exe"/>
<OBJFILES value="SimpleWinClose.obj TMainWin1File.obj tModalWin1File.obj"/>
<RESFILES value="SimpleWinClose.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES) TMainWin1File.dfm tModalWin1File.dfm"/>
<LIBFILES value=""/>
<LIBRARIES value=""/>
<SPARELIBS value="vcl.lib rtl.lib"/>
<PACKAGES value="vcl.bpi rtl.bpi dbrtl.bpi adortl.bpi vcldb.bpi vclx.bpi bdertl.bpi
vcldbx.bpi ibxpress.bpi dsnap.bpi cds.bpi bdecds.bpi qrpt.bpi teeui.bpi
teedb.bpi tee.bpi dss.bpi teeqr.bpi visualclx.bpi visualdbclx.bpi
dsnapcrba.bpi dsnapcon.bpi bcbsmp.bpi vclie.bpi xmlrtl.bpi inet.bpi
inetdbbde.bpi inetdbxpress.bpi inetdb.bpi nmfast.bpi webdsnap.bpi
bcbie.bpi websnap.bpi soaprtl.bpi dclocx.bpi dbexpress.bpi dbxcds.bpi
indy.bpi bcb2kaxserver.bpi"/>
<PATHCPP value=".;"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="ilink32"/>
<USERDEFINES value="_DEBUG"/>
<SYSDEFINES value="_RTLDLL;NO_STRICT;USEPACKAGES"/>
<MAINSOURCE value="SimpleWinClose.cpp"/>
<INCLUDEPATH value="$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH value="$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
<OTHERFILES value=""/>
</MACROS>
<OPTIONS>
<IDLCFLAGS value="-I$(BCB)\include -I$(BCB)\include\vcl -src_suffix cpp -D_DEBUG -boa"/>
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl60.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c
-tW -tWM"/>
<PFLAGS value="-$YD -$W -$O- -$A8 -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zd"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn -v"/>
<OTHERFILES value=""/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0w32.obj $(PACKAGES) Memmgr.Lib sysinit.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib"/>
<OTHERFILES value=""/>
</LINKER>
<FILELIST>
<FILE FILENAME="SimpleWinClose.res" FORMNAME="" UNITNAME="SimpleWinClose.res" CONTAINERID="ResTool" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="SimpleWinClose.cpp" FORMNAME="" UNITNAME="SimpleWinClose" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="TMainWin1File.cpp" FORMNAME="MainWin1" UNITNAME="TMainWin1File" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="tModalWin1File.cpp" FORMNAME="ModalWin1" UNITNAME="tModalWin1File" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
</FILELIST>
<BUILDTOOLS>
</BUILDTOOLS>

<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=3079
CodePage=1252

[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=

[HistoryLists\hlIncludePath]
Count=1
Item0=$(BCB)\include;$(BCB)\include\vcl

[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib

[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl

[HistoryLists\hlConditionals]
Count=1
Item0=_DEBUG

[Debugging]
DebugSourceDirs=$(BCB)\source\vcl

[Parameters]
RunParams=
Launcher=
UseLauncher=0
DebugCWD=
HostApplication=
RemoteHost=
RemotePath=
RemoteLauncher=
RemoteCWD=
RemoteDebug=0

[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0

[CORBA]
AddServerUnit=1
AddClientUnit=1
PrecompiledHeaders=1

[Language]
ActiveLang=
ProjectLang=
RootDir=
</IDEOPTIONS>
</PROJECT>



TMainWin1File.h
//---------------------------------------------------------------------------

#ifndef TMainWin1FileH
#define TMainWin1FileH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TMainWin1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TButton *OpenModal;
void __fastcall OpenModalClick(TObject *Sender);
private: // Anwender-Deklarationen
public: // Anwender-Deklarationen
__fastcall TMainWin1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainWin1 *MainWin1;
//---------------------------------------------------------------------------
#endif



TMainWin1File.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TMainWin1File.h"
#include "TModalWin1File.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainWin1 *MainWin1;
//---------------------------------------------------------------------------
__fastcall TMainWin1::TMainWin1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainWin1::OpenModalClick(TObject *Sender)
{
ModalWin1->ShowModal();
}
//---------------------------------------------------------------------------



TMainWin1File.dfm
--------------------------
object MainWin1: TMainWin1
Left = 192
Top = 114
Width = 696
Height = 480
Caption = 'MainWin1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object OpenModal: TButton
Left = 112
Top = 304
Width = 75
Height = 25
Caption = 'OpenModal'
TabOrder = 0
OnClick = OpenModalClick
end
end



tModalWin1File.h
//---------------------------------------------------------------------------

#ifndef tModalWin1FileH
#define tModalWin1FileH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TModalWin1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TButton *NetworkAndClose;
void __fastcall NetworkAndCloseClick(TObject *Sender);
private: // Anwender-Deklarationen
public: // Anwender-Deklarationen
__fastcall TModalWin1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TModalWin1 *ModalWin1;
//---------------------------------------------------------------------------
#endif



tModalWin1File.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "tModalWin1File.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TModalWin1 *ModalWin1;
//---------------------------------------------------------------------------
__fastcall TModalWin1::TModalWin1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TModalWin1::NetworkAndCloseClick(TObject *Sender)
{
AnsiString fileName;
int fh = 0; // filehandle
int anz = 50 ;
for (int i =1; i<anz;i++)
{
fileName = "L:\SimplWinCloseFile" + AnsiString(i).Trim()+".log" ;
if ( !FileExists(fileName) )
{
fh = FileCreate(fileName);
FileClose(fh);
}
}

for (int i =1; i<anz;i++)
{
fileName = "L:\SimplWinCloseFile" + AnsiString(i).Trim()+".log" ;
if ( FileExists(fileName) )
{
DeleteFile(fileName);
}
}
Close();

}
//---------------------------------------------------------------------------



tModalWin1File.dfm
object ModalWin1: TModalWin1
Left = 192
Top = 114
Width = 696
Height = 480
Caption = 'ModalWin1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object NetworkAndClose: TButton
Left = 464
Top = 160
Width = 139
Height = 25
Caption = 'NetworkAndClose'
TabOrder = 0
OnClick = NetworkAndCloseClick
end
end

 
the problem is the network stuff.
not the windows open and close stuff.

your problem occurs because your
network code is locking up looking
for something and it wont go away until
you do some error checking. expect
the network problems and write your code
to handle it.

tomcruz.net

ps
cpp is adequate for the response.
the bpr or dfm is not necessary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top