Вверх ↑
Разработчик
Ответов: 26151
Рейтинг: 2127
#1: 2008-01-20 22:44:40 ЛС | профиль | цитата
Galkov писал(а):
Кстати, о "прекрасности": если прописать неполный путь (например "Int\logo.jpg") и все честно благородно "крякает"

Ха! Действительно. Значит FileExists прпускает такое имя, а функция не понимает, ориинально? И какие булут предложения по защите от "дурака"?

------------ Дoбавленo:


Galkov писал(а):
Доказательства



Add(MainForm,7649955,294,238)
{
Left=10
Top=10
Ctl3D=0
Position=1
Point(onPaint)
Point(Handle)
link(onCreate,12423105:doData,[])
}
Add(InlineCode,4633675,483,252)
{
WorkPoints=#6:doLoad|9:doStretch|
DataPoints=#8:FileName|6:Bitmap|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|56:uses Windows,Messages,Share,Debug,ActiveX,KOLComObj,KOL;|0:|4:type|32: IImgCtx = interface(IUnknown)|48: ['{3050f3d7-98b5-11cf-bb82-00aa00bdce0b}']|40: // Initialization/Download methods|68: function Load(pszUrl:PWChar; dwFlags:DWORD): HResult; stdcall;|93: function SelectChanges(ulChgOn:DWORD; ulChgOff:DWORD; fSignal:DWORD): HResult; stdcall;|83: function SetCallback(pCallback:pointer; pUserData:pointer): HResult; stdcall;|44: function Disconnect: HResult; stdcall;|0:|22: // Query methods|95: function GetUpdateRects(prc:PRect; var prcImg:TRect; var pcrc:integer): HResult; stdcall;|104: function GetStateInfo(var pulState:DWORD; var pSize:TSize; fClearChanges:DWORD): HResult; stdcall;|64: function GetPalette(var phpal:HPalette): HResult; stdcall;|0:|26: // Rendering methods|69: function Draw(_hdc:HDC; var prcBounds:TRect): HResult; stdcall;|107: function Tile(_hdc:HDC; var pptBackOrg:TPoint; var prcClip:TRect; var psize:TSize): HResult; stdcall;|120: function StretchBlt(_hdc:HDC; dstX,dstY,dstXE,dstYE,srcX,srcY,srcXE,srcYE:integer; dwROP:DWORD): HResult; stdcall;|5: end;|0:|28: THiAsmClass = class(TDebug)|10: private|21: FImgCtx:IImgCtx;|17: hOK:THandle;|16: sg:boolean;|14: sz:TSize;|9: public|31: FileName,Bitmap:THI_Event;|47: procedure doLoad(var Data:TData;idx:word);|50: procedure doStretch(var Data:TData;idx:word);|5: end;|0:|14:implementation|0:|5:const|31: IMGCHG_SIZE = $0001;|31: IMGCHG_VIEW = $0002;|31: IMGCHG_COMPLETE = $0004;|31: IMGCHG_ANIMATE = $0008;|31: IMGCHG_MASK = $000F;|0:|35: IMGLOAD_NOTLOADED = $00100000;|35: IMGLOAD_LOADING = $00200000;|35: IMGLOAD_STOPPED = $00400000;|35: IMGLOAD_ERROR = $00800000;|35: IMGLOAD_COMPLETE = $01000000;|35: IMGLOAD_MASK = $01F00000;|0:|35: IMGBITS_NONE = $02000000;|35: IMGBITS_PARTIAL = $04000000;|35: IMGBITS_TOTAL = $08000000;|35: IMGBITS_MASK = $0E000000;|0:|35: IMGANIM_ANIMATED = $10000000;|35: IMGANIM_MASK = $10000000;|0:|35: IMGTRANS_OPAQUE = $20000000;|35: IMGTRANS_MASK = $20000000;|0:|35: DWN_COLORMODE = $0000003F;|35: DWN_DOWNLOADONLY = $00000040;|35: DWN_FORCEDITHER = $00000080;|35: DWN_RAWIMAGE = $00000100;|0:|66: CLSID_IImgCtx:TGUID = '{3050f3d6-98b5-11cf-bb82-00aa00bdce0b}';|66: IID_IImgCtx:TGUID = '{3050f3d7-98b5-11cf-bb82-00aa00bdce0b}';|0:|0:|22:{ StringToWideString }|73:function StringToWideString(const s: String; codePage: Word): WideString;|17:var l: integer;|5:begin|16: Result := '';|23: if s = '' then exit;|80: l := MultiByteToWideChar(codePage, MB_PRECOMPOSED, PChar(@s[1]), -1, nil, 0);|28: SetLength(Result, l - 1);|23: if l <= 1 then exit;|93: MultiByteToWideChar(CodePage, MB_PRECOMPOSED, PChar(@s[1]), -1, PWideChar(@Result[1]), l);|4:end;|0:|63:procedure MyCallback(pCtx:pointer; pUserData:pointer); stdcall;|5:begin|37: THiAsmClass(pUserData).sg := true;|4:end;|0:|32:procedure THiAsmClass.doStretch;|41:var dt:TData; DC:hdc; R:TRect; Wnd:dword;|5:begin|23: if not sg then exit;|31: dt := ReadData(Data,Bitmap);|46: if _isBitmap(dt) then with ToBitmap(dt)^ do|80: FImgCtx.StretchBlt(Canvas.Handle,0,0,Width,Height,0,0,sz.cx,sz.cy,SRCCOPY)|14: else begin |28: Wnd := ToInteger(dt); |28: if Wnd = 0 then exit; |29: DC := GetWindowDC(Wnd);|27: GetWindowRect(Wnd,R);|87: FImgCtx.StretchBlt(DC,0,0,R.right-R.Left,R.bottom-R.Top,0,0,sz.cx,sz.cy,SRCCOPY);|24: ReleaseDC(Wnd,DC);|10: end; |3: |4:end;|0:|29:procedure THiAsmClass.doLoad;|25:var s:string; stat:dword;|5:begin|34: s := ReadString(Data,FileName);|34: if not FileExists(s) then exit;|56: FImgCtx := CreateComObject(CLSID_IImgCtx) as IImgCtx;|52: FImgCtx.Load(PWChar(StringToWideString(s,3)), 0);|56: FImgCtx.SetCallback(@MyCallback, pointer(Self)); |46: FImgCtx.SelectChanges(IMGCHG_COMPLETE,0,1);|15: sg := false;|49: while not sg do Applet.ProcessPendingMessages;|37: FImgCtx.GetStateInfo(stat, sz, 0);|3: |4:end;|0:|14:initialization|20: CoInitialize(nil);|12:finalization|17: CoUninitialize;|4:end.|
link(Bitmap,14498594:Handle,[])
}
Add(DoData,12423105,350,252)
{
Data=String(W:\Int\logo.jpg)
link(onEventData,16707643:doEvent1,[])
}
Add(Hub,16707643,406,252)
{
link(onEvent1,4633675:doLoad,[])
}
Add(Image,14498594,483,189)
{
Width=392
Height=266
Align=5
Color=16777215
Point(Handle)
Point(onPaint)
link(onPaint,4633675:doStretch,[(527,202)(527,234)(471,234)(471,265)])
}

Вот тут у меня выдает ошибку на onPaint. Подключаешь нижнюю точку хаба, те же эмоции
карма: 22

0