|
Hi,
I am working on a list view control which displays thumbnails. What I want to do is to add a functionality that allows user to drag a thumbail from my list view and drop it into windows explorer or Internet explorer.
I have successfully handled drag and drop from Windows explorer & Internet Explorer on my list view control.
Important thing to note is that I am only using ATL and not MFC!!!
Can anybody help me out????
Best regards,
Pious.
|
|
|
|
|
1. MSDN Article Q214814 "HOWTO: Implementing Basic Drag and Drop In a Tree Control"
2. MSDN key words "ListView_CreateDragImage;LVN_BEGINDRAG"
3. Take the tree sample and replace with appropriate listview messages/macros
|
|
|
|
|
I am running into a warning -- when I use CString's as member variables inside DLL exportable classes {_declspec(dllexport)}
rfservice.h(30): warning C4251: 'RFService::m_Time' : class 'ATL::CStringT<basetype,stringtraits>' needs to have dll-interface to be used by clients of class 'RFService'
with
[
BaseType=char,
StringTraits=ATL::StrTraitATL<char,atl::chtraitscrt<char>>
]
Should I heed this warning? Should I wrap CString into a DLL-exportable class? What should I do?
-p
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b134980
PRB: C4251 & C4275 Compiler Warnings While Compiling an AFXDLL
The information in this article applies to:
The Microsoft Foundation Classes (MFC), when used with:
Microsoft Visual C++, 32-bit Editions 2.0
Microsoft Visual C++, 32-bit Editions 2.1
Microsoft Visual C++, 32-bit Editions 2.2
This article was previously published under Q134980
SYMPTOMS
The Compiler issues the following warning for a class derived from one of the MFC classes:
warning C4275: non dll-interface class XXX used as base for dll-interface class YYY
A related warning is issued when an object of some MFC class is embedded as a data member of a user-defined class:
warning C4251: identifier : class XXX needs to have dll-interface to be used by clients of class YYY
This problem no longer occurs in vc 4.0 or later.
CAUSE
The DLL version of MFC does not export its classes by declaring them with "class __declspec(dllexport)." Instead, it exports its classes through entries in the EXPORTS section of its module definition (.def) file.
Because the compiler has only the header files to work with, it cannot determine whether the MFC classes were actually exported, and therefore it issues the warning.
RESOLUTION
Because the MFC classes are in fact exported, these warnings can be safely ignored. As shown in the DLLHUSK sample, you can disable these warnings by using the following pragma statements:
<br />
#pragma warning(disable: 4275)<br />
#pragma warning(disable: 4251)<br />
On the other hand, if the warnings refer to some user-defined class rather an MFC class, you should ensure that the class is exported before disabling these warnings.
STATUS
This behavior is by design.
|
|
|
|
|
How to make window with LButtonDown event using WTL?
Write MFC List Class using STL?
Write Add,sub and Mul functions using ATL?
|
|
|
|
|
About every fourth build takes an eternity!
(I think it is when not performin an incremental link, but a fresh one)
The build output is filled with several idl-filepaths.
Does anyone know of anything like a pch for midl?
|
|
|
|
|
I’m getting the following errors:
atlctrls.h(1585) : error C2065: 'ImageList_Read' : undeclared identifier.
I would greatly appreciate if anyone can tell me why I’m getting the above error.
Here is my stdafx.h herder file:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__731756F9_46C8_4C84_843A_D84A4E3C42C1__INCLUDED_)
#define AFX_STDAFX_H__731756F9_46C8_4C84_843A_D84A4E3C42C1__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_APARTMENT_THREADED
#pragma warning( disable : 4541 ) // disable warning 4541
#pragma warning( disable : 4530 ) // disable warning 4530
// MFC
#include <afxwin.h>
#include <commctrl.h>
#include <afxdisp.h>
// WTL/ATL
#include <commctrl.h>
#include <atlbase.h>
#include <commctrl.h>
#include <atlapp.h>
#include <commctrl.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
class CExeModule : public CComModule
{
public:
LONG Unlock();
DWORD dwThreadID;
HANDLE hEventShutdown;
void MonitorShutdown();
bool StartMonitor();
bool bActivity;
};
extern CExeModule _Module;
#include <commctrl.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atlctl.h>
#include <comdef.h>
#include <atlhost.h>
#include <atldlgs.h>
#include <atlctrls.h>
// WINDOWS
#include <tchar.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
// STL
#include <typeinfo>
#include <algorithm>
#include <stdexcept>
#include <exception>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include
#include <vector>
#include <time.h>
#include <urlmon.h>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__731756F9_46C8_4C84_843A_D84A4E3C42C1__INCLUDED)
Thank you,
|
|
|
|
|
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
|
|
|
|
|