|
Hello ppl need your help im working on an application and i have this code:
void CChatView::OnChatroomAddtoautojoin()<br />
{<br />
CString strOut;<br />
strOut.Format(IDS_AUTOJOIN_ADD, GetDocument()->m_strRoom);<br />
WriteSystemMsg(FALSE, strOut, g_sSettings.GetRGBOK());<br />
CClipboard::SetText((LPSTR)(LPCSTR)GetDocument()->m_strRoom);<br />
ManageAutojoins dlg;<br />
dlg.DoModal();<br />
}
This code is copy a room id in Clipboard and after is Launche an other dialog now what i need the other dialog is IDD_AUTOJOIN_MANAGER (ManageAutojoins) this dialog have a text box named: IDC_ADD_BOX need when the user press the Menu Button "OnChatroomAddtoautojoin" after the copy of ID to paste Clipboard data in IDC_ADD_BOX in IDD_AUTOJOIN_MANAGER dialog.
With 2 words i need when the IDD_AUTOJOIN_MANAGER (ManageAutojoins) Launche to have pasted in IDC_ADD_BOX the room ID (was coppyed in Clipboard).
Can someone give the command? because im stack over 2 hours...
Thanks,
Zhen-Xlogic
|
|
|
|
|
If you look in the class header file for CClipboard , you will probably find a GetText() function.
|
|
|
|
|
How can i syntax that function GetText() to add the text in IDC_ADD_BOX in IDD_AUTO_JOIN_MANAGER?
Because i try something and isnt work...
Thanks,
Zhen-Xlogic
|
|
|
|
|
|
YeaP!
Thanks a lot
Zhen-Xlogic
|
|
|
|
|
You're welcome
|
|
|
|
|
Please post the code that you tried, and the definition line from the CClipboard class header file.
|
|
|
|
|
Code that i tried:
void CChatView::OnChatroomAddtoautojoin()<br />
{<br />
CString strOut;<br />
strOut.Format(IDS_AUTOJOIN_ADD, GetDocument()->m_strRoom);<br />
WriteSystemMsg(FALSE, strOut, g_sSettings.GetRGBOK());<br />
CClipboard::SetText((LPSTR)(LPCSTR)GetDocument()->m_strRoom);<br />
<br />
OpenClipboard();<br />
m_strAdd = CClipboard::GetText();<br />
CloseClipboard();<br />
<br />
ManageAutojoins dlg;<br />
dlg.DoModal();<br />
}
CClipboard class header file:
<br />
#ifndef __CCLIPBOARD_H<br />
#define __CCLIPBOARD_H<br />
<br />
class CClipboard<br />
{<br />
public:<br />
static CString GetText(HWND hWnd = NULL);<br />
static BOOL GetText (LPSTR lpszBuffer,<br />
int nBufSize,<br />
HWND hWnd = NULL);<br />
<br />
static BOOL GetTextLength (unsigned long *pnSize,<br />
HWND hWnd = NULL);<br />
<br />
static BOOL SetText (LPSTR lpszBuffer,<br />
HWND hWND = NULL);<br />
};<br />
<br />
#endif
And the CClipboard class source file:
#include "stdafx.h"<br />
#include "Clipboard.h"<br />
<br />
<br />
BOOL CClipboard::GetText (LPSTR lpszBuffer, int nBufSize, HWND hWnd)<br />
{<br />
HGLOBAL hGlobal;
LPSTR lpszData;
unsigned long nSize;
<br />
OpenClipboard(hWnd);<br />
<br />
hGlobal = GetClipboardData(CF_TEXT);<br />
<br />
if (hGlobal == NULL) return FALSE;<br />
<br />
lpszData = (LPSTR)GlobalLock(hGlobal);<br />
nSize = GlobalSize(hGlobal);<br />
<br />
if(nSize >= (UINT)nBufSize) nSize = nBufSize - 1;<br />
<br />
for (UINT i = 0; i < nSize; ++i)<br />
*(lpszBuffer + i) = *(lpszData + i);<br />
*(lpszBuffer + i) = 0;<br />
<br />
GlobalUnlock(hGlobal);<br />
CloseClipboard();<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
BOOL CClipboard::GetTextLength (unsigned long *pnSize, HWND hWnd)<br />
{<br />
HGLOBAL hGlobal;
unsigned long nSize;
LPSTR lpszData;
<br />
OpenClipboard(hWnd);<br />
<br />
hGlobal = GetClipboardData(CF_TEXT);<br />
<br />
if (hGlobal == NULL) return FALSE;<br />
<br />
lpszData = (LPSTR)GlobalLock(hGlobal);<br />
nSize = GlobalSize(hGlobal);<br />
<br />
GlobalUnlock(hGlobal);<br />
CloseClipboard();<br />
<br />
*pnSize = nSize;<br />
return TRUE;<br />
}<br />
<br />
<br />
int CClipboard::SetText (LPSTR lpszBuffer, HWND hWnd)<br />
{<br />
HGLOBAL hGlobal;
LPSTR lpszData;
unsigned long nSize;
<br />
OpenClipboard(hWnd);<br />
EmptyClipboard();<br />
<br />
nSize = lstrlen(lpszBuffer);<br />
<br />
hGlobal = GlobalAlloc(GMEM_ZEROINIT, nSize+1);<br />
<br />
if (hGlobal == NULL) return FALSE;<br />
<br />
lpszData = (LPSTR)GlobalLock(hGlobal);<br />
<br />
for (UINT i = 0; i < nSize + 1; ++i)<br />
*(lpszData + i) = *(lpszBuffer + i);<br />
<br />
GlobalUnlock(hGlobal);<br />
SetClipboardData(CF_TEXT, hGlobal);<br />
CloseClipboard();<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
CString CClipboard::GetText(HWND hWnd)<br />
{<br />
<br />
CString strReturn;<br />
ULONG nLen = 0;<br />
char *buffer = 0;<br />
<br />
if(GetTextLength(&nLen, hWnd)){<br />
<br />
buffer = new char[nLen];<br />
GetText(buffer, nLen, hWnd);<br />
strReturn = buffer;<br />
delete buffer;<br />
buffer = 0;<br />
}<br />
return strReturn;<br />
}<br />
With this code in the CChatView::OnChatroomAddtoautojoin is build ok! but the Room ID is copy but isnt paste in IDC_ADD_BOX (The IDC_ADD_BOX is m_strAdd: DDX_Text(pDX, IDC_ADD_BOX, m_strAdd); ).
Why Isnt work my code is correct???
Thanks,
Zhen-Xlogic
|
|
|
|
|
- You don't need to call
OpenClipboard() and CloseClipboard() - they are called in the CClipboard functions.
- The
DDX_Text() statement will only be executed when DoDataExchange() is called. You have to do more than just set the value in m_strAdd - you have to force DoDataExchange() to be called. You can do this by calling UpdateData(FALSE); .
|
|
|
|
|
Because i lost you a bit, can you show me a code!? with the m_strAdd ???
Thanks,
Zhen-Xlogic
|
|
|
|
|
See Code that i tried: in your previous post.
|
|
|
|
|
Hello,
here is the full code:
http://www.paste.lt/paste/8207c95295928305310b7fbdb7e40c6d
I get compiler error:
[C++ Error] Unit5.cpp(109): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'Tkontaktai'
overloading is in 84-89 lines, but it doesn't work.
how could I overload it correctly?
Dj_Lord
|
|
|
|
|
Please post relevant code here using "pre" tags.
|
|
|
|
|
how to overload << operator correctly, because i am getting a compiler error.
full code:
#pragma hdrstop
#pragma argsused
#include <iostream.h>
class Tkontaktai {
char vardas[20];
char tel[12];
public:
Tkontaktai( ) {vardas[0] = tel[0] = '\0';}
void saugok(char *v, char *t) {strcpy(vardas, v); strcpy(tel, t);}
virtual void rodyk( ) {cout << vardas << ", " << tel;}
char *s_vardas( ) {return vardas;}
char *s_tel( ) {return tel;}
};
template <class T>
class Tnode {
Tnode *kitas;
public:
T duomenys;
Tnode (T re, Tnode * rod = NULL):duomenys(re), kitas (rod){ };
Tnode * Paimti ();
void Prijungti (Tnode *y){
kitas= y;
}
Tnode *Papildyti (Tnode *y){
y->kitas = this;
return y;
}
Tnode * Rkitas () {return kitas; }
};
template <class T>
class Tstack {
Tnode<T> *head;
public:
Tstack () {head= NULL; }
~Tstack<T>();
T Pop ();
void Push (T y);
int Empty();
ostream& operator<< (Tkontaktai* );
};
template <class T>
void Tstack<T>::Push(T y){
Tnode<T> * temp= new Tnode<T> (y,head);
head= temp;
}
template<class T>
T Tstack<T>::Pop(){
Tnode<T> *temp= head;
T re=head->duomenys;
head = head->Rkitas();
delete temp;
return re;
}
template <class T>
Tstack<T>::~Tstack<T>() {
Tnode<T> *temp;
while (head){
temp = head;
head = head->Rkitas();
delete temp;
}
}
template <class T>
int Tstack<T>::Empty(){
if(head)
return 0;
else
return 1;
}
template<class T>
ostream& Tstack<T>::operator<< (Tkontaktai* duom){
ostream& outstr;
outstr << duom->s_vardas() << " " << duom->s_tel() << endl;
return ostr;
}
main(){
Tstack<Tkontaktai> x;
Tkontaktai k;
char vardas[20];
char tel[12];
for (int i = 0; i<3; i++){
cout << "vardas: ";
cin >> vardas;
cout << "telefonas: ";
cin >> tel;
k.saugok(vardas, tel);
x.Push(k);
}
cout<< "Eileje buvo sie skaiciai:"<< endl;
while (!(x.Empty()))
cout << x.Pop() << endl;
system("pause");
}
Dj_Lord
|
|
|
|
|
Just the relevant code is all that's needed. Most of what you've provided has nothing to do with the compiler error.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
class Tkontaktai {
char vardas[20];
char tel[12];
public:
char *s_vardas( ) {return vardas;}
char *s_tel( ) {return tel;}
};
template<class T>
ostream& Tstack::operator<< (Tkontaktai* duom){
ostream& outstr;
outstr << duom->s_vardas() << " " << duom->s_tel() << endl;
return ostr;
}
template<class T>
Tstack::Pop(){
Tnode *temp= head;
T re=head->duomenys;
head = head->Rkitas();
delete temp;
return re;
}
main(){
cout << x.Pop() << endl;
}
overloading isn't working...
Dj_Lord
|
|
|
|
|
Dj_Lordas wrote: templateostream& Tstack::operator<< (Tkontaktai* duom){ ostream& outstr; outstr << duom->s_vardas() << " " << duom->s_tel() << endl; return ostr;}
Shouldn't this be:
class Tkontaktai
{
public:
friend ostream& operator<<( ostream&, const Tkontaktai& );
};
ostream& operator<<( ostream &os, const Tkontaktai &duom )
{
return os << duom.vardas << " " << duom.tel << endl;
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks, you are right! I was adding operator overloading in the wrong class...
Dj_Lord
|
|
|
|
|
Hi Friends
Is any solution to read a barcode from an scanned image.
The image may be colourful
-RisKhan-
|
|
|
|
|
RisKhan wrote: Is any solution to read a barcode from an scanned image
yes, there are plenty of articles on CP about barcodes. have you searched some ?
|
|
|
|
|
|
Hi,
How Do I know that My Application App.exe is running On Citrix Env or Not? I need to write a code on the App.exe itself to find it is Loaded on Citrix By Seamless client or Loaded on the Standalone Pc.
Thanks in Advance
|
|
|
|
|
Have you tried asking on the Citrix forum?
|
|
|
|
|
hi i am downloading a package from server and instaling it in my system. i have to get the path where the package is installed. how it can be done? is there anyway to obtain it using registry
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
There's no rule that states an application needs to make a registry entry when it is installed.
There may be a way, maybe not - this is vendor-specific.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|