|
ATL has CComEnum . If you have your data in an STL collection, check out ICollectionOnSTLImpl and CComEnumOnSTL .
|
|
|
|
|
Hi
Actually I have created a toolbar for IE which will be changed after user loggs into our site and will be changed again after he logs out.These things I have done ,but the problem comes when it is session expiry.if the user does not do anything for 20 minutes in our site,then the session will expire and according to that the toolbar should also be changed again.How can I achieve that?My idea was to get the cookie value for that user when he logs in and firing a MySql query with the cookie value to our database each time when there is a page navigation or page refresh.If my query returns with no value,then it will mean that session has expired and according to that I will change the toolbar.I am retrieving the cookie value.But there are some problems:
1.I need to fire the query in DownloadBegin or DownloadComplete,but this is making IE very slow and IE is crashing.Moreover what I have dicovered is that,in IE6 if I dont do a page refresh or site navigation,simply if i just move the mouse over the page,then also the flow is coming to downloadbegin too many times,means that many times the query will be fired......oooops..that will be dangerous.where should I fire the query then?
|
|
|
|
|
|
hi,
I have a vector of a structure. I want to find a value of a element of structure, so that i can get that elememt in vector. I m not able to get any algo in STL so solve this problem. If you hv any idea please tell me.
Remember my vector is a vector of structure.
There is a function
_InIt find(_InIt _First, _InIt _Last, const _Ty& _Val)
doesn't for it.
Thanks & Regards
Pankaj Jain
|
|
|
|
|
That should work, unless the object/class allocates memory and it does not have a comparison method (operator==). The default comparison does a bitwise comparison, which will not work if the class (_Val) allocates memory (naturally).
Each collection type and each algorithm requires certain minimum requirements and the minimum requirement for find is a valid “operator ==”.
If that is not the problem, then I have no idea.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Perhaps something like this:
----------------------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Data
{
Data(int Num1, int Num2) : m_Num1(Num1), m_Num2(Num2) {}
int m_Num1;
int m_Num2;
friend bool operator==(const Data &lhs, const Data &rhs)
{
return (lhs.m_Num1 == rhs.m_Num1) && (lhs.m_Num2 == rhs.m_Num2);
}
};
void main()
{
// Create and populate the collection.
typedef vector<Data> coll_t;
coll_t coll;
coll.push_back(Data(3, 1));
coll.push_back(Data(4, 1));
coll.push_back(Data(5, 9));
coll.push_back(Data(2, 6));
coll.push_back(Data(5, 3));
// Find first (5, 9).
coll_t::const_iterator i = find(coll.begin(), coll.end(), Data(5, 9));
if (i != coll.end())
{
cout << "Found at index: " << (i-coll.begin()) << endl;
}
}
Steve
|
|
|
|
|
Hi
I have a vector of ClassA which has 5 public data member, X1,X2,X3,X4,X5. Now I want to find maximum and minimum value of X1 data member only. vector has more than 500 elements.
===========
class A
{
public:
int X1;// day , example only
int X2; // month
int X3 // year
double X4;
double X5
// only one function
CStrng GetData();// which format the date and return
}
==============
vector<class a=""> DataA;
A someDataA;
for (int i = 0; i < 500; i++)
{
// fill date members of someDataA;
DataA.push_back(someDataA); //
}
=================
Now I want to find the maximum and minimum value of X1 among all 500 data.
I don't want to compare object to object instead data member to data member.
I am new to STL/
So any code example will help. such as
max_element(0, 500,..) but how i will make sure it will compare specific data member only.
Thank you all.
msc
|
|
|
|
|
Look up “max_element”, there are 2 versions. The one you want takes a “predicate function object”. That “function object” does the comparison and you need to supply that. The same is true for the “min_element” algorithm.
I would normally just write my own loop to find the minimum and maximum in one pass, but too each their own.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
hi all, i have a class derived from CDialogImpl<>,i want to catch the Message WM_Keydown, and identify if that key is esc then dont close the dialog.
i have managed to do that in MFC application using Pretranslate function but that function is not working in ATL class,
i have tried to override DialogProc() but this function also not called, similaraly other option like CMessage::PreTranslateMessage and but same result these function are not called.
how to get equalent of MFC's PreTranslateMessage() in this class.
thanks in advance.
Regards.
Tasleem Arif
|
|
|
|
|
hi all,
i am having a sdk with fires an event.
i am trying to catch that event in other C++ console application,
i have derived my CEventSink class from IDispEventImpl
EventSink.h:
#pragma once
static _ATL_FUNC_INFO OnEvent = {CC_STDCALL, VT_EMPTY, 5, {VT_UI4, VT_BSTR, VT_BSTR, VT_I2, VT_BSTR}};
class ATL_NO_VTABLE CEventSink : public IDispEventImpl<1, CEventSink, &__uuidof(_ISourceEvents)>
{
public:
BEGIN_SINK_MAP(CEventSink)
SINK_ENTRY_INFO(1, __uuidof(_ISourceEvents), 1, OnEventES , &OnEvent )
END_SINK_MAP()
CEventSink(void);
~CEventSink(void);
HRESULT STDMETHODCALLTYPE OnEventES (DWORD dwSession, BSTR bszFilePath, BSTR bszName, SHORT Action, BSTR bszMessage);
};
OnEvent method from the sdk is:
[id(0x00000001), helpstring("method OnEvent ")]
HRESULT OnEvent (
[in] long dwSession,
[in] BSTR bszFilePath,
[in] BSTR bszName,
[in] short Result,
[in] BSTR bszMessage);
TestApp.cpp:
#include "stdafx.h"
#include "eventsink.h"
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
ISource *spEventFiringObject = NULL;
CEventSink* pEventSink = NULL;
HRESULT hr = CoCreateInstance(CLSID_Source, NULL, CLSCTX_ALL, IID_ISource, reinterpret_cast<void **="">(&spEventFiringObject));
if(SUCCEEDED(hr))
{
pEventSink = new CEventSink();
hr = pEventSink->DispEventAdvise(spEventFiringObject, &__uuidof(_ISourceEvents));
}
CoUninitialize();
return 0;
}
but DispEventAdvise returns something like
hr = 0xc0000005 The instruction at "0x
what is wrong here?
Thanx in advance.
|
|
|
|
|
Is the event interface defined as a dispinterface or a dual interface? It ought to be a dispinterface, really - I think dual interfaces can cause access violations (which is what your error looks like) if used as an event sink.
I'd also suggest adding the following two lines to your stdafx.h before any ATL files are included. They will show (in the debug output window - you need to run your application with the debugger) when AddRef/Release and QueryInterface are called, which may help you debug your issue.
#define _ATL_DEBUG_QI
#define _ATL_DEBUG_INTERFACES
|
|
|
|
|
Hi,
I am making a Toolbar for a website using ATL,WTL and WIN32. I have used BeforeNavigate2 function of DWebBrowserEvents2 where the control always come whenever we navigate to a certain URL.
I want to add a functionality whenever i Refresh a web page. During refresh of the page the control is not coming in BeforeNavigate2 function .
Which funcion is called when we refresh a webpage.
Can anyone help me.
Thanks In Advance.
Dhiraj Kumar Saini
|
|
|
|
|
I Have created a dialog in the resource editor. Now I want to add this in other frame window as a child component. I have created a class by deriving CDialogImpl<> template, to access the dialog in the program. How can I add an object of this class as a child window inside other class or frame window.
Note: I am using only WTL library. and the platform is VC++ in microsoft visual studio.NET
Gyan Prakash JOshi
|
|
|
|
|
Hi,
I currently use a vector to store a set of records. However there is now a limit to the number of elements the vector contains and once it is filled we have to remove the first element and insert the new one at the back. But as an added complication we aren't allowed any dynamic memory allocation so what needs to be done is:
1) Remove first element from list but do not free it's memory
2) overwrite the removed elements data with the new data
3) insert the updated element to the end of the vector
What is the best way to do this? I am not limited to only storing the data in a vector so if any other containers are more suitable then let me know!
TIA,
|
|
|
|
|
i'd recommend a std::list, but if you can't allocate any memory, you can't use any STL collections (since they'll allocate memory themselves).
so maybe a simple array:
RecordType array[MAX_SIZE];
?
|
|
|
|
|
Hi, thanks for your reply, the dynamic memory allocation can not happen in any code I write but it is allowed to happen in legacy or other code (i.e. STL, MFC, etc...). What happens at present is:
1) Start of program allocate enough space to the vector
2) Set the current position variable to 0 (i.e. we actually have no elements)
...
x) read in a record (again this is into an already defined variable)
x1) if not at the end of the vector copy the record into the next free position of the vector and increment the current position
x2) clear the contents of the read in variable (so its empty next time it gets a record)
The more I look at this code/mechanism the more clunky and bad it looks but I haven't got any other ideas how to do this, so if you have any suggestions that would be great.
Regarding using a list what methods would allow me to get the behaviour of moving the first element to the end?
cheers,
Andy
|
|
|
|
|
Hi (again),
I've just looked into the list container more and have figured out the following:
myList.splice(myList.end(),myList, myList.begin());
This seems to do what I was, is this the correct way to do it (and is it safe!)?
thanks,
|
|
|
|
|
mcsherry wrote: myList.end()
you'd probably want myList.end()-1 there, since myList.end() isn't an element.
otherwise, that should do what you want.
or, you can use pop_back / push_front
|
|
|
|
|
Chris Losinger wrote: i'd recommend a std::list
Or a deque[^]
|
|
|
|
|
mcsherry wrote: I currently use a vector to store a set of records. However there is now a limit to the number of elements the vector contains and once it is filled we have to remove the first element and insert the new one at the back. But as an added complication we aren't allowed any dynamic memory allocation so what needs to be done is:
1) Remove first element from list but do not free it's memory
2) overwrite the removed elements data with the new data
3) insert the updated element to the end of the vector
What is the best way to do this? I am not limited to only storing the data in a vector so if any other containers are more suitable then let me know!
I don't think STL provides any class that specificly avoids dynamic memory allocation, but ther is the notion of an allocator class which could be designed to just manage members of a fixed sized array. It might be simpler to not use an STL container. Boost might have the kind of class your looking for.
Failing that, you could implement your own class that does this. It would require an array, a first element index, and either a last element index of a content count. When the array gets full, you could update the first element index and assign a new value to the former first element.
Nathan
|
|
|
|
|
Well first off you are using dynamic memory just by using the ‘vector’ class, or any other STL collection, to store your records. Whether or not is frees the memory used by the first element is another story, it may just move the other elements down by one address, making the previous last element space empty (break out the pencil and paper). If the implementation of the ‘vector’ you are using does that, then you can simply remove the first element and add the new element to the end, and you have met the requirement (no special coding required); provided your class does not allocate memory in its copy constructor.
If you were dealing with a situation where you are supposed to write your own ‘vector’ type class, then I would say that instructor wants you to learn about ‘in place’ construction (look it up) using ‘new”.
Sorry if that did not help, but it is something you need to examine in detail to understand.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi
I have created a toolbar for IE in ATL,COM and WTL without using MFC.Now I want to get notification whenever the user changes the URL in the address bar or does a page refresh.I am using BeforeNavigate2 function which is working properly for any URL change,but not working for page reload or refresh.I need to get notified whenever there is a page refresh and whenever there is a navigation to different page.How to get it?
|
|
|
|
|
can any one send me the code for sending sms to mobile from aspx.cs code in c# code
|
|
|
|
|
me to want same coding . if u got it send to my mail plz..
by
vadivelu
9940294388
chennai
|
|
|
|
|
hi all
I have problem im my program,
I have:
<br />
string str_1, str_2;<br />
if( strcmp(str_1.data(),str_1.data()) == 0)<br />
{<br />
cout<<"equals";<br />
}<br />
else<br />
{<br />
cout<<"Not equals";<br />
}<br />
problem is that in 'str_1' and 'str_2' I have same text and rezult is "Not equals", can you help me and say how can I compeer two STL string's?
|
|
|
|
|