Solved

VARIANT structure

Posted on 1997-11-25
5
685 Views
Last Modified: 2013-11-20
I am using function
HRESULT IWebBrowser::Navigate(
    BSTR URL,                     // URL to navigate to
    VARIANT FAR* Flags,           // addr of option flags
    VARIANT FAR* TargetFrameName, // addr of frame name
    VARIANT FAR* PostData,        // addr of http Postdata
    VARIANT FAR* Headers,         // addr of HTTP headers
);

and wand to set the second parameter Flags.
It can come from another enum structure called
BrowserNavConstants. Could anyone tell me how
to put the values in BrowserNavConstants into
Flags? What is wrong in my code as following?

IWebBrowser mSearch;
VARIANT *flgaddr;
BrowserNavConstants flg;
flgaddr=&flg; //Wrong! how to set?
m_search.Navigate(URL, flgaddr, NULL, NULL, NULL);

0
Comment
Question by:hbh
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1310811
Try using

 IWebBrowser mSearch;
 VARIANT *flgaddr;
 BrowserNavConstants flg;
 COleVariant v;
 v = flg;
 flgaddr = v;
 m_search.Navigate(URL, flgaddr, NULL, NULL, NULL);


 

0
 

Author Comment

by:hbh
ID: 1310812
That doesn't work.
We can find, according to Help Information about the second
paramenter Flags:
"The variable can be a combination of the values defined by the
BrowserNavConstants enumeration." and

typedef enum BrowserNavConstants {
    navOpenInNewWindow = 1,
    navNoHistory = 2,
    navNoReadFromCache = 4,
    navNoWriteToCache = 8
} BrowserNavConstants;
which has been defined in Exdisp.h file.

However, the Flags is an address of VARIANT structure.
So I confuse about the two structures. Can anyone help me?  
hbh

0
 

Expert Comment

by:rakhras
ID: 1310813
Try the following:

IWebBrowser mSearch;
VARIANT varFlag;
BrowserNavConstants flg;

V_BYREF(&varFlag) = (void *) &flg;

m_search.Navigate(URL, &varFlag, NULL, NULL, NULL);
0
 

Expert Comment

by:rakhras
ID: 1310814
Oops, you must initialize your VARIANT, so go first::

VariantInit(&varFlag);
V_VT(&varFlag) = VT_BYREF;
V_BYREF(&varFlag) = (void *) &flg;

m_search.Navigate(URL, &varFlag, NULL, NULL, NULL);


0
 

Author Comment

by:hbh
ID: 1310815
Very good, it works. I think the Flag is long typ, so it
should be:
   VARIANT varFlag;
   BrowserNavConstants flg;
   flg = navNoHistory;
   VariantInit(&varFlag);
   V_VT(&varFlag) = VT_I4;
   V_I4REF(&varFlag) = (long *) &flg;
   m_search.Navigate(s_homepage, &varFlag, NULL, NULL, NULL);

However there is no any effct after "Flag" is set.
Acturally, here m_search is a WebBrowser control mumber variable.
Maybe this parameter is not effect to the Nevigate Method.
hbh.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 147
unable to delete all specified values regedit 38 544
Line meaning 9 87
Detect file exist or not 3 178
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question