!!! Besoin de faire tester !!!

Résolu
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 - 22 déc. 2004 à 11:12
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 - 23 déc. 2004 à 10:14
Salut,

comme j'ai un pb de linker avec dev-c++ 4.9.9.1 avec cette fonction (voir ci-dessous) dont je veux me servir, j'aurais besoin de qq'un pour la tester.
Elle sert à insérer un bitmap dans un rich edit, donc je la passe en espérant qq'un arrivera à la compiler.
/*Pour insérer une bitmap dans un RichEdit*/
bool InsererBitmap(HWND RichEdithWnd, HBITMAP hBitmap)
{
HRESULT hr;
IDataObject* pDataObject;
LPOLEOBJECT lpOleObject = NULL;
LPSTORAGE lpStorage = NULL;
LPOLECLIENTSITE lpOleClientSite = NULL;
LPLOCKBYTES lpLockBytes = NULL;
CLIPFORMAT cfFormat = 0;
LPFORMATETC lpFormatEtc = NULL;
FORMATETC formatEtc;
LPRICHEDITOLE lpRichEditOle;
SCODE sc;
LPUNKNOWN lpUnknown;
REOBJECT reobject;
CLSID clsid;
SIZEL sizel;
DWORD dwStart, dwEnd;

CoInitialize(NULL);
if(OpenClipboard(NULL))
{
EmptyClipboard();
SetClipboardData(CF_BITMAP, hBitmap);
CloseClipboard();
}
else return 0;

OleGetClipboard(&pDataObject);
if (pDataObject == NULL) return 0;
sc = CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (lpLockBytes == NULL) return 0;

sc = StgCreateDocfileOnILockBytes(lpLockBytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);
if (lpStorage == NULL) return 0;

lpFormatEtc = &formatEtc;
lpFormatEtc->cfFormat = cfFormat;
lpFormatEtc->ptd = NULL;
lpFormatEtc->dwAspect = DVASPECT_CONTENT;
lpFormatEtc->lindex = -1;
lpFormatEtc->tymed = TYMED_NULL;

SendMessage(RichEdithWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&lpRichEditOle);
if (lpRichEditOle == NULL) return 0;

lpRichEditOle->GetClientSite(&lpOleClientSite);
if (lpOleClientSite == NULL) return 0;

hr = OleCreateStaticFromData(pDataObject, IID_IOleObject, 3, lpFormatEtc, lpOleClientSite, lpStorage, (void**)&lpOleObject);
if (lpOleObject == NULL) return 0;

lpUnknown = (LPUNKNOWN)lpOleObject;
lpUnknown->QueryInterface(IID_IOleObject, (void**)&lpOleObject);
lpUnknown->Release();
OleSetContainedObject((LPUNKNOWN)lpOleObject, TRUE);

ZeroMemory(&reobject, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);

sc = lpOleObject->GetUserClassID(&clsid);

reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_BELOWBASELINE; //REO_RESIZABLE | REO_BELOWBASELINE;
reobject.dwUser = 0;
reobject.poleobj = lpOleObject;
reobject.polesite = lpOleClientSite;
reobject.pstg = lpStorage;
sizel.cx sizel.cy 0;
reobject.sizel = sizel;

SendMessage(RichEdithWnd, EM_SETSEL, 0, -1);
SendMessage(RichEdithWnd, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
SendMessage(RichEdithWnd, EM_SETSEL, dwEnd+1, dwEnd+1);

lpRichEditOle->InsertObject(&reobject);

lpLockBytes->Release();
lpStorage->Release();
pDataObject->Release();
lpRichEditOle->Release();
lpOleClientSite->Release();
lpOleObject->Release();
CoUninitialize();

return 1;
}

P.S : il faut inclure windows.h et la librairie ole32.

Merci d'avance et j'attends vos résultats avec impatience.

YOYO, @+.
:big) YOYO ;)

7 réponses

cs_Nebula Messages postés 787 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 7 juin 2007 2
22 déc. 2004 à 20:51
Rajoute donc -luuid dans tes libs.
3
luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 6
22 déc. 2004 à 12:13
Chez moi, la compilation est très loing de marcher. De nombreux termes sont indéfinis. ex: LPRICHEDITOLE, REOBJECT, EM_GETOLEINTERFACE, etc etc

sur ce ++
0
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 2
22 déc. 2004 à 14:13
Salut luhtor,

tout d'abord merci d'avoir pris du temps sur mon pb.
J'avais oublié de préciser qu'il faut également richole.h et richedit.h.

En fait la fonction reçoit le handle d'un richedit et celui d'un bitmap (bien sûr à créer au préalable).

Voilà, jespère que ça vous aidera.

YOYO, @+.
:big) YOYO ;)
0
cs_Nebula Messages postés 787 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 7 juin 2007 2
22 déc. 2004 à 20:15
Ne fonctionne pas chez moi (et j'ai du adapter les appels des interfaces pour les gérer en C)... C'est quoi, ton problème de link ?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 2
22 déc. 2004 à 20:25
Dev-C++ n'arrive pas à linker IID_IOleObject.

:big) YOYO ;)
0
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 2
22 déc. 2004 à 20:59
Merci Nebula,

c'est ce qu'il me manquait.
Ca compile bien maintenant mais ça fonctionne pas.

Je suis dégouté.

YOYO, @+.
:big) YOYO ;)
0
yoyo269 Messages postés 1403 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 11 janvier 2009 2
23 déc. 2004 à 10:14
Eureka j'ai trouvé ça fonctionne.
Voilà la source.

http://www.cppfrance.com/code.aspx?ID=28353

P.S: mettez un commentaire et une petite note svp.

YOYO, @+.
:big) YOYO ;)
0
Rejoignez-nous