neame
asked on
WinProc & Delphi2
I hope someone can help me....
The following are code snipits from an application I am trying
to get running. I've run it using straight windows API calls but
now need to run it from a Delphi2 application. The function
TfrmMain.InitDigitizingArm starts a backgound
process that sends messages to the function WindowProc in straight
windows API programming. What is the equivalent in Delphi? In Delphi2
will it send the data to the
frmMain.WMCommand? Is my application.handle correct (frmMain.Handle vs
Application.Handle)? I'm sure I've overlooked something simple.
Any help is surely appreciated. Thanks in advance.
Jeff Jolie
Shaken, not stirred.
public
{ Public declarations }
Password : string ;
procedure WMCommand(var Message:TMessage); message wm_Command;
procedure TfrmMain.WMCommand(var Message: TMessage);
var
a : parm_rec;
begin
inherited;
New(a);
if Message.WParam = armMessageVal then
begin
a := pArmGetArmRec;// @LParam;
// more processing here
end;
end;
/// This function called during frmMain create
function TfrmMain.InitDigitizingArm : boolean;
begin
armMessageVal := RegisterWindowMessage(ARM_ MESSAGE);
hLib := LoadLibrary('Armdll32.dll' );
pArmStart := GetProcAddress(hLib,'ArmSt art');
pArmConnect := GetProcAddress(hLib,'ArmCo nnect');
pArmSetBckgUpdate := GetProcAddress(hLib,'ArmSe tBckgUpdat e');
pArmGetArmRec := GetProcAddress(hLib,'ArmGe tArmRec');
...this handle is key....
status := pArmStart(frmMain.Handle); // tried Application.Handle with
no luck
Result := True;
if( status <> ARM_SUCCESS ) then
begin
MessageBox(0,'Can not start ArmStart','ArmStart Error',mb_ok);
Result := False;
Exit;
end
else
begin
status := pArmConnect(2,9600);
if ( status = ARM_SUCCESS ) then
begin
status := pArmSetBckgUpdate(ARM_3DOF ); // this should send
messages to frmMain.WMCommand, but doesn't
if ( status <> ARM_SUCCESS ) then
begin
MessageBox(0,'Can not set bkgnd update.','BkgndUpdate
Error',mb_ok);
Result := False;
Exit;
end;
end
else
begin
MessageBox(0,'Arm Connect Error.','ArmConnect Error',mb_ok);
Result := False;
Exit;
end;
end;
end;
The following are code snipits from an application I am trying
to get running. I've run it using straight windows API calls but
now need to run it from a Delphi2 application. The function
TfrmMain.InitDigitizingArm
process that sends messages to the function WindowProc in straight
windows API programming. What is the equivalent in Delphi? In Delphi2
will it send the data to the
frmMain.WMCommand? Is my application.handle correct (frmMain.Handle vs
Application.Handle)? I'm sure I've overlooked something simple.
Any help is surely appreciated. Thanks in advance.
Jeff Jolie
Shaken, not stirred.
public
{ Public declarations }
Password : string ;
procedure WMCommand(var Message:TMessage); message wm_Command;
procedure TfrmMain.WMCommand(var Message: TMessage);
var
a : parm_rec;
begin
inherited;
New(a);
if Message.WParam = armMessageVal then
begin
a := pArmGetArmRec;// @LParam;
// more processing here
end;
end;
/// This function called during frmMain create
function TfrmMain.InitDigitizingArm
begin
armMessageVal := RegisterWindowMessage(ARM_
hLib := LoadLibrary('Armdll32.dll'
pArmStart := GetProcAddress(hLib,'ArmSt
pArmConnect := GetProcAddress(hLib,'ArmCo
pArmSetBckgUpdate := GetProcAddress(hLib,'ArmSe
pArmGetArmRec := GetProcAddress(hLib,'ArmGe
...this handle is key....
status := pArmStart(frmMain.Handle);
no luck
Result := True;
if( status <> ARM_SUCCESS ) then
begin
MessageBox(0,'Can not start ArmStart','ArmStart Error',mb_ok);
Result := False;
Exit;
end
else
begin
status := pArmConnect(2,9600);
if ( status = ARM_SUCCESS ) then
begin
status := pArmSetBckgUpdate(ARM_3DOF
messages to frmMain.WMCommand, but doesn't
if ( status <> ARM_SUCCESS ) then
begin
MessageBox(0,'Can not set bkgnd update.','BkgndUpdate
Error',mb_ok);
Result := False;
Exit;
end;
end
else
begin
MessageBox(0,'Arm Connect Error.','ArmConnect Error',mb_ok);
Result := False;
Exit;
end;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I solved the problem myself while waiting for the answer. Sperlings answer was correct. Thanks.
Jeff Jolie
Jeff Jolie
You should use TFrmMain.Handle. If you use Application.Handle, you need to obtain the message using Application.HookMainWindow
Regards,
Erik.