|
Maybe your WINNT version macro is set too low. Change it from 0x0400 to 0x0500.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I'm having a bit of a problem with vector iterators. I've got the following defined:
<br />
std::vector<TrayIcon*> trayIconList;<br />
typedef std::vector<TrayIcon*>::iterator trayIconItem;<br />
Where TrayIcon is class that has GetWnd() and GetID() methods. So, I've created the following function:
<br />
trayIconItem FindTrayIcon(NOTIFYICONDATA *iconData)<br />
{<br />
trayIconItem iter;<br />
<br />
for (iter = trayIconList.begin(); iter != trayIconList.end(); iter++)<br />
{<br />
if (iter->GetWnd() == iconData->hWnd && <br />
iter->GetID() == iconData->uID)<br />
break;<br />
}<br />
<br />
return iter;<br />
}<br />
I'm assuming I have to dereference the 'iter' iterator, since during the compile, I get the following:
<br />
main.cpp: In function `trayIconItem FindTrayIcon(NOTIFYICONDATA*)':<br />
main.cpp:459: request for member `GetWnd' in `<br />
*(&iter)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator->()<br />
const [with _Iterator = TrayIcon**, _Container = std::vector<TrayIcon*,<br />
std::allocator<TrayIcon*> >]()', which is of non-aggregate type `TrayIcon*'<br />
main.cpp:460: request for member `GetID' in `<br />
*(&iter)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator->()<br />
const [with _Iterator = TrayIcon**, _Container = std::vector<TrayIcon*,<br />
std::allocator<TrayIcon*> >]()', which is of non-aggregate type `TrayIcon*'<br />
Can someone please point me in the right direction?
Thanx!
Chris
|
|
|
|
|
Replace every occurrence of
iter-> with
(*iter)-> (remember that you have iterators to pointers.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you much!
Chris
|
|
|
|
|
I create a windows explorer like application. When an item is selected in
treecontrol, the corrosponding items are shown in the list view. The problem
is that when I select an item in the list view, all icons are displayed correctly
except for .htm and .html files. The file assosiations are ok. The code I use is
struct LISTITEMINFO {<br />
LISTITEMINFO() {memset(this, 0, <br />
<br />
sizeof(LISTITEMINFO));}<br />
ITEMIDLIST* lpi;<br />
IShellFolder* pParentFolder;<br />
TCHAR szName[_MAX_PATH];<br />
int iIcon;<br />
DWORD dwAttrs;<br />
};<br />
<br />
<br />
BOOL CMainFrame::FillListView(CTreeItem hItem, SHCONTF shFlag)<br />
{<br />
CWaitCursor wait;<br />
LPITEMIDLIST pidlFolder;<br />
<br />
TVITEM tvi;<br />
tvi.mask = TVIF_PARAM; <br />
tvi.hItem = hItem;<br />
if (!m_FolderTree.GetItem(&tvi)) {<br />
return FALSE;<br />
}<br />
TREEITEMINFO* pItem = (TREEITEMINFO*) tvi.lParam;<br />
pidlFolder = pItem->pidlFullyQual;<br />
IShellFolder* piFolder;<br />
CComPtr<IShellFolder> piDesktopFolder;<br />
::SHGetDesktopFolder(&piDesktopFolder);<br />
<br />
HRESULT hr = piDesktopFolder->BindToObject(pidlFolder, <br />
<br />
NULL, __uuidof(IShellFolder), reinterpret_cast<void**>(&piFolder));<br />
if (FAILED(hr)) <br />
piDesktopFolder.QueryInterface(&piFolder);<br />
<br />
IEnumIDList* piEnum;<br />
hr = piFolder->EnumObjects(NULL, shFlag , &piEnum);<br />
if (FAILED(hr)) return hr;<br />
<br />
INT iOverlayIndex(0);<br />
DWORD dwStyle(0);<br />
LPITEMIDLIST pidlNext;<br />
SHFILEINFO sfi;<br />
INT nCounter = 0;<br />
<br />
while (S_OK == piEnum->Next(1, &pidlNext, NULL))<br />
{<br />
LPITEMIDLIST* ppidlChild = new <br />
<br />
LPITEMIDLIST(pidlNext);<br />
if (NULL == ppidlChild) return E_OUTOFMEMORY;<br />
LPITEMIDLIST pidlAbsChild;<br />
pidlAbsChild =Pidl_Concatenate(pidlFolder, <br />
<br />
*ppidlChild);<br />
<br />
sfi.iIcon = 0;<br />
<br />
<br />
::SHGetFileInfo((LPCSTR)(LPCITEMIDLIST)pidlAbsChild, 0, <br />
&sfi, sizeof(SHFILEINFO), <br />
SHGFI_PIDL | SHGFI_DISPLAYNAME | <br />
<br />
SHGFI_ATTRIBUTES | <br />
SHGFI_SYSICONINDEX | <br />
<br />
SHGFI_SMALLICON);<br />
<br />
if (0xFFFFFFFF == sfi.dwAttributes)<br />
sfi.dwAttributes = 0;<br />
<br />
dwStyle = sfi.dwAttributes & SFGAO_GHOSTED ? <br />
<br />
LVIS_CUT : 0;<br />
dwStyle |= sfi.dwAttributes & SFGAO_LINK ? <br />
INDEXTOOVERLAYMASK(2) : 0;<br />
dwStyle |= sfi.dwAttributes & SFGAO_SHARE ? <br />
INDEXTOOVERLAYMASK(1) : 0;<br />
<br />
LISTITEMINFO* pItemInfo = new LISTITEMINFO;<br />
pItemInfo->dwAttrs = dwStyle;<br />
pItemInfo->iIcon = sfi.iIcon;<br />
pItemInfo->lpi = pidlAbsChild;<br />
pItemInfo->pParentFolder = piFolder;<br />
lstrcpy(pItemInfo->szName, sfi.szDisplayName);<br />
<br />
LVITEM lvInsert;<br />
lvInsert.cchTextMax = _MAX_PATH;<br />
lvInsert.iImage = <br />
<br />
I_IMAGECALLBACK;<br />
lvInsert.iItem = nCounter++;<br />
lvInsert.iSubItem = 0;<br />
lvInsert.pszText = LPSTR_TEXTCALLBACK;<br />
lvInsert.mask = <br />
<br />
LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;<br />
lvInsert.lParam = <br />
<br />
(LPARAM)pItemInfo;<br />
<br />
int n = m_ListView.InsertItem(&lvInsert);<br />
m_ListView.AddItem(n, 1, LPSTR_TEXTCALLBACK, <br />
<br />
I_IMAGECALLBACK);<br />
m_ListView.AddItem(n, 2, LPSTR_TEXTCALLBACK, <br />
<br />
I_IMAGECALLBACK);<br />
m_ListView.AddItem(n, 3, LPSTR_TEXTCALLBACK, <br />
<br />
I_IMAGECALLBACK);<br />
delete ppidlChild;<br />
}<br />
piEnum->Release();<br />
return TRUE;<br />
}<br />
<br />
and function is called using FillListView(pnmtv->itemNew.hItem, <br />
<br />
SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN | <br />
<br />
SHCONTF_FOLDERS)
any help?
Thanks
|
|
|
|
|
I Implement IDocHostUIHandler interface .
I handler Event when user right click Pic or url or any where in Webbrowser .
But I can't handler user right click flash control in webbrowser
why ?
Who have better method to resolve it?
Thanks
I believe I can touch the sky
|
|
|
|
|
What are the best online C++ tutorials for experienced VB developers who need to learn C++ fast. In other words, they need one that is both clear and concise.
To put this in perspective, I have a friend who is a VB developer who's been thrown in at the deep end. This is what he said:
"My boss agreed to write a component for a company that wanted it as a small download. He incorrectly thought you didn't need the VB VM library (weighing in at 1.6 MB) and that we could do it in VB6.
So we'll have to do it in VC++ ver6. What he thought might take 3 days will now probably take 3 weeks - talk about a loss leader! I haven't got the first clue about VC++. I did a little C on UNIX back in my 2nd year ar Uni and placement year, but that was 13 years ago. I may need to pick your brains a little, concerning the MFC. Is it quite large ? Our component has to be under 1MB to download, so the client thought that would rule out using the MFC.
Basically, the component has no interface, it just needs to sit in the system tray and every hour interrogate a fixed URL to determine if there are any changes to the page. If so, the system tray icon should change colour and should a bubble with some text in it and then (when clicked on) open the browser and take the user to that page. It needs to store the URL and frequency with which to check it in an ini file or the registry.
We've got some code to handle the system tray icons and I've got some code to download a web page to a file, but then we need to parse the text for any changes. Not sure how they'll be determined yet. We're not sure what we'll need to do in terms of a setup and deployment package. Will everything needed be built into the .exe file or will it have dependencies on anything such as the MFC dll(s) ?"
I've suggested using ATL and, in fact, there's an example on Code Project that appears to do exactly what he wants.
I suppose the question is really: "How little C++ does he need to know to achieve his objective using ATL?"
I have extensive experience with MFC, but nothing in components (beyond Automation Servers). I've done a little ATL but not commercially.
Kevin
|
|
|
|
|
Here are some excellent C++ reference sites.
CodeProject
CodeGuru
CPlusPlus
Kuphryn
|
|
|
|
|
Yes. But I was really looking for specifc recommended articles.
Kevin
|
|
|
|
|
Well, maybe this is not an option, but if your friend's boss recognizes it's been his fault maybe he'd be willing to hire this little job to some freelance programmer --probably the most cost-effective solution. Later on they can take the code and maintain it themselves, out of time pressure.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hello i has created a vector and i declared as follow:
struct CharacterCoordinate<br />
{<br />
GLfloat xpos;<br />
GLfloat ypos;<br />
<br />
};<br />
<br />
std::vector< CharacterCoordinate > CharacterPos;<br />
and i call with
void Scene::CreatInitCharacter(int InitAmount)<br />
{<br />
<br />
<br />
srand(time(0)); <br />
<br />
CharacterCoordinate *PtrCreat;<br />
<br />
for(int i=0;i<InitAmount;i++)<br />
{<br />
PtrCreat = new CharacterCoordinate();
CharacterPos.push_back(PtrCreat);<br />
<br />
PtrCreat->xpos = ( ( 1 + rand( ) % 120 ) - 70 );<br />
PtrCreat->xpos = ( ( 1 + rand( ) % 120 ) - 70 );<br />
<br />
<br />
<br />
<br />
<br />
<br />
}<br />
<br />
}<br />
and i have this message error
error C2664: 'push_back' : cannot convert parameter 1 from 'struct CharacterCoordinate *' to 'const struct CharacterCoordinate &'<br />
Reason: cannot convert from 'struct CharacterCoordinate *' to 'const struct CharacterCoordinate'<br />
No constructor could take the source type, or constructor overload resolution was ambiguous<br />
and i want to store in the structur but when i want to store in the vector
|
|
|
|
|
You have defined a vector of struct CharacterCoordinate s, but you are trying to add a pointer to such a structure into the vector. Change the code in CreatInitCharacter to:
CharacterCoordinate Creat;
for(int i=0;i < initAmount; ++i)
{
Creat.xpos = ( ( 1 + rand( ) % 120 ) - 70 );
Creat.ypos = ( ( 1 + rand( ) % 120 ) - 70 );
CharacterPos.push_back(Creat);
}
|
|
|
|
|
When I wanted to read the vector of structur i have error:
<br />
for(int Index=0;Index<CharacterPos.size() ; Index++)<br />
{<br />
glTranslated(CharacterPos[Index]->xpos,CharacterPos[Index]->ypos , 0 );
}
void Scene::CreatInitCharacter(int InitAmount)<br />
{<br />
<br />
<br />
srand(time(0)); <br />
<br />
CharacterCoordinate PtrCreat;<br />
<br />
for(int i=0;i<InitAmount;i++)<br />
{<br />
PtrCreat = new CharacterCoordinate();
<br />
<br />
PtrCreat.xpos = ( ( 1 + rand( ) % 120 ) - 70 );<br />
PtrCreat.ypos = ( ( 1 + rand( ) % 120 ) - 70 );<br />
CharacterPos.push_back(PtrCreat);<br />
<br />
}<br />
<br />
}<br />
i have this error
62) : error C2819: type 'CharacterCoordinate' does not have an overloaded member 'operator ->'<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\scene.h(21) : see declaration of 'CharacterCoordinate'<br />
(62) : error C2227: left of '->xpos' must point to class/struct/union<br />
(62) : error C2819: type 'CharacterCoordinate' does not have an overloaded member 'operator ->'<br />
(21) : see declaration of 'CharacterCoordinate'<br />
(62) : error C2227: left of '->ypos' must point to class/struct/union<br />
88) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct CharacterCoordinate *' (or there is no acceptable conversion)<br />
|
|
|
|
|
Use CharacterCoordinate[index].xpos and CharacterCoordinate[index].ypos to access the members and get rid of the new . The CharacterPos.push_back() takes care of allocating memory space when necessary. The vector stores actual structs, not pointers to them.
|
|
|
|
|
i make this modification but the error is be here also
(62) : error C2275: 'CharacterCoordinate' : illegal use of this type as an expression<br />
(21) : see declaration of 'CharacterCoordinate'<br />
(62) : error C2228: left of '.xpos' must have class/struct/union type<br />
(62) : error C2275: 'CharacterCoordinate' : illegal use of this type as an expression<br />
(21) : see declaration of 'CharacterCoordinate'<br />
(62) : error C2228: left of '.ypos' must have class/struct/union type<br />
|
|
|
|
|
|
For a module I want to write my own stream class.
Although not identical the following example illustrates what I want to do:
suppose you have a class representing a printer:
class Printer { ...};
I want the user of this class to send data to this class using the << operator, so that any data type/class, for which << is defined on streams, e.g.
Printer myPrinter (printerName);
PrinterStream &printStr = myPrinter.getStream();
printStr << "Hello world" << 123 << std::endl;
So, how can I write my own stream class so that I can intercept the data send to printStr?
I probably need to inherit from some STL stream class, but I don't know where to start. Is this something that can be done easily, or is this almost impossible?
Another alternative (although I don't really like it) is to let my getStream() method to return a stringstream. My class then simply needs a kind of flush method to get the data from the stringstream, send it to the output where I want it and then empty the stringstream. I don't like this alternative because it exposes the fact that's a stringstream to the caller. Also I cannot add my own output manipulators (e.g. to set the font or color) to the stream.
Does anybody know a simple solution, or point me to an article that explains how to write your own stream class?
Thanks in advance.
Enjoy life, this is not a rehearsal !!!
My Articles:
- Implementing a Subject/Observer pattern with templates
- Different ways of writing class factories
- AutoRunner: a template class to automatically run start- and cleanup-code in code blocks
</
|
|
|
|
|
use Subject/Observer pattern
|
|
|
|
|
Writing your iostream class is not hard, but it's not trivial either. Basically you have to make CPrinter derive from std::ostream and provide a special std::streambuf class:
class CPrinter: public std::ostream
{
typedef std::ostream super;
CPrinterStreambuf sbuf;
public:
CPrinter():super(&buf){}
...
}; Now, std::ostream handles all the IO via the provided CPrinterStreambuf object, which derives from the virtual base class std::streambuf . Depending on where you want the bytes to be sent, you might consider writing CPrinterStreambuf from scratch or deriving from say std::filebuf or std::stringbuf . Now you can intercept outgoing data by overriding overflow and sync . Here[^] is an example provided by MS that might be useful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
hello
i create a vector where i store the random number but when i compile it use only the last couple of number that had generated by random.
where is the problem ,is that the vector don't work or it don't store the firsts numbers or it's me who don't well use the vector?????
void foufou::CreateCharacter(int amount) <br />
{ <br />
int randomX =0,randomY =0,randomZ =0; <br />
<br />
foufou *PtrCreat; <br />
<br />
for(int i=0;i<amount;i++) <br />
{ <br />
PtrCreat = new foufou();
VectorOfCharacter.push_back(PtrCreat); <br />
<br />
initPosX = ( ( 1 + rand( ) % 120) - 70 ); <br />
initPosY = ( ( 1 + rand( ) % 120 ) - 70 ); <br />
<br />
<br />
<br />
<br />
NumCharacter++; <br />
} <br />
<br />
} <br />
<br />
<br />
<br />
<br />
<br />
void foufou:rawCharacterOnInitSimulation() <br />
{ <br />
<br />
for(int i=0 ;i<VectorOfCharacter.size() ;i++) <br />
{ <br />
<br />
DrawCreatedCharacter(VectorOfCharacter[i]->initPosX, VectorOfCharacter[i]->initPosY); <br />
<br />
} <br />
<br />
<br />
<br />
} <br />
<br />
|
|
|
|
|
If I understand your code, the line
initPosX = ( ( 1 + rand( ) % 120) - 70 ); should be
PtrCreat->initPosX = ( ( 1 + rand( ) % 120) - 70 ); (and the same for the next line).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i have a listview with LVS_EX_FULLROWSELECT style.I use AddItem to add an icon into the view.When i run the app,everything appears to be good.However,when i click the row to select it,the texts in the row are highlighted but icons DISAPPEARED!I tried several other ways (InsertItem or SendMessage),but these made no difference.I wonder if there is any possibility to insert icons to a listview?!
BTW:i want icons inserted in both headers and items,but the background colors of them are different,but one ImageList can have only one bkcolor(maybe more,i'm not sure).so is there any solution to this problem?
modified 1-May-21 21:01pm.
|
|
|
|
|
I used ATL create a Dll project,
I want get current DLL directory, I used ::GetCurrentDirectory() API,
but I only get the EXE 's current path.
I want get Dll's directory
what can I do ?
I believe I can touch the sky
|
|
|
|
|
GetModuleFileName will return the full path of the module you specify. If you give it NULL for the hInstance, then it will return the path of the main executable.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|