Delphi2007下调试通过
program NoVCLPic;
uses
Windows,Messages,ActiveX;
function OleLoadPictureFile(varFileName:OleVariant;var lplpdispPicture:IDispatch):HResult;stdcall;external 'OleAut32.dll' index 422;
type
PRect=^TRect;
var
hwndMain:HWND;
msg :TMSG;
wc:TWNDCLASS;
DispPic:IDispatch;
aPic:IPicture;
PicW,PicH:LongInt;
const
PicFile='D:\radiogroupbutton.gif';
function MainProc(hwndMe:HWND;uMsg,wParam,lParam:Integer):LongInt;stdcall;
var
aDC:HDC;
ps:TPaintStruct;
ClientRect:TRect;
begin
case uMsg of
WM_CREATE:
begin
if OleLoadPictureFile(PicFile,DispPic) < 0 then
MessageBox(hwndMe,'Load Picture Error!',nil,MB_OK)
else
begin
aPic := DispPic as IPicture;
aPic.get_Width(PicW);
aPic.get_Height(PicH);
end;
end;
WM_PAINT:
begin
GetClientRect(hwndMe,ClientRect);
aDC := BeginPaint(hwndMe,ps);
aPic.Render(adc,0,0,ClientRect.Right,ClientRect.Bottom,0,PicH-1,PicW,-PicH,PRect(Nil)^);
EndPaint(hwndMe,ps);
end;
WM_DESTROY:
PostQuitMessage(0);
WM_LBUTTONDOWN:
begin
WinExec(PChar('C:\Windows\explorer.exe'),SW_NORMAL);
end;
end;
Result:= DefWindowProc(hwndMe,uMsg,wParam,lParam);
end;
begin
CoInitialize(nil);
try
wc.style := CS_VREDRAW or CS_HREDRAW;
wc.lpfnWndProc := @MainProc;
wc.cbClsExtra := 0;
wc.cbWndExtra := 0;
wc.hInstance := hInstance;
wc.hIcon := LoadIcon(0,IDI_APPLICATION);
wc.hCursor := LoadCursor(0,IDC_ARROW);
wc.hbrBackground := 0;//GetStockObject(GRAY_BRUSH);
wc.lpszMenuName := nil;
wc.lpszClassName := 'MainWndClass';
if (RegisterClass(wc)= 0) then Exit;
hwndMain := CreateWindow('MainWndClass','NoVCLLoadPic',
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, 0,0,HInstance, nil);
if (hwndMain =0) then Exit;
ShowWindow(hwndMain, SW_NORMAL);
UpdateWindow(hwndMain);
while (GetMessage(msg,0, 0,0)) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
finally
CoUninitialize;
end;
end.
迅雷专用高速下载