|
Heh - saved me looking it up
I think they did it that way to make it more difficult to determine the distance between iterators where it implies an inefficient implementation. For example, with linked list iterators (bidirectiuonal iterators?), it's an O(n) operation, whereas for random-access iterators, it's O(1).
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Yikes -- sorry for the long-winded response. I forgot to mention how to find the relative position between two non-random-access iterators. The trick is to use the std::distance function:
using namespace std;
typedef list<int> intlist;
int _tmain(int argc, _TCHAR* argv[]) {
intlist lst;
lst.push_back(1);
lst.push_back(2);
lst.push_back(3);
lst.push_back(4);
lst.push_back(5);
intlist::iterator iter = lst.begin();
++iter;
++iter;
cout << static_cast<int>(distance(lst.begin(),iter)) << endl;
return 0;
} Outputs 2 as expected.
A warning: For bidirectional iterators, distance is a linear-time operation.
- Mike
|
|
|
|
|
Thank you for replying.
Your response was neither long-winded, nor off-beat; to the contrary, I found it to be eloquent and informative.
Since I'm dealing with iterators of vectors, maps and multimaps, I'll restrict myself to the way iterators pertain to them.
There is this huge vector of strings I'm dealing with that acts as the repository of data. The data are classified (meaning, categorized and differentiated) according to certain criteria. For example, when the program is handling blue data, they are deposited to the vector, but their place in the vector is being recorded in the multimap relative to where (in the vector) they are located. This means there is a beginning and an ending point the multimap record for each set of color data. The same is done for red data, green data, yellow data (etc.).
The idea is that someone can go to the multimap and find where all the red data reside in the vector. (The same for blue data, and green data, etc.) This is because each entry in the multimap records a beginning and an ending point for each different set of data. Those beginning and ending points relate to positions in the vector, and herein is where I'm experiencing iterator nightmares.
While the entry of data to the vector is done sequentially through a series of "push_back()'s", the simple idea of using "v.begin()" and "v.end()" to register boundaries for the various colors, isn't turning out to be a walk in the park. For example, "v.end()" of one color does not always lend itself valid as far as where the next color should begin. IOW, "v,end()" is NOT necessarily "v.begin()" for the next color, which has caused me to look at everything pertaining to iterators.
This is why I was thinking of checking the value of "v.end()" iterator to determine if there might be some break, or incorrect value being passed to "v.begin()" for the next set of color data.
BTW, I'm just using colors figuratively to distinguish one set of data from another.
William
Fortes in fide et opere!
|
|
|
|
|
How come this code fails with the ATLASSERT( ::IsWindow(m_hWnd) );?
This code is in my CMainFrame and I'm tring to show a dialog.
CPrintDialog dlg(FALSE);
...
TCHAR sTitle[_MAX_FNAME] = {0};
AtlLoadString( IDR_MAINFRAME, sTitle, _MAX_FNAME );
dlg.SetWindowText( sTitle );error here
// Show it
Thank You
Bo Hunter
|
|
|
|
|
|
i didn't find any metohod in CListViewCtrl that can set the height of the item, can someone tell me how to do it? thanks in advance
|
|
|
|
|
The simpliest way is to use image list, like the following:
m_ImageList.Create(1,20,ILC_COLOR,1,1); // set height to 20 pixels
m_List.SetImageList(&m_ImageList,LVSIL_SMALL);
|
|
|
|
|
If ur ok 2 handle Ownerdraw then just override MeasurItem and set the item hight as u like by using the struct parameter in MesureItem.
|
|
|
|
|
Here in the (un)real world, I've just come across a problem. We have some COM+ components, including a database layer which uses OLE DB, via ATLDBCLI.H
There is a template class wrapping CCommand, which depending on parameters will set required properties. One of these is DBPROP_SERVERDATAONINSERT, which is useful when using server-generated data, like IDENTITY columns.
However, I now find that in cases where this is erroneously added (ie no insert is allowed), this causes the Open to fail with a multiple-step error, and by the time I find out, I can't get any more detailed information.
With MDAC 2.7, this wasn't an issue, but it seems to be so now with 2.8.
Is anyone else aware of this? I haven't looked in the MS newsgroups for a little while (although I use CP every day..), but I thought I'd raise it here in case anyone else is having similar issues.
I'm slowly going through the affected code, which, thankfully, is only in one component, albeit spread over 20+ files.
Steve S
|
|
|
|
|
i compiled a atl project to implement dhtm binary behavior by vc6.0.
but, the error, 'IElementBehavior' : base class undefined, had appeared.
i included mshtml.h in my project.but i find that the interface 'IElementBehavior' is not in it. why?help me.thanks.
vc++6.0 winxp pro
|
|
|
|
|
Hi,
How can i get the reference to an activex control using handle.
Regards
Abhay
eeeshwar
|
|
|
|
|
Hi.
I have some ATL dialog which hosts web browser on it and I would wish to disable the context menu opened on the web page running in it. I have no
option to do it with script built in on the web page itself - cause this
would get changed dynamically and I have no control on its content. Is
there any technique to do this from ATL dialog itself?
Thanks
|
|
|
|
|
I have made a dialog-based WTL application in VS.NET.
I'm trying to make one edit window act as a command prompt. I would therefore like to receive a notification in the parent dialog when the user presses carriage return in the edit control.
I have tried to use the example by Kristian Lippert in his article Subclassing controls in ATL dialogs using WTL[^] but with no luck. It seems that the sub-class does not receive the WM_KEYDOWN or WM_CHAR at all (does receive WM_CHAR when typing some text).
First I thought that I could just use the IDOK-notification and use the control ID or the control hWnd parameters of the notification. But they are "empty" no matter which control has the focus when CR is pressed.
Any help appreciated.
Below is my control-template:
#define EN_GOT_RETURN 0x1000<br />
<br />
template <class T><br />
class CEditEnterNotificationT : public CWindowImpl<CEditEnterNotificationT<T> , CEdit><br />
{<br />
public:<br />
BEGIN_MSG_MAP(CEditEnterNotificationT< T >)<br />
TRACEMSG("CEditEnterNotification");<br />
MESSAGE_HANDLER(WM_CHAR, OnChar)<br />
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)<br />
END_MSG_MAP()<br />
<br />
CEditEnterNotificationT(HWND hWnd = NULL){ }<br />
<br />
CEditEnterNotificationT< T >& operator=(HWND hWnd)<br />
{<br />
m_hWnd = hWnd;<br />
return *this;<br />
}<br />
<br />
LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
switch (wParam)<br />
{<br />
case '\r':
ATLTRACE("WM_CHAR - CR\n");<br />
return 0;<br />
break;<br />
}<br />
return DefWindowProc(uMsg, wParam, lParam);<br />
}<br />
<br />
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
switch (wParam)<br />
{<br />
case VK_RETURN:<br />
ATLTRACE("WM_KEYDOWN - CR\n");<br />
::PostMessage (m_parent, WM_COMMAND, MAKELONG(EN_GOT_RETURN, this->m_dlgItem), LPARAM(this->m_hWnd));<br />
bHandled = TRUE;<br />
return FALSE;<br />
}<br />
return DefWindowProc(uMsg, wParam, lParam);<br />
}<br />
<br />
BOOL AttachToDlgItem(HWND parent, UINT dlgID)<br />
{<br />
m_dlgItem = dlgID;<br />
m_parent = parent;<br />
HWND hWnd = ::GetDlgItem(parent,dlgID);<br />
return SubclassWindow(hWnd);<br />
}<br />
private:<br />
UINT m_dlgItem;<br />
HWND m_parent;<br />
};<br />
<br />
typedef CEditEnterNotificationT<CWindow> CEditEnterNotification;<br />
|
|
|
|
|
your subclassed control should handle WM_GETDLGCODE to tell the parent dialog that it "DLGC_WANTALLKEYS"
|
|
|
|
|
Thanks alot. That did the trick.
I don't think it's mentioned in the book (Pezold).
Happy now
|
|
|
|
|
Make sure that Want Return is set in the dialog editor.
|
|
|
|
|
This is by far the weirdest bug I’ve ever encountered! We’ve used an ATL NT Service module (multithreaded) to synchronize the physical clocks of the nodes in our network with the (so called) master time server. The service runs fine for 49,7 days, but then sh*t happens. RPC pulls a heavy CPU load for a few seconds and right afterwards the servers seems to show some nasty unexpected behavior. The service runs 100% CPU until a new client connects and asks the masters time, then the service continues normally for a few minutes and restarts pulling 100% CPU load. The weirdness is that “if” we set the clients interval at 5 minutes it all seems to run fine. I’m aware of the 32 bit rollover.
Concluding: for some reason the service starts pulling 100% CPU on the main thread. This because we couldn’t see (after profiling) any weird behavior in our own code. Debugging the host process doesn’t reach any further then the message loop where we expect the weirdness to happen.
Got a clue?
|
|
|
|
|
My applciation requires generating various wizards (either stacked dialog boxes / property sheets if MFC) using ATL. I am new to ATL. Can any body tell me how to display dialog box in ATL and followed by stacked dialogs? Any samples would be greatly appreciated.
Thanks.
Help Ever, Hurt Never
|
|
|
|
|
|
I am tring to do a little WTL and am getting a undeclared identifier
for CFile. If I try to include afx.h then ATL complanes that I am
not allowed to include windows.h, but I am not using the windows.h
include. What do I need to do.
Thank You
Bo Hunter
|
|
|
|
|
WTL doesn't have a CFile class. If you want to use MFC and WTL together, start a new MFC project, add support for ATL in the wizard, then add the WTL headers manually to stdafx.h.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Background:
I've finally feel comfortable with c++ programming and now i want to get into 2D Game Programming. I'm using the free Borland compiler from the Command Prompt for my studies and so that makes it even harder.
Problem:
Since I'm trying to learn, the best way is to study the code and learn from it, however, all the DirectDraw/DirectX examples are written in VC++.
Question:
Can I implement DirectX, create a GUI, and use ATL/WTL/STL libraries to create 2D games such as Tetris using this compiler?
Follow-up Challenge:
If someone is movated to do so, can I just see a "skeliton" window using Direct X and DirectDraw in a GUI window using ATL/WTL/STL?
Summary:
Also, If I don't know what I'm talking about feel free to call me an idiot but if you do, also please correct me.
When in doubt, shout it out because the worst that could happen is waking up with a headache and a hospital bill.
|
|
|
|
|
How can I manipulate BSTR typed string in ATL3COM?
Can I convert it to some manipulateable String type?
If yes in which?
Kindly guide me.
Kind Regards
Atif
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
You may want to use the following functions to convert from/to char*/BSTR:
_com_util::ConvertBSTRToString(BSTR pSrc)<br />
_com_util::ConvertStringToBSTR(const char *pSrc)
Hope this helps.
-Tareq
|
|
|
|
|
|