|
Just put the enum inside the library block!
--
Run around in the radiation
Run around in the acid rain,
On a black, black planet
|
|
|
|
|
Thanks. I guess I should have better documentation but it is hard to find this kind of stuff in ATL manuals they seem all to spend 300 pages talking about threading models and very little on stuff like this...
John
|
|
|
|
|
It was kind of funny though. Michael had the solution for you in his post all along.. notice how his enum is in the library clause?
You need a book on IDL it seems. I'm gonna buy one or two soon, because I believe I only know the tip of the ice berg. Besides, I think it's good bedtime reading.
--
Run around in the radiation
Run around in the acid rain,
On a black, black planet
|
|
|
|
|
Jörgen Sigvardsson wrote:
notice how his enum is in the library clause?
I did not know that made a difference. I am very much a newbie when it comes to ATL or com.
Jörgen Sigvardsson wrote:
You need a book on IDL it seems.
I guess I do. I don't directly edit IDL files for the most part unless I want to change or add a parameter on a method.
John
|
|
|
|
|
Can I fire events in ATL so as to be consumed in internet explorer?
I want to send notifications to the IE, whenever a condition becomes true.
Is it possible to use ATL events for the purpose such that whenever the condition becomes true an event is fired by the DLL/Control, which can be captured in the IE
|
|
|
|
|
I have an SDI app.I put an CSplitterWindow in it and put a CListViewCtrl in the splitter window.My question is how to get those LVN_XXXXXXXXX notifications passed down to the main frame so that I can handle them.(the parent window of the list view is the splitter window).
And antoher question is that I added the LVS_EX_FULLROWSELECT style to the list view when I created it, but it doesn't work, why?
modified 1-May-21 21:01pm.
|
|
|
|
|
Look at the message map in CSplitterWindow , it contains FORWARD_NOTIFICATIONS() . That means essentially, "pass all unhandled WM_NOTIFY or WM_COMMAND messages to my parent". So when the list sends a LVN_xxx to its parent (the splitter), the splitter sends it to its parent (the main frame). So the answer is, you don't have to do anything. (BTW I'll be covering this topic in my WTL articles soon, probably part 7.)
Can't say about your 2nd question. Post some code.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
First thank you
but there are still some problems i met with
1.i find the NOTIFY_HANDLER ask for the id of the control, but my CListViewCtrl is a view. how can i handle these notifications?
2.look at this
http://www.codeproject.com/useritems/wtlsnapsplitter.asp[^]
it has a listbox,the author added the LVS_EX_FULLROWSELECT to it,but ...
see for yourself.
3.my intelisence doesn't recognize CSplitterWindow, why?
modified 1-May-21 21:01pm.
|
|
|
|
|
|
hello
i creat a vector in class named foufou vector< foufou * > fou_caracter; and in an other class i store in the vector a random position that i generat
by rand
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
<br />
<br />
ptrfoufou->initPosX =( ( 1 + rand( ) % 100 ) - 50 );<br />
ptrfoufou->initPosY =( ( 1 + rand( ) % 100 ) - 50 );<br />
ptrfoufou->initPosZ =( ( 1 + rand( ) % 100) - 50);<br />
<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
and in an other function i want read the vector but i don't can
void creatfoufou::iteratorVector()<br />
{<br />
<br />
creatfou(5);<br />
int vectorIndex;<br />
vectorIndex = fou_caracter.size();<br />
<br />
for (int i=0;i<vectorIndex ;i++)<br />
{<br />
<br />
ptrfoufou->RePaint(<br />
fou_caracter[i]->initPosX,<br />
fou_caracter[i]->initPosY,<br />
fou_caracter[i]->initPosZ);<br />
}<br />
<br />
<br />
}
what is the error with this???
|
|
|
|
|
aguest wrote:
what is the error with this???
Use an iterator
vector<foufou*>::iterator myIter;
-Nick Parker
|
|
|
|
|
but how i can manipulat e thi siterator to read the vector.
thank you
|
|
|
|
|
aguest wrote:
but how i can manipulat e thi siterator to read the vector.
You don't have to use an iterator, here is an example of not, I guessed what you class might look like:
#include <iostream>
#include <vector>
using namespace std;
struct Stuff
{
int x, y, z;
};
int main()
{
vector<Stuff*> vect;
unsigned int index;
Stuff* si = new Stuff;
Stuff* si2 = new Stuff;
si->x = 2;
si->y = 4;
si->z = 6;
si2->x = 1;
si2->y = 3;
si2->z = 5;
vect.push_back(si);
vect.push_back(si2);
for(index = 0; index < vect.size(); index++)
{
cout << "X = " << vect[index]->x << endl;
cout << "Y = " << vect[index]->y << endl;
cout << "Z = " << vect[index]->z << "\n\n";
}
delete si;
delete si2;
return 0;
}
-Nick Parker
|
|
|
|
|
Used a VC++ ATL Wizard to build a COM DLL server and then add a simple ATL object inside, when this COM object is created in ASP, IIS complaint library not registered.
Try to create that object VB, no problem at all.
How to fix this problem?
|
|
|
|
|
Have you implemented IObjectSafetyImpl ?
B
|
|
|
|
|
You need to add a reference to a type library for your server in the file global.asa .
Like this:
<!-- METADATA TYPE="TypeLib" FILE="d:\path\to\typelib\or\server.dll" -->
I think that should help you.
--
Run around in the radiation
Run around in the acid rain,
On a black, black planet
|
|
|
|
|
I am not all that familiar with the STL so bear with me.
I need something that can hold a lot of information and
be resized fairly easily - I have thought of std::vector
for this purpose.
However, the data I am using is not int, double, long, etc...
Instead, it is a class, say for simplicity CString.
Is it possible to define:
<br />
vector<CString> StringStack;<br />
This compiles and I can seem to add "strings" to it
If so, how does one go about declaring and using an iterator for this?
Have tried:
<br />
vector<CString>::iterator itr;<br />
for (itr = StringStack.begin(); itr != StringStack.end(); ++itr)<br />
{<br />
cout << *itr;<br />
}<br />
But this doesn't seem to work. Is what I am attempting even possible?
Thanks.
|
|
|
|
|
Ok, I am guessing here. Does CString support iostreams? You might try using std::string.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I think I've got it.
I do need to overload << though.
|
|
|
|
|
Try this:
<br />
vector<CString> StringStack;<br />
<br />
StringStack.push_back(CString("John"));<br />
StringStack.push_back(CString("Kim"));<br />
StringStack.push_back(CString("Kathy"));<br />
<br />
vector<CString>::iterator itr;<br />
for (itr = StringStack.begin(); itr != StringStack.end(); ++itr)<br />
{<br />
cout << (LPCTSTR)*itr << endl;<br />
}<br />
|
|
|
|
|
Thanks for the reply. I think I've figured it out.
I actually wasn't using CString, but rather a user-defined
class. Nonetheless, I seem to have figured it out.
The following apprears to work:
<br />
using std::vector;<br />
using std::endl;<br />
using std::sort;<br />
using std::partition;<br />
using std::less;<br />
using std::bind2nd;<br />
using std::ostream_iterator;<br />
using std::copy;<br />
using std::back_inserter;<br />
using std::vector<CSpring>;<br />
<br />
void CSpringSolver::DumpSprings()<br />
{<br />
vector<CSpring>::iterator itr;<br />
for (itr = SpringStack.begin(); itr != SpringStack.end(); ++itr)<br />
{<br />
itr->ShowSpring();
}<br />
}<br />
I just need to overload << (if possible)
|
|
|
|
|
So I've authored the activeX control using ATL and used the wizard to implement the connection point I added. Of course the wizard generated that header file, '<NameOfProject>CP.h', and in that header was the class: 'CProxy<INameOfDispInterface>Events'.
Now here's my dilema...
I want the event handler, that is a member function of the MFC dialog containing the control, to close and destroy the dialog. Unfortunately when that happens, the COleControlSite with the ATL control in it also get's destroyed, and then when the 'Fire_<Event1>' method returns from the call to 'pDispatch->Invoke' it tries to call release on the CComPtr it held pointing to the COleControlSite (which was just destroyed).........hence a memory access exception.
I'd love for someone to point out what I'm doing wrong, or perhaps another way to do this.
Ultimately all I care about is having an MFC dialog that can destroy itself based on some kind of event from a contained ATL control.
thanks,
nebbish
"The man who trades freedom for security does not deserve, nor will he ever receive either." -- Benjamin Franklin
|
|
|
|
|
I've created a toolbar for IE using ATL, and weird problem has showed up.
Everything is fine when I open up Internet Explorer and select View->Toolbars->mytoolbar, however, when i close IE after that and open it up again, there is only the first button visible on my toolbar.
When i hide my toolbar, restart IE and make toolbar visible (View->Toolbars->mytoolbar)everything is ok again (all the buttons do appear...), so the problem might be related somehow to IE initializing toolbars at startup...
Any comments?
Hannes Pahapill
|
|
|
|
|
Hi,
I have written a dll using ATL. In which I want to fire events from a call back function. When I tried to do that my program crashes.
So that I have implemented a hidden window (which I saw in an article in this site) and posting the message to that window. From there I fire the events. It is working quite fine.
But my problem is, when I closes the application which used my COM object, it crashes at the end. I cannot trace what is the problem.
I describe here step by step what I have written in my program..
1. This is the hidden window i have created..
// mywnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyWindow window
class CClsRecord;
class CMyWindow : public CWnd
{
// Construction
public:
LRESULT OnFireEventForThread(WPARAM wParam, LPARAM lParam);
CClsRecord *m_pControl;
HWND Create();
CMyWindow(CClsRecord *pCtrl);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyWindow)
protected:
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyWindow();
// Generated message map functions
protected:
//{{AFX_MSG(CMyWindow)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
HWND CMyWindow::Create()
{
//Register a window class
LPCTSTR classname = 0;
classname = AfxRegisterWndClass(0);
//Create the window and return it's handle
CWnd::CreateEx(NULL,classname,NULL,NULL,1,1,1,1,NULL,NULL);
ASSERT(m_hWnd!=NULL);
return m_hWnd;
}
LRESULT CMyWindow::OnFireEventForThread(WPARAM wParam, LPARAM lParam)
{
CComBSTR bstr;
//This is a one-message-does-everything handler. If wParam is not
//set, that means our message has been sent to fire the even.
//If wParam is set that means we're being asked to destroy ourselves
if(!wParam)
{
if (lParam!=NULL)
{
bstr = m_pControl->GetEventMessage();
m_pControl->Fire_OnEvent(lParam,bstr.Copy());
}
}
else if(wParam==1)
DestroyWindow();
return TRUE;
}
void CMyWindow::PostNcDestroy()
{
//clean up this object
delete this;
}
2. In the ClsRecord class, I have created a thread like this
CMyWindow *pWnd = new CMyWindow(this);
HWND hwndTarget = pWnd->Create();
//create a thread for handling all the events
HANDLE threadHandle = CreateThread(NULL,NULL,
(LPTHREAD_START_ROUTINE)GetNextEventLoopInThread,
(LPVOID)hwndTarget,
NULL,
&Tid);
3. Now, I am sending the message to the window like this..
PostMessage(hWnd,WM_THREADFIREEVENT,(WPARAM)NULL,(LPARAM)CLS_END_CALL_EVENT);
4. Now I call the dll in a VB application. The events are getting fired without any problem. But when I close the vb application, my program crashes. If I use 'End' statement in VB also it crashes immediately.
I have absolutely no glue that what could be the probem? Is it because of a memory leak? Then how can I detect this?
Kindly help me..
Thanks in advance
with regards
Sivakumar R
|
|
|
|
|
Did you call CoInitializeEx(...) in both threads where you are accessing your object?
Don't forget to call also CoUninitialize() before the thread exits.
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|