|
Hi Steve,
Do I need to call the CoInitialize in the ActiveX(OCX) thread for that event. I tried that too, I then get the following error.
RPC_E_WRONG_THREAD which translates to "The application called an interface that was marshalled for a different thread." I don't know what to do next. Any ideas?
Thanks
|
|
|
|
|
I suspect you're passing interface pointers between threads without marshalling. In general this can't work as COM has to take the difference in the threading models into account and it does this by setting by proxies and stubs when an interface is marshaled. Threading is complicated.
Steve
|
|
|
|
|
Hi Steve,
Do you know how I can do this between the ActiveX(OCX) and the ATL Exe Server?
Regards,
|
|
|
|
|
how to programming for allow users drag & drop spliter to adjust
control position?
just like windows explorer.
you can adjust position of both left directory tree and right file
details.
and I need add this function in Standard VC++ 6.0 (can't using MFC).
because I need add this in my ATL control.
thanks in advance.
|
|
|
|
|
|
to Mike,
Thanks for your reply. I have read your acticle your provided. this is a class under MFC. can you using it in my ATL (not support MFC)?
Thanks in advance.
|
|
|
|
|
No, it's not an MFC class. The article however is targeted at MFC developers, making the WTL learning curve less steep.
|
|
|
|
|
CSplitterWindow is a WTL class, not MFC, you'll have no trouble using it in an ATL project as long as you add the right WTL includes. See Part 1 and 2 of the series for details on how to set up a WTL project.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thank you very much, I will try it later, Now I am coding for other important functions in my project.
|
|
|
|
|
Hi Mike,
I am writing code for add a splitter now.
I downloaded WTL7.1 and setuped it. then add this includes into vc directories.
But, there are many errores happened when I add two include(atlapp.h and atlsplit.h) only.
the following text is error messages
--
D:\WTL71\INCLUDE\atlapp.h(397) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(398) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(596) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(600) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(601) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(604) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(845) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(57) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(82) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(205) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(490) : see reference to class template instantiation 'WTL::CMenuT<t_bmanaged>' being compiled
D:\WTL71\INCLUDE\atlgdi.h(78) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(86) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(88) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(528) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(682) : see reference to class template instantiation 'WTL::CBitmapT<t_bmanaged>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(824) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(852) : see reference to class template instantiation 'WTL::CSplitterWindowImpl<t,t_bvertical,tbase,twintraits>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(823) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(863) : see reference to class template instantiation 'WTL::CSplitterWindowT<t_bvertical>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(823) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(863) : see reference to class template instantiation 'WTL::CSplitterWindowT<t_bvertical>' being compiled
E:\Workspace_synviz\SynViz1.1\SynVizRGGantt\StdAfx.cpp(8) : error C2856: #pragma hdrstop cannot be inside an #if block
E:\Workspace_synviz\SynViz1.1\SynVizRGGantt\StdAfx.cpp(9) : error C2856: #pragma hdrstop cannot be inside an #if block
Error executing cl.exe.
--
ATL + WTL these confuse me deeply.
Thanks in advance.
|
|
|
|
|
Just a thought, have you tried Build->Rebuild All? That seems to fix some problems I've had in the past...
[EDIT]Are you including these files in stdafx.h?[/EDIT]
- S
50 cups of coffee and you know it's on!
-- modified at 2:23 Thursday 27th April, 2006
|
|
|
|
|
Hi Steve Echols,
Thanks for your reply.
Steve Echols wrote: Just a thought, have you tried Build->Rebuild All? That seems to fix some problems I've had in the past...
--
I alway press F7 key from building my project. F7 is short key for ‘Rebuild ALL’.
Steve Echols wrote: Are you including these files in stdafx.h?
--
yes. I add these include in 'stdafx.h' file.
|
|
|
|
|
ah, I forgot to mention that when you use WTL and MFC in the same project, you need to #define _WTL_NO_AUTOMATIC_NAMESPACE before the WTL headers because some classes in MFC and WTL have the same name (like CString ).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Mike,
I changed the code like you told me.
but, the system still output error messages, just like I didn't add [#define _WTL_NO_AUTOMATIC_NAMESPACE ] before the WTL headers.
--
C:\WTL71\INCLUDE\atlapp.h(396) : error C2872: 'ATL' : ambiguous symbol
--> Source Code : ATL::CSimpleArray<CMessageFilter*> m_aMsgFilter;
...
Michael Dunn wrote: because some classes in MFC and WTL have the same name (like CString).
I am developing a ATL com without MFC. does it something wrong?
Thanks for your help.
|
|
|
|
|
Hi.
----------------------------------------
AtlWin.h some code about unsubclass window:
LONG_PTR pfnWndProc = ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC);<br />
lRes = pThis->DefWindowProc(uMsg, wParam, lParam);<br />
if(pThis->m_pfnSuperWindowProc != ::DefWindowProc && ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc)<br />
::SetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc);<br />
#if (_ATL_VER >= 0x0700)<br />
pThis->m_dwState |= WINSTATE_DESTROYED;<br />
#else // !(_ATL_VER >= 0x0700)<br />
HWND hWnd = pThis->m_hWnd;<br />
pThis->m_hWnd = NULL;<br />
pThis->OnFinalMessage(hWnd);<br />
#endif // !(_ATL_VER >= 0x0700)
---------------------------------------
WINCORE.CPP some code about unsubclasswindow
WNDPROC pfnWndProc = WNDPROC(GetWindowLongPtr(m_hWnd, GWLP_WNDPROC));<br />
Default();<br />
if (WNDPROC(GetWindowLongPtr(m_hWnd, GWLP_WNDPROC)) == pfnWndProc)<br />
{<br />
WNDPROC pfnSuper = *GetSuperWndProcAddr();<br />
if (pfnSuper != NULL)<br />
SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, INT_PTR(pfnSuper));<br />
}<br />
Detach();
----------------------------------------------------
1.Why in ATL when "pThis->m_pfnSuperWindowProc == ::DefWindowProc " not need restore old wndproc, but in MFC without this compare?
2.Now i write subclass window(mulriple, like DefWindowProc -> My subclass -> CWnd subclass(CWindow subclass) or DefWindowProc -> CWnd subclass(CWindow subclass) -> my subclass), and can safe unsubclass window. which above code i can modification and use in my code?
Thanks.
|
|
|
|
|
This is more of a Win32 question than a WTL Q, but I don't see a Win32 message board.
I have "Win32 Programming" by Rector & Newcomer which has been great (I bought it a year or two after it was published [1997], still quite useful).
Unfortunately it doesn't cover a lot of the common controls, most notably the listview and tab control. I am really looking for an in-depth book or article on common controls behavior & best programming practices. Built-in MSVC help / MSDN stuff just don't cut it & are both woefully inadequate (just about as useful for programming as a dictionary would be to tell you how to write sentences).
any suggestions? Right now I am going out of my mind trying to deal with MSDN docs.
--Jason
|
|
|
|
|
Actually the 'Visual C++ / MFC' forum would probably generate more answers. I can not recommend any books, because every book I have seen falls short on this subject, even books that are supposed to cover the subject. The best source is the MSDN, even though their examples are woefully inadequate. The next best source is the Web, most sights will just regurgitate what the MSDN says but some of them will actually give you new information. The last source is articles on programs that actually require the control that you need information on, you can find these at sights like CodeProject (CP).
Finding information on the Web is an art form and is all about how you ask the question.
INTP
Every thing is relative...
|
|
|
|
|
What methods do people here use for case-insensitive comparisons of STL strings? The std::wstring compare method is case-sensitive, and I want to use something portable if possible. Currently I use _wcsicmp(str1.c_str(), str2.c_str()) but this doesn't "feel" right...
The Rob Blog Google Talk: robert.caldecott
|
|
|
|
|
depends
derive from wstring. replace wcsicmp()?
Kuphryn
|
|
|
|
|
Robert Edward Caldecott wrote: What methods do people here use for case-insensitive comparisons of STL strings?
They ask the Guru[^]
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Robert Edward Caldecott wrote: but this doesn't "feel" right
Nor to me, but that's still what I use
|
|
|
|
|
I have created a COM component(dll). It consists of a simple ATL object which implements connection points (Say MyObject) and a Dialog(say MyDialog). Now, the client would call a function of MyObject like showmydialog(), which would display the Dialog. The Dialog contains buttons. Now when the buttons are clicked, the client should be informed.
My problem is that, the connections points are implemented in MyObject and the button is being clicked in MyDialog. How do I tell MyObject that the button has been clicked from MyDialog so that the client can be informed about it.
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Hello LazyKancha,
Seems quite straightforward to me as long as your dialog box is owned by the same thread as your client application's main UI thread.
I wrote an experimental ATL COM DLL plus a VB client app to demonstrate this. If you want it, pls email me directly :
bio_lim_2004@yahoo.com
Best Regards,
Bio.
|
|
|
|
|
I'm trying to implement some kind of locking and am having problem with iterating through a map that contains an object with a set. I can of course change my structure and to aviod the problem, but I'm REALLY curious why this is happening.
Below is an extract of the classes I have. The problem I have is with stripeLock, which is a map with pointer to clsReadWriteLock as value. The map key is stripe number, so I have one map entry for each stripe that is being locked. clsReadWriteLock contains a set, which keeps track of what jobs are locking the stripe and what type of lock. I can have multiple read jobs locking a same stripe.
class clsReadWriteLock {
private:
char lockType;
std::set<int> currentLock;
public:
clsReadWriteLock() {};
clsReadWriteLock(char reqType) {lockType = reqType; currentLock.clear();}
~clsReadWriteLock(){currentLock.clear();}
char getLockType() {return lockType;}
std::set<int> getCurrentLock() {return currentLock;}
};
class clsLocking {
private:
std::map<int, clsReadWriteLock*> stripeLock;
std::map<int, std::deque<int> > pendingWrite;
std::map<int, std::deque<int> > pendingRead;
public:
clsLocking() {};
~clsLocking(){};
std::map<int, clsReadWriteLock*> getStripeLock() {return stripeLock;}
char getStripeLockType(int stripeId) {return stripeLock[stripeId]->getLockType();}
std::set<int> getStripeLockSet(int stripeId) {return stripeLock[stripeId]->getCurrentLock();}
.....
}
Below is my main(), where I put values into the map. Stripe 1 is lock by jobs 31, 2 and 20, and stripe 2 is lock by job 4. However, when I try to iterate the map to print out the jobs tied to each stripe, the iterator for the map keeps giving me problem. After the 2nd for loop, value of mapIter->first gets changed if I try to pluck out the set that is in the map.
int main() {
clsLocking *lockObjects = new clsLocking;
lockObjects->acquireStripeLock(1,31,'r');
lockObjects->acquireStripeLock(1,3,'r');
lockObjects->acquireStripeLock(1,20,'r');
lockObjects->acquireStripeLock(2,4,'w');
map<int, clsReadWriteLock*>::iterator mapIter;
set<int>::iterator setIter;
set<int> setInMap = lockObjects->getStripeLockSet(1);
for (mapIter= lockObjects->getStripeLock().begin(); mapIter!=lockObjects->getStripeLock().end(); mapIter++) {
cout << "Stripe " << mapIter->first << " lock by ref Id";
set<int> setInMap = lockObjects->getStripeLockSet(mapIter->first);
for (setIter= setInMap.begin(); setIter!=setInMap.end(); setIter++) {
cout << " " << (*setIter);
}
cout << endl << "iter->first after loop Set " << mapIter->first << endl << endl;
}
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
I get the printout below and the program terminates.
Stripe 1 lock by ref Id 3 20 31
iter->first after loop Set 20
But if I pluck out the set outside the 1st for loop (by commenting and uncomment the 2 lines of codes as indicated above) mapIter->first remains the same and I get the following print out.
Stripe 1 lock by ref Id 3 20 31
iter->first after loop Set 1
Stripe 2 lock by ref Id 3 20 31
iter->first after loop Set 2
Why does setting the set within the loop upsets the mapIter?
|
|
|
|
|
I can't see any "<"s or ">"s.
Steve
|
|
|
|