arconius
Messages postés27Date d'inscriptiondimanche 10 février 2002StatutMembreDernière intervention16 janvier 2006
-
26 août 2004 à 22:54
magic_Nono
Messages postés1878Date d'inscriptionjeudi 16 octobre 2003StatutMembreDernière intervention16 mars 2011
-
27 août 2004 à 11:05
Salut à tous :),
J'ai besoin d'un peu d'aide car je galère avec le presse papier.
Ce que je veux faire est très simple, j'ai une variable char qui contient admetons "Salut !!" et je voudrais copier son contenu dans le presse papier.
A priori, cela me paraissait hyper simple seulement voilà, je ne trouve aucun exemple qui m'aide vraiment.
glipper
Messages postés246Date d'inscriptiondimanche 2 juin 2002StatutMembreDernière intervention11 septembre 20161 27 août 2004 à 00:20
Tiens cette partie de code te copie la chaine "Le Texte" dans le presse papier :) Je trouve ca quand meme bien compliqué pour faire copier du texte dans le presse papier, mais apparament la fonction SetClipboardData veut un HANDLE comme second parametre donc bon....
magic_Nono
Messages postés1878Date d'inscriptionjeudi 16 octobre 2003StatutMembreDernière intervention16 mars 2011 27 août 2004 à 11:04
un autre
void BVisuel::copieTextDsPressePapier(const BString &txt)
{
/// --------------------------------------------------------------------------------------
/// ---------------- BVisuel::copieTextDsPressePapier(const BString& txt) ----------------
/// --------------------------------------------------------------------------------------
/// ----- Objectif : copie un txt ds le presse papier
/// ----- PreCond : presse papier préhenptable
/// ----- PostCond : presse papier vidé & remplacé
/// ----- Etat : 1 (-1<0<1<2)
/// --------------------------------------------------------------------------------------
/// ----- const BString& txt : texte à copier
/// --------------------------------------------------------------------------------------
/// ----- Var Muettes (cf.partie préc) (1) : txt
/// ----- Var Internes à la fonction (2) : hClipboardData ,pchData
/// ----- Var In (1) : txt
/// ----- Var In Globales Constantes (2) : CF_TEXT ,GMEM_DDESHARE
//BString plomp=txt;plomp+="\n\nprêt a être copié le txt ds le presse papier"; informe(plomp);
if(!OpenClipboard(NULL))
informe("échec d'ouverture du presse papier",false);
else
{
if(!EmptyClipboard())
informe("échec de vidage du presse papier",false);
// informe(msg);
// recup Net DEB
/// algo : {Clipboard locked && Clipboard empty.}
/// algo : allocate the global memory for our data.
HGLOBAL hClipboardData;
hClipboardData=GlobalAlloc(GMEM_DDESHARE, txt.getLength()+1);
// Calling
/// Nota : GlobalLock returns a pointer to the data associated with the handle
char*pchData;
pchData=(char*)GlobalLock(hClipboardData);
/// algo : copie
strcpy(pchData, (const char*)txt);
// strcpy(pchData, LPCSTR(strData));
/// algo : unlock the memory
/// Nota : never call GlobalFree : automatically when EmptyClipboard is next called.
GlobalUnlock(hClipboardData);
/// algo : set the Clipboard data by specifying that ANSI text is being used and passing the handle to the global memory.
SetClipboardData(CF_TEXT,hClipboardData);
/// algo : close the Clipboard
// recup FIN
if(!CloseClipboard())
informe("échec de fermeture du presse papier",false);
/// algo : {Clipboard unlocked}
}
}
et là, tt est commenté....
à l'extreme....
je me suis plutot laché qd je l'ai fait lol
++
Magic Nono: l'informagicien! 8-)
Vous n’avez pas trouvé la réponse que vous recherchez ?