Solved

VARIANT structure

Posted on 1997-11-25
5
687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 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