|
I just had a peek at the implementation of CAxDialogImpl. I saw that it uses CAxWindow (and CAxWindow2) for hosting the actual controls. It does not host the controls directly, hence you'll always get at least one window per activex control.
There's not much you can do, unless you implement your own dialog which hosts the controls directly (tricky business).
But what's so wrong with an extra window? Your control will function properly!
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
This is bad news, because my intentions were to experiment with a GUI completely built in flash, and I can't do it with window background around it (if I want to use WTL, that is).
Nonetheless, I thank you for your efforts and clarifications!
But before I give up on WTL to do this job, can you give me some hints about hosting the control directly? How much coding and knowledge does it involve?
|
|
|
|
|
Forjer wrote:
This is bad news, because my intentions were to experiment with a GUI completely built in flash, and I can't do it with window background around it (if I want to use WTL, that is).
Interesting concept. How exactly is the flash stuff supposed to be laid out? Should it cover the entire client area, or can you instantiate windowless flash controls and tie them together in some way?
I also don't think you can "escape" the extra window in MFC. I'm not 100% sure about how MFC implements active x control hosting, but I suspect it does it similar to ATL/WTL.
Forjer wrote:
But before I give up on WTL to do this job, can you give me some hints about hosting the control directly? How much coding and knowledge does it involve?
That's quite a daunting task I imagine. There are a number of interfaces you'd need implement. ATL::CAxHostWindow is a good place to start I guess. IIRC, this is the window I've been talking about which hosts the actual control. Perhaps you could derive from it or use code from it to achieve your goal.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Jörgen Sigvardsson wrote:
Interesting concept. How exactly is the flash stuff supposed to be laid out? Should it cover the entire client area, or can you instantiate windowless flash controls and tie them together in some way?
There will be only one flash control which will be the entire client area. Flash can communicate with its hosting program via a special command in its ActionScript, which fires an event. Together with the interface we get a two-way communication.
Jörgen Sigvardsson wrote:
I also don't think you can "escape" the extra window in MFC. I'm not 100% sure about how MFC implements active x control hosting, but I suspect it does it similar to ATL/WTL.
When I try it in MFC I get a debug output of 'control wants to be windowless'. When I override WM_ERASEBKGND, the flash control has no window around it.
A search for the debug message led me to the file occsite.cpp, which led me to the ATL class IOleInPlaceObjectWindowlessImpl.
I don't know if I can make something useful from the information, as I'm very new to the COM architecture, but if I do I'll probably write an article
|
|
|
|
|
Forjer wrote:
There will be only one flash control which will be the entire client area. Flash can communicate with its hosting program via a special command in its ActionScript, which fires an event. Together with the interface we get a two-way communication.
CAxWindow will do just fine for you, honest! CAxWindow offers an interface much like CWindow/CWnd . Just make it span over all your client area.
First create it with (pseudo code) CAxWindow::Create(hWndParent, clientrect, _T("ProgId.For.Flash"), WS_CHILD | WS_VISIBLE); . Then use CAxWindow::QueryControl to acquire a reference to an interface, which you can advise for events.
I'd suggest you create a WTL SDI-project using the WTL wizard. In the wizard, uncheck the "use a view window" checkbox. Click OK to generate project. Then in CMainFrame::OnCreate at the bottom, do something like this:
m_hWndClient = m_activex.Create(*this, rcDefault, _T("flash.prog.id or {clsid}"), WS_CHILD | WS_VISIBLE);
UpdateLayout(); The frame window will then resize your activex control automatically. About _T("flash.prog.id or {clsid}") see the Create method for CWindow in the MSDN docs. CAxWindow interprets the window text as a control class id/prog id. CAxDialogImpl uses this "trick".
It *will* work, and it'll save you from reimplementing the entire OLE hosting code (which is a lot, and not the easiest thing if you're new to COM).
Forjer wrote:
A search for the debug message led me to the file occsite.cpp, which led me to the ATL class IOleInPlaceObjectWindowlessImpl.
That impl stub is used by controls that implement activex interfaces - the interface IOleInPlaceObjectWindowless is used by the container to communicated with the control.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Your efforts are very kind, but I think you missed the point. If I understand the code correctly, it won't make the control windowless, which is my *only* problem.
I have to make it windowless because I only want to show the flash GUI and nothing else. The only way I can achieve this without a windowless control would be to build a square GUI - but that would be unesthetic.
|
|
|
|
|
Ah.. then I think you're out of luck. Now, I may be wrong on this one, but I can't seem to find anything in the OLE/activex interfaces which indicate non rectangular controls.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
I Developed a com service using ATL and added one interface to it. During the development time the serivce was registered as /RegServer.
For Release version i need to register it as /Service and when i do so i get the following error.
0x80004015 The class is configured to run as a security id different from the caller
what should i do to solve this problem thank you.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
You need admin rights.
When most installtion programs run into this kind of situtation, they just tell the user they don't have enough rights.
I don't think there's a way around it - as that would be insecure.
|
|
|
|
|
I guess i found the solution, i was not registering the right version as /service.
If you try to register a debug build as /service it fails and gives that error message.
I compiled the code with mindependency release then tried to register it. It got registered and it works.
Thanx for replying anyways.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
There is this huge STL map created inside a class object that is unique (meaning, there is only ONE such class object).
It reaches a point where I DON'T want to add anything more to the map, but would like to keep reusing it (meaning, empty out some of its content and keep the map for reuse). Because of its size, it seems almost impractical to do a "find" on the thousands of keys I would like to eliminate, thereby making room for the new entries I would like to insert.
I am looking for a way to accomplish what I'm trying to do, without having to make C++ do it (meaning, I would like to see if there is a way to have STL take care of the situation itself).
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
check out STL algorithms. (use remove_if())
sample codes below.
using namespace std;
int main()
{
vector<int> coll;
INSERT_ELEMENTS(coll,2,6);
INSERT_ELEMENTS(coll,4,9);
INSERT_ELEMENTS(coll,1,7);
PRINT_ELEMENTS(coll,"coll: ");
//remove all elements with value 5
vector<int>::iterator pos;
pos = remove (coll. begin(), coll.end(), //range
5); //value to remove
PRINT_ELEMENTS(coll,"size not changed: ");
//erase the "removed" elements in the container
coll. erase (pos, coll.end());
PRINT_ELEMENTS(coll,"size changed: ");
//remove all elements less than 4
coll.erase(remove_if (coll.begin(), coll.end(), //range
bind2nd(less<int>(),4)), //remove criterion
coll.end());
PRINT_ELEMENTS(coll,"<4 removed: : ");
}
for replacing element in container. Use replace_copy_if(...)
BTW, my sample code is not using std::map but more or less the same I suppose.
Hope this helps.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanks for replying.
Yes, I recognized your sample as the one on page 379 of Josuttis' book, "The C++ Standard Library." However, if you were to look on the page before that, page 378 (the third bullet from the bottom), it reads, "Due to modifications, you cannot use these algorithms for an associative container." One of the algorithms it is referring to, is "remove_if()".
Map is an associative container, and therefore you cannot use "remove_if()" on it!!
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
Map is an associative container, and therefore you cannot use "remove_if()" on it!!
Well, that's a finer version of the truth. The truth is that associative containers are designed such that client code cannot reorder the elements. The sole reason for that design reason was to allow implementations to use binary search trees and hash maps - data structures which does not allow arbitrary order of elements.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Write your own remove/filter function?
template <typename Coll, typename Predicate>
void filter(Coll& coll, const Predicate& p) {
typename Coll::iterator i = coll.begin(), end = coll.end();
while(i != end) {
if(p(*i))
i = coll.erase(i);
else
++i;
}
}
struct MyFilter {
bool operator()(const std::pair<Key, Value>& v) const {
}
};
filter(myColl, MyFilter());
That ought to work?
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Thanks for replying.
What you have described above, looks very similar to the "for_each" algorithm, which is what I'll probably end up using in combination with "stable_partition".
William
Fortes in fide et opere!
|
|
|
|
|
I'm sorry, but stable_partition can't be used with associative types, as you cannot control the order of the items (which is what stable_partition does).
Also, be aware that for_each cannot be used to manipulate the collection which you iterating. You may manipulate the individual items, but not the overall collection, because you could end up screwing up iterators for for_each.
--
They say the most horrible things, but I hear violins.
When I close my eyes, I'm at the center of the sun.
|
|
|
|
|
Thanks again for replying.
Having reread my earlier reply, I can see where I misrepresented my intent in the ways I proposed using "stable_partition" along with "for_each" (and I'm glad you caught me on that point).
My thoughts are (and it starts off this way), "OK. I am thinking about using a list (or a vector) container to arrive at a workable solution for what I'm doing. The map container currently being used, is so huge, I definitely have to find another way to ease its load (meaning, not adding anything more to it) while NOT creating another 'map' as part of the solution. A better solution (it seems) must come with the ability for that next container to be able to expand and contract (considering maps do not lend themselves handily for doing that, hence the 'vector', or the 'list' is what comes to mind). However, I'd like to obtain the ability to do bsearch on that new container, hence the thought about 'stable_partition'." (End of Part 1.)
"Part 2" deals with the use of the "for_each" algorithm with regards to the continuing support of the map, currently being used. Through the use of "for_each" with its function object, I am thinking about doing "in-place" updates, thereby freezing the size of the map (so to speak), making no more addition to it.
Therefore, my proposed solution to the current map situation lies in using both "for_each" and "stable_partition" combined, but in different routines.
I'm glad you caught me on that point because I can see where some explaining was in order.
William
Fortes in fide et opere!
|
|
|
|
|
Hi out there!
What happens, if I initialize a std::istrstream with a NULL - pointer?? I guess, it could happen something like
1. will throw immediately.
2. will throw, when I try to >> somevalue
3. will show undefined behaviour (because it tries to guess the size of the string (char*)NULL points to ... and this is just undefined)
4. will work without problem and show standard behaviour (read: same behaviour as if I'd pass a valid char* and had read past the end of the stream)
Hope someone can clear this topic for me.
Best regards, Ralph
P.S: Sorry for posting this in THE LOUNGE first ... I'm not that much used to this !
|
|
|
|
|
Hi,
I have created a com server using ATL as Windos NT service.
I also added an interface to the server i.e STA interface.Every thing works fine... The com server is maintaining a socket connection in a worker thread.
My problem starts like this... I have written a client application that uses the interface... When two clients are open no problem, if three clients are open no problem, then if i start closing each client one by one (in any order) then no problem. When i close the last client application along with the client ther service also terminates (it gets out of the message loop) and hence the socket connection. I want to maintain the socket connection even if no client is using the interface....
I am desperate for an answer as i could not find any solution.
Setup
1.visual C++, version 6.0
2.Project type ATL COM Service.
3.How it was executed the service? By clicking run button on the toolbar.
one more thing,
How do i make the service startup when windows boots?
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Hi all
I wrote a pretty big MFC application. I have many frames and UI controls, I've changed the default message routing a bit. It works fine except one little problem: when i moving the mouse over its windows - the CPU jumps upto 100%. It happens as result of UPDATE_COMMAND_UI notifications.
Does anybody met such problem? know any utilities that can help to monitor the app and see what catches the CPU?
thanks.
|
|
|
|
|
Hi all. As I'm haveing problems with OLE DB database access, and I've tried everything that came to my mind to solve the problems, I would appreciate if someone gives me a sample of a working application (or a link where I can find it) so I can see what's I'm doing wrong. I have a .mdb that I really want to update, but I can't!! I can read it, i can insert a new record, but i can't update the record. I use ATL 7.1 without the attributed code, just plain wizard generated code plus additions.
Thanks in advance
PS: I forgot to say that articles submited to CP didn't help much in discovering what's wrong, neither MSDN helped me.
"semper aliquid haeret", Bacon.
-- Sebastián.
|
|
|
|
|
This book could be of some help:
"Database programming with Visual C++ 6" by Lyn Robison, published by Sams.
|
|
|
|
|
Thanks, but I don't want a book, and seems a bit outdated. I just need some working code to see how it works.
"semper aliquid haeret", Bacon.
-- Sebastián.
|
|
|
|
|
I have had success with the Microsoft example OnlineAddressBook from the MSDN library (comes with Visual Studio .NET Enterprise). I believe you can download it off the msdn site as well. It shows record retrieval, update, delete etc...
|
|
|
|
|