|
Anu_Bala wrote: My application: when i resize it, the contents which are included in that size appears.
Ex. If the content is like this text "MDI application",when i resize the text gets shrinked in size and show me the full text.
But in my application,when i resize it,it shows only "MDI appl".
This is the part I'm not understanding - where is this text "MDI application" geting drawn? In the title bar or the client area of the window?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In the client area..Actually im drawing some graphs and tables .For example oonly i denote like MDI application.
When im resizing i can seee only part of the graph.
Anu
|
|
|
|
|
Anu_Bala wrote: Actually im drawing some graphs and tables
And where in the code are you doing this?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Iam doing all drawing functiosn is OnDraw()..
void CUnitTrendView::OnDraw(CDC* pDC)
{
GetClientRect(&ClientArea);
CFont *pOFont = pScreenDC->SelectObject(&TextFont);
CPen *pOPen = pScreenDC->SelectObject(&GPen[0]);
pScreenDC->FillRect(ClientArea,&GBrush[2]);
pScreenDC->SetTextColor(RGB(0,255,0));
pScreenDC->SetBkColor(RGB(0,0,0));
if(AreaTrendFlag)
{
POSITION TrendListPos = goTrendList.GetHeadPosition();
if(TrendListPos != NULL)
{
CTrendInfo *pAreaTrend = (CTrendInfo*)goTrendList.GetAt(goTrendList.GetHeadPosition());
cTimeBreakUp = pAreaTrend->GetTrendTimeBase();
sUnitTrendTitle = (CString)"Area Trend Overview " + " ( " + GetTimeBreakUpText(pAreaTrend->GetTrendTimeBase()) + " )";
int *pUTrTagIndex = pAreaTrend->GetTrendTagIndex();
for(int i = 0;i<24;i++)
iUnitTrendTagIndex[i] = pUTrTagIndex[i];
}
AreaTrendFlag = FALSE;
}
pTrend->Draw(pScreenDC,iUnitTrendTagIndex,sUnitTrendTitle);
}
Im coding all drawing functionalities in OnDraw()
Anu
|
|
|
|
|
One thing...
Are you considering actual size of the window to make a zoom? If you create your fonts with static/fixed size, it is logical that if u make the window smaller not the whole text will be visible.
One idea:
Take the size of your window just at the beggining of the application (init instance or somewhere like that) and save the values as first values. Then, when the window is resized (OnSize or something similar) take the new values and if they are different, get the ratio factor with ActualSize / OriginalSize.
With this ratio you can make different things: One... make a zoom in or zoom out depending on if the ratio is bigger or lower than 1. Or just multiplicate all your size/position variables with this ratio and you will keep the proportion without mattering about the size of the screen.
The only problem with that is if you resize the window only in one direction, then you will get a distorsionated View.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
hi all. i have a very simple question: i have created an array of strings like this ->
string all_errors[256]; // stores 256 error strings
then i store a value for all_errors[0] = "test";
i want to write this out to a text file. i do it like this:
results << all_errors[0] << "\n";
is there anything wrong syntactically with the above statements? if not, i will give more code..
i get two errors:
1>.\simpleTask.cpp(425) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(650): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(697): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(735): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(782): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(906): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(913): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(920): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(927): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\documents and settings\dhruv\my documents\spring\node.h(248): or 'std::ostream &operator <<(std::ostream &,const Node &)'
1> c:\documents and settings\dhruv\my documents\spring\nodearray.h(153): or 'std::ostream &operator <<(std::ostream &,const NodeArray &)'
1> c:\documents and settings\dhruv\my documents\spring\edge.h(69): or 'std::ostream &operator <<(std::ostream &,const Edge &)'
1> c:\documents and settings\dhruv\my documents\spring\tetra.h(104): or 'std::ostream &operator <<(std::ostream &,const Tetra &)'
1> c:\documents and settings\dhruv\my documents\spring\tetraarray.h(48): or 'std::ostream &operator <<(std::ostream &,const TetraArray &)'
1> c:\documents and settings\dhruv\my documents\spring\face.h(171): or 'std::ostream &operator <<(std::ostream &,const Face &)'
1> c:\documents and settings\dhruv\my documents\spring\facearray.h(51): or 'std::ostream &operator <<(std::ostream &,const FaceArray &)'
1> c:\documents and settings\dhruv\my documents\spring\object.h(314): or 'std::ostream &operator <<(std::ostream &,Object &)'
1> c:\documents and settings\dhruv\my documents\spring\objectarray.h(69): or 'std::ostream &operator <<(std::ostream &,ObjectArray &)'
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(168): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(174): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(181): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(188): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(208): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(241): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(261): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(286): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(306): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(326): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(347): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(367): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(388): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(408): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(428): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(448): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(468): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, std::string)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>.\simpleTask.cpp(446) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(650): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(697): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(735): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(782): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(906): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(913): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(920): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(927): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\documents and settings\dhruv\my documents\spring\node.h(248): or 'std::ostream &operator <<(std::ostream &,const Node &)'
1> c:\documents and settings\dhruv\my documents\spring\nodearray.h(153): or 'std::ostream &operator <<(std::ostream &,const NodeArray &)'
1> c:\documents and settings\dhruv\my documents\spring\edge.h(69): or 'std::ostream &operator <<(std::ostream &,const Edge &)'
1> c:\documents and settings\dhruv\my documents\spring\tetra.h(104): or 'std::ostream &operator <<(std::ostream &,const Tetra &)'
1> c:\documents and settings\dhruv\my documents\spring\tetraarray.h(48): or 'std::ostream &operator <<(std::ostream &,const TetraArray &)'
1> c:\documents and settings\dhruv\my documents\spring\face.h(171): or 'std::ostream &operator <<(std::ostream &,const Face &)'
1> c:\documents and settings\dhruv\my documents\spring\facearray.h(51): or 'std::ostream &operator <<(std::ostream &,const FaceArray &)'
1> c:\documents and settings\dhruv\my documents\spring\object.h(314): or 'std::ostream &operator <<(std::ostream &,Object &)'
1> c:\documents and settings\dhruv\my documents\spring\objectarray.h(69): or 'std::ostream &operator <<(std::ostream &,ObjectArray &)'
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(168): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(174): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(181): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(188): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(208): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(241): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(261): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(286): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(306): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(326): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(347): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(367): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(388): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(408): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(428): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(448): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\ostream(468): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, std::string)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
--
dg
|
|
|
|
|
Holy cow, that's 2 errors?
Try
results << all_errors[0].c_str() << "\n";
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You shouldn't have to do this.
Steve
|
|
|
|
|
Strike that
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Compiles fine for me with VS 2005 and no service pack;
I'd try changing "\n" to std::endl
|
|
|
|
|
Josh Gray wrote: I'd try changing "\n" to std::endl
This is not related to the OP, but I think there is a tendency to overuse std::endl, I suspect that somehow people think it is more C++ish. The big difference is that std::endl, as well as outputting a new line character, flushes the stream's buffer. For a few random output lines this doesn't matter, but for writing normal files use '\n' and let the stream's buffer do what it is supposed to do. The exception is when you use file-based debugging - here endl is essential as it ensures that in the case of a crash the last line of the file is actually written to disk.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
cp9876 wrote: This is not related to the OP, but I think there is a tendency to overuse std::endl, I suspect that somehow people think it is more C++ish. The big difference is that std::endl, as well as outputting a new line character, flushes the stream's buffer. For a few random output lines this doesn't matter, but for writing normal files use '\n' and let the stream's buffer do what it is supposed to do. The exception is when you use file-based debugging - here endl is essential as it ensures that in the case of a crash the last line of the file is actually written to disk.
Thanks I didnt know that. I always thought the advantage was that it would put the correct line ending for the platform you are running on.
|
|
|
|
|
I am having a more-than-momentary lapse of reason... I want to use the PostMessage( ) function to pass a window handle (CWnd) from one app to another.
In the caller, i have something like this:
CWnd hWnd;
static CWnd *pWnd;
pWnd = FindWindow("RecvApp",0);
pWnd->PostMessage(WM_CONNECT_APP, hWnd, 1);
In the receiver application ("RecvApp"):
CWnd *pWnd_Caller;
ON_MESSAGE(WM_CONNECT_APP, OnMakeConnection)
LRESULT CMainFrame::OnMakeConnect(WPARAM wParam, LPARAM lParam)
{
if (lParam == 1)
m_View->PostMessage(WM_CONNECT_APP, wParam, lParam);
}
wParam->PostMessage(WM_ADD_ENTITY, 0, 0);
I want to use the window handle of the caller to post a message back to itself based upon parameters gathered in the receiver app...
(caller) PostMessage (to receiver)
(receiver) assign values, do its stuff...
(receiver) PostMessage (to caller - new values)
In short, I need to know how to pass and use/dereference (etc...) the CWnd handle I am passing around.
Thanks.
Johnny
|
|
|
|
|
You can't pass a CWnd object or a pointer to one. You can pass the HWND that is wrapped by the CWnd
object though.
To obtain the HWND from a CWnd you can use
The HWND cast operator
HWND hWnd = (HWND)MyCWnd;
Use CWd::GetSafeHwnd()
HWND hWnd = pMyCWnd->GetSafeHwnd();
On the receiving end, to get a CWnd from an HWND you can
Create a temporary CWnd object using CWnd::FromHandle()
CWnd *pCWnd = CWnd::FromHandle(hWnd);
For an object that needs to persist, use CWnd::Attach()
pCWnd = new CWnd(); <br />
pCWnd->Attach(hWnd);
Cast an HWND to (WPARAM) or (LPARAM) when passing with PostMessage().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
john john mackey wrote: wParam->PostMessage(WM_ADD_ENTITY, 0, 0);
instead of CWnd* send actual HWND by using CWnd::GetSafeHwnd() method and on Receieving end using CWnd::Attach attach that Hwnd to CWnd Pointer!
sending CWnd* is creating problem because the Pointer Address can't be accesible two application!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
Hi all, quick question. I dont know how to save to a buffer in C++ only in C with sprintf().
Can anyone tell me how to print to a buf with C++? Thanx in advance!
|
|
|
|
|
dellthinker wrote: I dont know how to save to a buffer in C++
dellthinker wrote: tell me how to print to a buf with C++
Save...print... what to what kind of buffer?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
dellthinker wrote: Hi all, quick question. I dont know how to save to a buffer in C++ only in C with sprintf().
sprintf also available in c++ too. are talking abt std::string class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
|
Hello,
I am storing a card number 9999999999 in the database as hexa format 0x09090909090909090909,
i have to send it to the controller in a pack of 5 binary (in hexa Format), meaning 0x02540BE3FF
any sample code appreciated.
With Rgds,
Anil
|
|
|
|
|
__int64 llValue = _tstoi64(_T("9999999999"));
Send low-order 5 bytes of llValue
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Wait, I missed half of this earlier...
AnilUnni wrote: I am storing a card number 9999999999 in the database as hexa format 0x09090909090909090909
Wouldn't ASCII have been easier?
I guess you need to convert those "hexa format" (why the "0x"??) digits to ascii then convert to binary.
Is this homework?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi -
I've been working on a large multi-threaded VC++ 6.0/MFC application for some years and use ODBC as the main database service provider to a backend database in SQL Server 2000.
For one client's application, though, we notice that the ODBC connection disappears from time to time (their database generally resides on a different machine) and the application crashes when it makes a database request over a handle that's gone bad. As the application has recently started transporting real money, this is unacceptable and I need to know the answers to two questions:
1. Is it possible for the ODBC driver to alert me when it determines that a connection has died, rather than leaving me find out the hard way? The application is idle perhaps 98% of the time and a temporary outage caused by a resurrect-on-connection-death is going to affect the performance far less than a system crash.
2. If there is no answer to (1), is there an alternative to ODBC that will give me this functionality - either something (a) that is stateless and which will allow me to query, read and write the database without requiring handles or (b) or which has a fast connect, so that I can make a connection every time that I need to do something or (c) something that doesn't crash when the connection is lost? You can assume that I'm going to continue using VC++ 6.0/MFC for the foreseeable future.
thanks folks,
- robin.
|
|
|
|
|
1) I don't think so, i don't recall any callback functionality, nor do i believe the connection is 'live', i think it is like (is?) a TCP/IP connection.
2)
a)
i)Rewrite the app as a client-server system that can handle caching data while the server is offline.
ii) See if any of the SQL server replication (pub-sub) services can help you.
b) You say that a reconnect would be acceptable, in that case i would suggest turning on connection pooling and reconnecting each time. If there are a lot of requests in a short period then a connect request will receive an existing connection from the pool (fast), if not then a full connect will happen (slower).
c) Why not test the connection before you use it ? If bad reconnect. There shouldn't be any reason for the app to crash.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote: c) Why not test the connection before you use it ? If bad reconnect. There shouldn't be any reason for the app to crash.
I've done this in another module for this application, but it's unreliable because (AFAIR) the code which checks if the database handle is alive (it does a "SELECT GETDATE()") generally crashes if the HDBC is dead. Doesn't do it all the time, which is why I've written it this way. Catching 25% of problems is better than catching none at all.
I might try the connection pooling method and see how I get on with that. It's certainly goin to give better results than I've been getting to date.
Thanks for your help
|
|
|
|
|