🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1031

Reading params of object

#1031
From: Chris.you
Date: Fri, 04 Nov 2005 06:58
180 lines
6888 bytes
Hello~

I am making some application that be able to write all of
picture and flash in homepage.

i have 2 problems, but i can't find solution.. :(



1. Getting present picture.

I want to get present picture. (not twice downloading from address)
maybe, i believe IHTMLImgElement doesn't support the function be
able to get original binary. isn't it? :)

so, then, I get above address and download picture by URLDownloadToFile
function (it is in DownloadImageElement function following source)

i saw "URLDownloadToFile is smart, it will not download twice if i
have cache of this picture". it's working if i test just picture file
perfectly. but, it has a problem if test dynamic image like cgi or php file.
(exactly, it downloaded picture again)

so, I use OLECMDID_COPY then get picture from clipboard.
it's work, and i can get present picture without twice downloading.
but, it has different binary as server because of i can't know
type of image file correctly. (i've save image from clipboard to bmp file.
but, i believe it will has different binary even if i will save jpg file)

how can i get present binary file? :(
(I saw HttpWatch application, it has solve this problem :( )


void GetImageElement(IHTMLDocument2 *ihDocument)
{

 IHTMLElementCollection                *ciElementCol;
 IHTMLImgElement                       *ciImageElement;
 LONG                                  lnMaxElement;
 int                                   itCount, itImageIndex;
 VARIANT                               vaRequest, vaRequestSub;
 IDispatch                             *idReturn;
 BSTR                                  bsAddress, bsFilename;
 String                                stFileExt;


 // ��� �̹����� ã�Ƴ�
 if(SUCCEEDED(ihDocument->get_images(&ciElementCol))) {
   if(SUCCEEDED(ciElementCol->get_length(&lnMaxElement))) {

     Main->Memo1->Lines->Add("Image : " + IntToStr(lnMaxElement));

     // ��ü ó��
     for(itCount = 0; itCount < lnMaxElement; itCount ++) {
       vaRequest.vt   = VT_UINT;
       vaRequest.lVal = itCount;
       VariantInit(&vaRequestSub);

       // �� �̹������� ������ ���´�
       if(SUCCEEDED(ciElementCol->item(vaRequest, vaRequestSub, &idReturn))) {
         if(SUCCEEDED(idReturn->QueryInterface(IID_IHTMLImgElement, (void **)&ciImageElement))) {

           // ���� �м�
           ciImageElement->get_src(&bsAddress);

           if(((String)(bsAddress)).Length() > 10 && DATA.Image->IndexOf(bsAddress) < 0) {
             itImageIndex = DATA.Image->Count;
             DATA.Image->Add(bsAddress);

             ciImageElement->get_nameProp(&bsFilename);
             stFileExt = ExtractFileExt(bsFilename).UpperCase();

             if(stFileExt == ".BMP" || stFileExt == ".TGA" || stFileExt == ".PNG" || stFileExt == ".GIF" || stFileExt == ".JPG" || 
stFileExt == ".JPEG") {
               // ���� �̹��� ó��
               DownloadImageElement(itImageIndex, ciImageElement);
              } else {
               // ���� �̹��� ó��
               DownloadDynamicImageElement(itImageIndex, ciImageElement);
             }
           }

           ciImageElement->Release();

         }

         idReturn->Release();
       }
     }
   }

   ciElementCol->Release();
 }

}


2. get param of object.

i wrote simple code like following to my server.


<BODY>
  <OBJECT id="menu" codeBase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0 height=100 
width=204 align=middle classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000>
    <PARAM NAME="allowScriptAccess" VALUE="always">
    <PARAM NAME="movie" VALUE="b.swf">
    <PARAM NAME="quality" VALUE="high">
    <PARAM NAME="bgcolor" VALUE="#ffffff">
    <param name="wmode" value="opaque">
    <param name=flashvars value="id=worldtime&worldtime_data=2005|11|02|14|15|05&worldtime_zone=57|0"/>
  </OBJECT>
</BODY>


I've access object with following way.
but, i could't access param (<PARAM NAME="movie" VALUE="b.swf">) because of
IHTMLObjectElement has not method be able to access param.

how can i get a param value? :(


 // ��� Object ��ü�� ã�Ƴ�
 if(SUCCEEDED(ihDocument->get_applets(&ciElementCol))) {
   if(SUCCEEDED(ciElementCol->get_length(&lnMaxElement))) {

     Main->Memo1->Lines->Add("Object : " + IntToStr(lnMaxElement));

     // ��ü ó��
     for(itCount = 0; itCount < lnMaxElement; itCount ++) {
       vaRequest.vt   = VT_UINT;
       vaRequest.lVal = itCount;
       VariantInit(&vaRequestSub);

       // �� �̹������� ������ ���´�
       if(SUCCEEDED(ciElementCol->item(vaRequest, vaRequestSub, &idReturn))) {
         if(SUCCEEDED(idReturn->QueryInterface(IID_IHTMLObjectElement, (void **)&ciObjectElement))) {

           // Just testing ...  v

           // ���� �м�
           IHTMLFormElement                     *ciFormElement;
           LONG                                 lnLength;

           ciObjectElement-> get_form(&ciFormElement);
           ciFormElement->get_length(&lnLength);
           Main->Memo1->Lines->Add(lnLength);


           ciObjectElement->get_BaseHref(&bsAddress);
           Main->Memo1->Lines->Add(bsAddress);

           ciObjectElement->get_object(&idReturn);

           if(SUCCEEDED(idReturn->QueryInterface(IID_IHTMLParaElement, (void **)&ciParamElement))) {
             Main->Memo1->Lines->Add("OK");

           }

           ciObjectElement->Release();

         }

         idReturn->Release();
       }
     }
   }

   ciElementCol->Release();
 }



I am always getting too many help from here.
I hope to get any suggestions even if it's not solution.

thanks.


cuperido 
Technical Details
Message-ID: <436b0690$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,4fb7d706632f0bf1,start
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII
From: "Chris.you" <cuperido@mail.com>
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Reading params of object
Date: Fri, 4 Nov 2005 15:58:51 +0900
Lines: 182
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 210.91.29.80
Message-ID: <436b0690$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1131087504 210.91.29.80 (3 Nov 2005 22:58:24 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail