|
If it's dialogbased control, you should receieve WM_INITDIALOG instead.
--
Please state the nature of your medical emergency.
|
|
|
|
|
I've come across an interesting problem, that I can't find a nice clean solution to.
The problem is how to manage adding and deleting objects from two vectors containing different objects.
Here's what I've got: A list of objects that contain an vector of ints as data points. The object holding the list has an vector of description objects containing information about each of the ints in the vector. They have a one to one relationship.
Now, I need to support adding or removing data points. What I can't figure out how to do is how to do this without a lot of overhead. My first thought was that I'd simply get the position of the data point description object that was added, then simply do a for_each over the list and call insert or erase for the appropriate position in the data points vector as required by the operation. Unfortunately both of those functions require an iterator to the item being erased, or the position the new item is being inserted at, not just it's index position.
Is there a way to do this without iterating over each data point vector? Since the position in the vector is going to be the same for all the objects, it seems like there should be a way to do this without all the manipulation.
Any ideas?
|
|
|
|
|
Mark Tutt wrote:
Here's what I've got: A list of objects that contain an vector of ints as data points. The object holding the list has an vector of description objects containing information about each of the ints in the vector. They have a one to one relationship.
Why didn't you make a map in this case ? a map of <DataPoints,DescriptObj> ????? or if Description objects must be a vector of points ...
<DataPoints,vector<DescriptObj>> ?
So you want to remove a specific data point , it's enough to reference the data point .
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
|
|
|
|
|
If I'm understanding your question, it was to avoid the memory overhead of needing the have the description objects for each of the data point vectors.
A map would involve copies of the objects, greatly increasing memory requirements. There may be 10's or 100's of thousands of data point vectors, and I only need one set of description objects. Even having a pointer to the associated description object for each data point essentially doubles the memory requirements.
Mark
|
|
|
|
|
And why not use instead vector of pointers to Data Points ?
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
|
|
|
|
|
I think you're missing the point of what I was trying to do...
Think of rows in a database table. All you need is the data, stored in rows, in a sequential list that you can move through. (leaving out indexing for now)
The column information, i.e. Name, data type, default value, nullable, etc. is going to be the same for every row in the table. You don't need to carry the weight of that data along with each row, so you just have one copy of this for the table.
Now assume you've got a doubly linked list containing vectors (rows) of 10 integers each. You've got another vector that contains the column information for the 10 columns.
If you want to delete the 8th column, you've got to delete the 8th int from each row in the list.
If you were to add pointers to the integers, you're not really changing the basic requirement of the operation, and you're adding additional memory overhead of a 32byte pointer to a 32byte int, i.e. doubling the memory requirement.
What someone else pointed out was that given that we know the position in our column information vector, we can use datapoint.begin()+pos to get the datapoint iterator to the datapoint position that we have to erase, so we can do something like this to perform a 'column delete' operation on our entire dataset.
for_each(datalist.begin(), datalist.end, erase(data.begin()+pos))
|
|
|
|
|
You can have constant-time access to the n-th element of a vector v via the iterator v.begin()+n . I agree with you that proably std::vector is the best choice for holding huge arrays of int s. As for the description list, you'd probably be better off using a std::map<int,CDescription> . Access is log-time given the position, and insertions and deletions are way cheaper.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
v.begin()+n was the answer I needed! Thanks!
|
|
|
|
|
Mark Tutt wrote:
v.begin()+n
Shi***t !!!!!!!! So that was that !!!!! *grin* (banging the head against the table)
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
|
|
|
|
|
Hello,
I’m facing some problem when I want to send the ICommand interface to the Client to work around the data fetched from the Database by OLEDB provider. I can successfully query the database and traverse through the Rowset at the Server end. When I’m packing the ICommand interface in a variant (as dispatch), at the Client End it throws the Error “No such interface supported”).
Here is the excerpt from my code
HRESULT CDAC::GetCommand (BSTR bstrQuery, VARIANT *pvarColumnInfo, VARIANT *pvarCmd)
{
HRESULT hr;
CSession session;
CCommand<cdynamicaccessor, crowset=""> objCmd;
LONG lRetVal;
try
{
USES_CONVERSION;
// Getting the Database connection by using the connection string
lRetVal = GetDBConnection();
// Creating the session for the transaction
hr = session.Open(m_objDBSrc);
CHECK_HR(hr);
// Create the Command by using the session for the query
hr = objCmd.Create(objSession, bstrQuery);
CHECK_HR(hr);
// Command Optimization
hr = objCmd.Prepare();
CHECK_HR(hr);
// Execute the Command
hr = objCmd.Open();
CHECK_HR(hr);
// Place the column Information in the OUT VARIANT
pvarColumnInfo->vt = VT_BYREF;
pvarColumnInfo ->byref = (PVOID)cmdObj.m_pColumnInfo;
// Place the command object in the OUT VARIANT
pvarCmd->vt = VT_DISPATCH;
pvarCmd->pdispVal = (IDispatch*)cmdObj.m_spCommand.Detach();
// Unable to get the ICommand, return the error
if(pvarCmd ->pdispVal == NULL)
{
hr = E_FAIL;
goto CLEANUP;
}
}
catch(_com_error &ce)
{
ERRBOX(ce.ErrorMessage(), "Error");
hr = ce.Error();
goto CLEANUP;
}
catch(...)
{
ERRBOX("Unknown Error", "Error");
hr = E_UNEXPECTED;
goto CLEANUP;
}
// Successfully Completed. Return Success code.
hr = S_OK;
CLEANUP:
return hr;
}
Can anyone suggest that where I’m failing or how to pass the Command information from the Server to Client?
Advance thanks,
Regards,
Ramesh M.
|
|
|
|
|
Try using QueryInterface to get the IUnknown of the cmd interface, and pass that through in your variant as an IUnknown, then at the client end use QueryInterface to get the ICommand interface back.
Steve S
[This signature space available for rent]
|
|
|
|
|
I've written a dll with ATL.I want to use it in Delphi.Is that possible?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Yes, you must make sure that the exported function have the same signature when you try to call them from delphi (i.e. make them __stdcall, _cdecl etc.)
Best regards,
Alexandru Savescu
|
|
|
|
|
Why sometimes vc++ couldn't find atlres.h ??
How to solve this problem !?
----------------------------
i am a beginner.
|
|
|
|
|
Mandalay wrote:
Why sometimes vc++ couldn't find atlres.h ??
Because you don't have WTL, or don't have the files in your INCLUDE path. See the VC forum FAQ, there's a FAQ on this topic.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
The only lame question is one that can't walk.
|
|
|
|
|
Hi All,
The prblem is as follows.
The component is an exe created using the ATL.
The client application for the component is working as expected Locally.when the component is tried for accessing from remote system, the error is generated.
The following are the setting done using the Dcomconfg tool
---On the server machine:--
1.under the "security" tab
a. "use custom access permission" option is selected and the client is added apart from the SYSTEM, INTERACTIVE & Network
2.under the "identity" tab
a. The "Interactive user" option is selected
--On the client machine--
1.Under the "General" tab
a.The "Default" option is selected from the combo box
2.Under the "Location" tab
a.Run on the following computer is selected and the remote computer name is specified.
--------------------------------------
The cleint code is as follows
In the OnInitDialog() function
////////////////////////////////////////////////////
m_host = "Wesley"
COSERVERINFO server_info;
ZeroMemory( &server_info, sizeof(server_info));
server_info.dwReserved1 = 0;
server_info.dwReserved2 = 0;
server_info.pwszName = m_host.AllocSysString();
server_info.pAuthInfo = NULL;
MULTI_QI mqi = { &IID_IDRMath,NULL, 0};
hr = CoCreateInstanceEx(CLSID_DRMath, NULL,
CLSCTX_REMOTE_SERVER, &server_info, 1, &mqi);
::SysFreeString(server_info.pwszName);
if(SUCCEEDED(hr))
{}
else if( (FAILED(hr))|| (FAILED(mqi.hr)) )
{
AfxMessageBox(IDS_E_NOCREATE, MB_OK | MB_ICONERROR);
EndDialog(TRUE);
return TRUE;
}
////////////////////////////////////////////////////
Is there any changes or addition i need to do in the code or with the DcomConfg tool?
Thanks
Chary.
|
|
|
|
|
Are you trying to create the control on a different machine on your network, or over the internet.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I'am trying to access the component on a remote machine on the network & not over the Internet.
The component is very simple their is no heavy business logic.It only takes the input,performs calculation & returns the value(ie like addition subtraction etc).
Thanks
Chary.
aishwarya
|
|
|
|
|
I generated an ATL Service EXE using the default wizard settings.
To this I added a CWindowImpl<> derived class. The (hidden) window is created when the service starts and receives messages from a worker thread. This all works fine as expected.
I have now added a simple ATL object through the wizard. When I try to create an instance of this object from a VB application (straight CreateObject call), the call seems to get stuck and never returns.
I'm assuming that the CWindowImpl message handler is conflicting with the default service one (so the messages to create the COM object are being ignored).
Is there a good sample anywhere that demonstrates how to have a service receive messages to a hidden window, whilst still being able to create instances of COM objects.
Michael
|
|
|
|
|
Hi Michael, (I am just throwing ideas here kind to see where's the problem)
1. Do you have a message loop in your service application? because your main thread needs a message loop to process message.
2. Your service is also the server, am I right? so if it fail with VB, try with C++ codes and check the reason why it fails.
3. You said that the hidden window messages are processed in a worker thread, I am not sure that you really need another thread (see 1)
Take care
ÿVOTD:5 "For to which of the angels did God ever say, "You are my Son; today I have become your Father"? Or again, "I will be his Father, and he will be my Son"? 6 And again, when God brings his firstborn into the world, he says, "Let all God's angels worship him." - Heb 1:5-6
|
|
|
|
|
why we are specifying this macro
|
|
|
|
|
This is an alias __declspec(novtable) , which instructs the compiler not to generate the corresponding vtable for a given class (which is safe as long as the class can not be instantiated, which happens e.g. with abstrat classes). Unless you're writing highly optimized code, there's no much reason to use it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Anyone have recommendations for recent STL reference books for an otherwise very experienced C++ programmer.
|
|
|
|
|
Have you looked at Scott Meyers Effective STL. It is very similar to his Effective C++ books.
It is not quite a reference book, but there are many good tips on how to use STL effectively and properly once you become familiar with the mechanics of the generic programming templates.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|