Re: too many consecutive exceptions
From: Bernhard Mayer (mayerbernd_at_gmx.net)
Date: 07/26/04
- Next message: Bruce Roberts: "Re: Indexing common controls - e.g. : array of type TLabel"
- Previous message: Bruce Roberts: "Re: Max size on an exe?"
- In reply to: Bernhard Mayer: "Re: too many consecutive exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 26 Jul 2004 16:05:23 +0200
ok, i have found the bug and a workaround. it is a bug with dlls, forms and
the groupbox component.
the bug relays on the xp theme model. you can easily repoduce it by making
two new projects. first the main app and second the dll. just put a function
in the dll dpr like this:
function DllFormShow: Integer; stdcall;
var
form: TForm2;
begin
form := TForm2.Create(nil);
result := form.ShowModal;
FreeAndNil(form);
end;
now exports this function and import it in your main app and put a xpman on
it. place a button and call with it the DllFormShow function, thats all.
just compile and run, all work fine, till now. put a groupbox in your
dllform and recompile it and run. you will get a exception now. delete the
groupbox, all if fine.
the workaround comes from borland code central and is easily included. just
add two units to your uses in the dll dpr (themes and uxtheme). after
FreeAndNil place two new lines of code.
ThemeServices.ApplyThemeChange;
FreeThemeLibrary;
now with a groupbox in the dll form compile all and run, and it should work.
this can also be done in a separate function if that window is not modal.
that the must be exported too and called from the main app.
thx to code central :)
"Bernhard Mayer" <mayerbernd@gmx.net> schrieb im Newsbeitrag
news:2mhlr3Fn1f4cU1@uni-berlin.de...
> have something figured out. it depends on the d7 xp manifest! have started
a
> new and empty project. have include the unit with all external
declarations
> for my dlls, which is the same unit as used by the main app. drop a button
> and used the function to show my dll form. build and run, and it works
> without any error! a little bit wondering, but then i included the xpman
> component. rebuild and run. click the button close the window, exit the
app
> and the same error msg. deleted the xpman component from main app and the
> uses xpman. rebuilt and run. perfect!
>
> does any one know why?
>
>
> "Bernhard Mayer" <mayerbernd@gmx.net> schrieb im Newsbeitrag
> news:2mhjioFn4cppU1@uni-berlin.de...
> > it get an error message if i call the function from my dll to show
> > the form in that dll. too many consecutive exceptions...
> > any idea? the dll is static linked not dynamic.
> > dll code:
> >
> > library optionen;
> >
> > uses
> > {$IFDEF UseShareMem}
> > ShareMem,
> > {$ELSEIF UseFastShareMem}
> > FastShareMem,
> > {$IFEND}
> > {$IFDEF UseMemCheck}
> > MemCheck,
> > {$ENDIF}
> > Windows,
> > SysUtils,
> > Classes,
> > Forms,
> > einstellungen in 'einstellungen.pas' {foEinstellungen},
> > einstellungstypen in 'einstellungstypen.pas';
> >
> > {$R *.res}
> >
> > var
> > opt: TfoEinstellungen;
> >
> > procedure OptionenErzeugen(Parent: HWND); stdcall;
> > begin
> > Application.Handle := Parent;
> > opt := TfoEinstellungen.Create(nil);
> > opt.ShowModal;
> > opt.Free;
> > opt := nil;
> > Application.Handle := 0;
> > end;
> >
> > exports
> > OptionenErzeugen,
> > ReadOptions,
> > WriteOptions,
> > GlobalOptions;
> >
> > begin
> > {$IFDEF UseMemCheck}
> > MemChk;
> > {$ENDIF}
> > end.
> >
> > the readoptions procedure has no parameter and reads the settings from
> > registry in an record that exists in the dll form. writeoptions writes
> these
> > settings back to registry. globaloptions is an function that returns a
> > pointer
> > at the options record too the main app.
> > memcheck is known, maybe. but not set too be included. and by now i use
> > sharemem, because fastsharemem get some errors.
> >
> > the app function:
> >
> > procedure TfoMain.acProgrammEinstellungenExecute(Sender: TObject);
> > begin
> > OptionenErzeugen(Application.Handle);
> > TryToConnectDB;
> > end;
> >
> > procedure TfoMain.FormCreate(Sender: TObject);
> > begin
> > ReadOptions;
> > Optionen := GlobalOptions;
> > if not TryToConnectDB then
> > acProgrammEinstellungen.Execute;
> > end;
> >
> > the function trytoconnectdb simply sets the settings for the db
connection
> > and try to connect to it. there is no other access to the global options
> > variable.
> > and if i don't click the button to show the settings form in my dll, my
> app
> > closes without any error.
> >
> > any idea abot that?
> > thx
> >
> >
>
>
- Next message: Bruce Roberts: "Re: Indexing common controls - e.g. : array of type TLabel"
- Previous message: Bruce Roberts: "Re: Max size on an exe?"
- In reply to: Bernhard Mayer: "Re: too many consecutive exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]