Thread View: borland.public.delphi.rtl
4 messages
4 total messages
Started by Ivan Petrovic
Mon, 21 Jan 2002 20:02
BUG: TListView
Author: Ivan Petrovic
Date: Mon, 21 Jan 2002 20:02
Date: Mon, 21 Jan 2002 20:02
74 lines
3511 bytes
3511 bytes
Hello,
There is a strange bug connected with OnItemActivate event with
TListView component... Let say you have this code associated with
OnItemActivate event on ListView1 component (it starts NOTEPAD.EXE and waits
until NOTEPAD.EXE is terminated).
// BEGIN OF CODE
procedure TForm1.dfsExtListView1ItemActivate(Sender: TObject);
function InstExec (const Filename, Params: String; WorkingDir: String;
const WaitUntilTerminated, WaitUntilIdle, RunMinimized: Boolean;
const ProcessMessagesProc: TProcedure): Boolean;
var
CmdLine: String;
WorkingDirP: PChar;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
Result := True;
CmdLine := {$IFDEF WIN32}'"'+{$ENDIF}Filename{$IFDEF WIN32}+'"'{$ENDIF}
+ ' ' + Params {$IFNDEF WIN32} + #0 {needs null terminator for Delphi 1}
{$ENDIF};
FillChar (StartupInfo, SizeOf(StartupInfo), 0);
StartupInfo.cb := SizeOf(StartupInfo);
if RunMinimized then begin
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_SHOWMINIMIZED;
end;
if WorkingDir '' then WorkingDirP := PChar(WorkingDir)
else WorkingDirP := nil;
if not CreateProcess(nil, PChar(CmdLine), nil, nil, False, 0, nil,
WorkingDirP, StartupInfo, ProcessInfo) then begin
Result := False; Exit;
end;
with ProcessInfo do begin
CloseHandle (hThread);
if WaitUntilIdle then
WaitForInputIdle (hProcess, INFINITE);
if WaitUntilTerminated then
repeat
application.processmessages;
until MsgWaitForMultipleObjects(1, hProcess, False, INFINITE,
QS_ALLINPUT) WAIT_OBJECT_0+1;
CloseHandle (hProcess);
end;
end;
begin
instexec('c:\windows\notepad.exe','c:\test.txt','c:\',true,true,false,nil,i)
;
end;
// END OF CODE
Now run the application, and double click on any item (to start this
event). Notepad will start, but we cannot do anything with ListView in the
application any more (it's halted) until NOTEPAD is terminated.
If we use ENTER key to open selected item (instead of double click),
everything works fine and we can use application and ListView component even
if NOTEPAD is still active.
Credits and free licenses of PowerArchiver for anyone who finds a
solution...
Thanks.
Ivan Petrovic
ConeXware, Inc.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
email: ivan@powerarchiver.com
web : http://www.powerarchiver.com
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Re: TListView
Author: Steve Trefethen (Borland)
Date: Tue, 22 Jan 2002 00:21
Date: Tue, 22 Jan 2002 00:21
13 lines
1462 bytes
1462 bytes
Hi Ivan, A simple workaround which I bet would work would be to use PostMessage and send your form a custom message indicating it needs to execute the code you specified. -- -Steve Delphi/C++ Builder R&D Borland Software Corporation Please, no private email, unless specifically invited in this message, thank you. http://www.geocities.com/delphihelp Have you tried searching http://groups.google.com first?
Re: TListView
Author: Ivan Petrovic
Date: Tue, 22 Jan 2002 08:05
Date: Tue, 22 Jan 2002 08:05
4 lines
1157 bytes
1157 bytes
Can you do example of it? It's very important... You will get credit and free licenses of PowerArchiver... Ivan
Re: TListView
Author: Steve Trefethen (Borland)
Date: Tue, 22 Jan 2002 20:29
Date: Tue, 22 Jan 2002 20:29
36 lines
1992 bytes
1992 bytes
Declare: const CM_MYMessage = CM_BASE + 1; Add a method to your form that does the work from your previous message: procedure CustomMessage(var Msg: TMessage); message CM_MYMessage; Then in place of the code you posted previously simply call: PostMessage(Form.Handle, CM_MyMessage, 0, 0); You can also refer to the Object Pascal Language reference for more information on implementing "message methods" which is what these are called. -- -Steve Delphi/C++ Builder R&D Borland Software Corporation Please, no private email, unless specifically invited in this message, thank you. http://www.geocities.com/delphihelp Have you tried searching http://groups.google.com first? "Ivan Petrovic" <ivan@powerarchiver.com> wrote in message news:3c4d1dfe_1@dnews... > Can you do example of it? It's very important... You will get credit and > free licenses of PowerArchiver... > > Ivan > > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads