Link to home
Start Free TrialLog in
Avatar of Ayd192
Ayd192

asked on

HTML Dialogs?

Hi,
Can anybody give me some information or links about using HTML dialogs in delphi?
My main question is how I can access data in a HTML dialog ( for example edis boxes ) ?
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

hello Ayd192, You ask about HTML dialogs in delphi, I have tried to use the ShowHTMLDialog( ) function from the MSHTML.DLL and could not get it to work compleatly, I did get a HTML Dialog box to show. For this you will not only need to know Delphi And API, and COM, but JScript and HTML as well, here is some code for a simple HTML Dialog. . . .

FIRST, the HTML code for the for the Dialog.htm

<html>
<!--TOOLBAR_START--><!--TOOLBAR_EXEMPT--><!--TOOLBAR_END-->
<HTML id=Dialog1 STYLE="height: 17em; width: 15em">
<head><title>HTML Dialog</title>
<SCRIPT language="JScript">
<!--
window.returnValue = 0;
--->
</SCRIPT>
</head>
<BODY  BGCOLOR="#DEE2C0" TEXT="#000000" LINK="#0000CC" VLINK="#990099" ALINK="#CC0000">
<center><font size="+2" face="Comic Sans MS, Arial" color = "Red"><b>HTML Dialog</b><br></font><br><br>
This is the HTML Dialog page, So What<br><br>
<HR width="70%">
<FONT SIZE="+1" face="Arial">Click a Button to close this HTML Dialog Box</FONT>
   
<P><INPUT type=BUTTON value="OK" id="okButton" onClick="window.returnValue = 22; window.close();">
 &nbsp; &nbsp;
<INPUT type=BUTTON value="Cancel" id="cancelButton" class=button onClick="window.returnValue = 30; window.close();">
</body></html>


============================================================

NEXT, the Delphi code for your button press -


uses
UrlMon, ActiveX, ComObj;

procedure TForm1.but_HtmlDialogClick(Sender: TObject);
type
  TShowHTMLDialog = function(hwndParent: Cardinal;
    IMnk: IMoniker; varArgIn: OleVariant;
    PWCHOptions: PWCHAR; varArgOut: OleVariant): HRESULT; stdcall;

var
hLib2: Integer;
ShowHTMLDialog: TShowHTMLDialog;
pURLMoniker: IMoniker;
VarArgs, VarReturn: OLEVariant;
HR1: HRESULT;
Str1: String;
begin
hLib2 := LoadLibrary('MSHTML.DLL');
  if hLib2 <> 0 then
    try
    ShowHTMLDialog := GetProcAddress(hLib2, 'ShowHTMLDialog');
    if @ShowHTMLDialog <> nil then
      begin
      VarReturn := 1;
      OLECheck(CreateURLMoniker(nil, 'file:E:\Dialog.htm', pURLMoniker));
      HR1 := ShowHTMLDialog(Handle, pURLMoniker, VarArgs, nil, VarReturn);
      if HR1 = S_OK then
        begin
        if VarIsEmpty(VarReturn) then
          ShowMessage('varOleStr');
          str1 := VarReturn;
          ShowMessage('VarReturn is '+str1);
        end else
          ShowMessage('The ShowHTMLDialog FAILED');;
      end;
    finally
    FreeLibrary(hLib2);
    end;
end;


================================================================== = = = = = =  ==
I could not find any webpages for info about Delphi using ShowHTMLDialog( ), I did find some for C++,, but they did not provide much more info than the MSDN example web page .. . .
I could not get the VarArgs to be accepted with information in it, only if it was empty
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ayd192
Ayd192

ASKER

Hi Slick812,
Sorry for my late reply.

Thank you for your answers, they helped a lot ( Actually they answered almost all of my questions).

I should confess I didn't understand the part you use resources to pass images to dialog and your code dind't work right on this, but rest of the code was great.

thanx
Yea, I did this in win XP with IE  ver 6, I'm not sure if the images from resources is suppose to work in all versions of IE (four and above)  or not, but it works for me in IE 6. I fould the code to get the images from resources, but it did not say anything about the version of IE that it did or did not work in. This was a tough one to figure out the code for, since the only sample code I could find was in C++
do you need somethig else?
Ayd192  

Is this question still active?

Do you need more help with this?
Avatar of Ayd192

ASKER

Thank you Slick812,
as I've told you, your answers helped a lot.
I've forget to Accept your answer, but I'll do it now.

Excuse me for being late.