1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
function VirtualWinProc(Handle: THandle; uMsg: UINT; wParam: WPARAM;
lParam: LPARAM): LResult; stdcall;
{Returns the TDelphiTwain object}
function Obj: TDelphiTwain;
begin
Longint(Result) := GetWindowLong(Handle, GWL_USERDATA);
end {function};
var
Twain: TDelphiTwain;
i : Integer;
Msg : TMsg;
begin
{Tests for the message}
case uMsg of
{Creation of the window}
WM_CREATE:
{Stores the TDelphiTwain object handle}
with pCreateStruct(lParam)^ do
SetWindowLong(Handle, GWL_USERDATA, Longint(lpCreateParams));
{case} else
begin
{Try to obtain the current object pointer}
Twain := Obj;
if Assigned(Twain) then
{If there are sources loaded, we need to verify}
{this message}
if (Twain.SourcesLoaded > 0) then
begin
{Convert parameters to a TMsg}
Msg := MakeMsg(Handle, uMsg, wParam, lParam);
{Tell about this message}
FOR i := 0 TO Twain.SourceCount - 1 DO
if ((Twain.Source[i].Loaded) and (Twain.Source[i].Enabled)) then
if Twain.Source[i].ProcessMessage(Msg) then
begin
{Case this was a message from the source, there is}
{no need for the default procedure to process}
Result := 0;
Exit;
end;
end {if (Twain.SourcesLoaded > 0)}
end {case Else}
end {case uMsg of};
{Calls method to handle}
Result := DefWindowProc(Handle, uMsg, wParam, lParam);
end; |
Partager