|
I develope a DLL that is loaded with every instance of Internet Explorer. In the DLL, I want to handle something like "BeforeNavigate" event to get the URL user enter in the Adress Bar.
I've written this DLL before in C#. And in C#, handle this event is quite easy, just write something like:
WebBrowser browser;
browser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandle(this.BeforeNavigate);
But now, I have to write it in Visual C++ 6.0. How can I handle this event in Visual C++ 6.0?
Hope to see your replies soon.
Thanks.
Lan hue sau ai lan hue heo
Lan hue sau doi trong heo ngoai tuoi
|
|
|
|
|
|
hi!
i have tried to store bitmap image into my activex control. i used the following Put property to store image.
[propput, id(7), helpstring("property CompanyLogo")] HRESULT CompanyLogo([in] IPictureDisp * newVal);
and in it i wrote following four lines of code.
m_pCompLogoDisp = newVal;
SetDirty(true);
SendOnDataChange();
FireViewChange();
The property is receiving image data but not persisting it.
does my property declarion incorrect. if so then plz help me.
Thanks in advance.
|
|
|
|
|
I've a MTS/COM+ component (COMPONENT_1) that #import s ADO library. And, I have another MTS/COM+ component (COMPONENT_2) that #import s this component. I need to use ADO objects in my second component (COMPONENT_2) too. If I use #import in my second component, I get lots of errors. If I do not, the MIDL compiler remains unable to recognize _Recordset data type. Can anyone please show me how to do it?
I am using ATL with Visual C++ 6.0 SP5.
Thanks
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
Hi-- I've been banging my head trying to solve this problem. Of course I'm a self trained pseudo programmer who just started to use STL. I have a huge file with 10 million entries that are paired, say:
1 8
1 5
1 3
2 0
2 4
3 0
3 8
etc...
They are stored as a two dimensional array of 10 million rows and two columns... you get the idea of the data. I need to find the records in the file that have one and only one of the tags in the first entry of the pair and put the second in another vector file in the order found. For example, if I need records with the tag 2, I'll create the vector
0
4
I suppose I need to use a multimap, but do not know how to read the file and then store the results in a vector. Right now I have this simple code:
typedef vector DVECTOR;
DVECTOR FDV;
int tag;
double FD;
int id = 3;
int idp = id + 1;
while(tag != idp)
{
GetData >> tag >> FD;
cout << tag << " " << FD << endl ;
if(tag == id)
FDV.push_back(FD);
}
This does what I want by scaning the file from the begining until it finds the target value and reads all the entries with such value. If the number is close to the first entry, cool it's fast, but if it is near the end it will take a long time (big program repeated many times...). The question is, would the multimap work better and faster to do the same task? If so... how do I do it??? that is, read the file, store the data in a multimap, search for the tag number of my interest and copy all values associated to the tag number into a vector. If I have to read the whole 10 million line file to put it in a map, then it's going to be hanging around in memory for further use (several times)... or should I read the file every time I need it?? If so, then, isn't my naive code more efficient???
By the way, I'm trying this other code using multimap but gives me horrible error messages:
typedef multimap<int, double=""> DMMAP;
DMMAP mapfish;
while(!GetData.eof())
{
GetData >> tag >> FDS;
mapfish.insert(make_pair(tag,FDS));
}
argggggggggggggggggggggggggg
Thank you so much!
Carlos
|
|
|
|
|
Well, if I understand your scenario correctly, you have two valid alternatives:- Scan the whole file into a
multimap and use this later several times. - Improve your file searching by doing something like a binary search on it. This is a little complex, but doable: broadly sketched, you have to open the file and set the current offset to the middle of it, skip characters until you find a newline and then read the entry: if the tag is
id -1, keep on reading till you get to your target portion and proceed. If the tag is greater than that, set the offset to 1/4 of the file, else set it to 3/4, proceed recursively etc. If you'll be doing the search many times, the multimap solution is probably faster, otherwise you'll have better performance with binary searching on the file. We can do an estimate: Let us call N the number of entries (10 millions in your case) and S the number of search operations you're going to perform on the file. Each search takes approximately log2N entry readings, so the binary search method will read in total S*log2N file entries. With the first method, the entries read are exactly N, as you scan the entire file. So the first method is better (on a first approximation) than the second if
N < S*log2N
With 10 million entries, this means the first method wins if you do more than ~430,000 search operations. I guess you won't do that many searches, hence my hunch is that you're probably better off implementing the file binary search stuff. Hope this helps a little.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
|
Hi all
Imconfused by a daft problem..
Our apps are written using MFC (CStrings etc) but we are using a library which uses ATL (strings). I understand string is a basic string but cant get my head around this simple problem...
I cannot assign a string longer than 15 chars...
To show an example..
string s1;
CString cs1;
cs1 = m_sRootURL.Left(10);
s1 = cs1.GetString(); // ok
cs1 = m_sRootURL.Left(12);
s1 = cs1.GetString(); // ok
cs1 = m_sRootURL.Left(14);
s1 = cs1.GetString(); // ok
cs1 = m_sRootURL.Left(16);
s1 = cs1.GetString(); // not ok, s1 = "5rf"
All help etc.. etc...
|
|
|
|
|
I don't really understand your question. When you say "I understand string is a basic string" do you really mean: a BSTR?
If your ATL component requires data to be input as a BSTR you can use CString::AllocSysString in MFC to allocate a BSTR and copy a Cstring's contents into the BSTR. Then you can pass the BSTR to the ATL library.
Robert
|
|
|
|
|
i have created an activex control using COM/ATL and then i placed my activex control into Word document using following
function.
CComVariant varClsType("Ascertia.AscertiaObj.1");
MSWord::InlineShapePtr MyObj =
m_pWordApp->Selection->InlineShapes->AddOLEObject(&varClsType);
Now my activex control has different get and set properties like Caption,
BKColor,MyData etc. I want to access and modify those properties after executing the above 2 lines of code from within MSWord.
anybody there to give me a hand.
Thanks in advance.
Ahmad Jalil Qarshi
|
|
|
|
|
Hi,
I'm designing an application that consists of ONLY a wizard. I use this code to show it.
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMainWizard wizard;
if ( IDOK == wizard.DoModal() )
{
}
return 0;
}
The rest of the code is default wizard code.
It all works perfectly but when i close the wizard with the cancel button i get a first chance exeception. It think this is because Run() always returns zero.
What should i do to let it exit in an ordinate fashion? Thnx
|
|
|
|
|
i dont think that the error is caused by your return code, you need to step into the code on the cancel button handler and try to "isolate" the line that causes the exception, watch variables and go line by line till you find out whats wrong.
If you still cant find whats wrong, post the code for your CMainWizard class so we can help you find the problem.
HTH
|
|
|
|
|
hi guys
i have create three Interfaces in a class which is create by ATL Object Wizard
this Interfases defines as under:
IA,IB,IC
IA derived from IDispatch
IB derived from IA
IC derived from IA
could you tell me how to write the 'BEGIN_COM_MAP' etc for my case?
thinks a lot
I love programming, but my english is too bad (
|
|
|
|
|
Currently, I have a COM event which I've created a sink for and all of that jazz. It receives events at the Invoke method of course. Then i use dispIdMember to figure out which event was called. The only problem is that the event is fired from a different thread as the rest of my program, which poses a huge problem. Is there a way that I can call a function on threadA from threadB?
|
|
|
|
|
one way to do this is to create a hidden window on threadA and then post a message on threadB to the threadA hidden window.
If you need to wait for the process to finish before threadB continues then use sendmessage not postmessage.
Best of luck
Forever Developing
|
|
|
|
|
hi!
i want to persist binary data read from a file into my ActiveX object. i have tried to do that using VARIANT containing SAFEARRAY of BYTES but couldn't do that. furthermore i tried to do same by using directly SAFEARRAYs of bytes, but unfortunately i couldn't. It seems that its not possible to store VARIANT containing SAFEARRAY of bytes as well as direct SAFEARRAYS of bytes. Am i right?
if its possible then please tell me how to do that. Is there any other way to do that?
Thanks in advance.
Ahmad Jalil Qarshi
|
|
|
|
|
There is already an Automation-compatible type for holding a block of bytes - BSTR . Use SysAllocStringByteLen() to allocate the BSTR . (Normally BSTR s are used to hold C-style strings, but that's not mandatory.)
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thanks Mike!
You solved my problem. you are really great. I was working on it since last 2 weeks. nobody guided me towards using BSTR. but now when i see so simple solution with the help of you great person i am so happy.
Thanks a lot.
Ahmad Jalil Qarshi
|
|
|
|
|
How to fix (custom ActiveX)control size in design time.
I am using MFC ActiveX ControlWizard.
Please help me.
Thanks
David Park
|
|
|
|
|
How to lock child window from resizing in MDI ?
I am using WTL + MDI/Dialog framework.
- CMDIFrameWindowImpl<MAINFRAME>
--- CMDIChildWindowImpl<MY_FRAME>
----- CDialogImpl<MY_FRAME_VIEW>
i tried to set-up window styles (below) on creating... but child window then freezing :/ and i can do nothing with it (move/minimize)
Style to setup for not-resizing window:
~WS_THICKFRAME;
~WS_MAXIMIZEBOX;
i have example, but it built on Document/View technology...
http://www.thecodeproject.com/dialog/resizeformtofit.asp
----------------------------
never stop coding.
|
|
|
|
|
use the WM_NCCALCSIZE msg to set the dimensions of the dialog to the same min/max size, use it in the frame
regards
|
|
|
|
|
hi
i'm want to use new GNU comipler
the problem is with hash_map interator
after reading some articles i added some extra macros but the didn't solve the problem
compiler seems to do not recognize type
template <typename Data>
or
template <class Data>
and in line
hash_map<int, Data>::interator ptr;
throws an error: expected `;' before "ptr"
here is whole code
<code>
#include <string>
#include <ext/hash_map>
#include <iostream>
#include <iterator>
#if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95)
/*STL extensions were put in the std namespace ...*/
namespace gnuext = std ;
#elif defined(__GNUC__) && (__GNUC__>=3)
/* STL extensions have their own namespace */
namespace gnuext = __gnu_cxx ;
#else
#error "This code relies on non-standard STL extensions as defined by GNU libraries."
#endif
#if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95)
/*STL extensions were put in the std namespace ...*/
#define __GNUEXT std
#elif defined(__GNUC__) && (__GNUC__>=3)
/* STL extensions have their own namespace */
#define __GNUEXT __gnu_cxx
#else
#error "This code relies on non-standard STL extensions as defined by GNU libraries."
#endif
template <typename Data>
class MyHash {
MyHash() {}
~MyHash() {}
__GNUEXT::hash_map<int,Data> myhash;
void add(Data d)
{
__GNUEXT::hash_map<int, Data>::iterator ptr;
}
};
<code/>
Pain is a weakness living the body
|
|
|
|
|
ravjak wrote:
__GNUEXT::hash_map::iterator ptr;
try:
typename __GNUEXT::hash_map<int, data="">::iterator ptr;
|
|
|
|
|
bingo
thans
Pain is a weakness living the body
|
|
|
|
|