Solved

VARIANT structure

Posted on 1997-11-25
5
679 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 104
has22 challenge 11 70
mapBully challenge 6 88
wordcount challenge 11 73
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now