|
Hi friends,
I developed a dialog application.
I want the content to be displayed in "Print Preview" view.
I tried it by calling the OnFilePrintPreview() fn.
But its aborting.
Plz anybody help me out to solve the problem..
Thanks.
Reagards
Shiva
|
|
|
|
|
PrintPreview is quite less problematic than printing in paper. BTW if you say that is aborting but you give wether the exact error nor a code snippet... it will be pretty difficult to help you. There are very good programmers here, but AFAIK there are no mediums or telepats in forum.
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
CFrameWnd* pFrameWnd=(CFrameWnd*)AfxGetThread()->m_pMainWnd;
{
CPrintPreviewView* pView=(CPrintPreviewView*)pFrameWnd->GetActiveView();
pView->OnFilePrintPreview();
}
Now im getting the preview, but the prgm hangs..
whats the problem?
Reagards
Shiva
|
|
|
|
|
I guess an unended bucle. Or a reiterative call to OnDraw without end. Or something like this...
This code seems to be ok, can you show what you are doing to print contents in the preview?
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi,
This OnFilePrintPreview() is available in CView or VEditView.
But u can`t use it directly in a Dialog.
If you want you have to Create a Dialog with Print Preview Option, inherited from CDialog Class.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
hi all !
I'm working on c#.net but i'm new in c++ . i want to know is there any difference between C++ and C++.NET from point of in powerful or ... .
i want to work in cell phones programm .
Thanx in Advance !
Yours ,
s_mostafa_h
|
|
|
|
|
Yes, there are differences.
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
can u explain more about this !
thanx
s_mostafa_h
|
|
|
|
|
C++ produces native code. "C++.NET", more commonly known as Managed C++ or C++/CLI produces MSIL, which is the intermediate language understood by the .NET Framework...
the C++/CLI language differs by its syntax however, and such source code would not compile with a pure C++ compiler.
|
|
|
|
|
Another difference will be the "easibility", some things that in .Net are made with just a few lines using the libraries, MFC or other things... won't be available in pure C++ and you will have to learn/understand what that functions make and how they work to simulate their behaviour, and (if it is possible) to code them yourself.
C++ doesn't need the .Net framework so it may be more portable if you code it following standards.
BTW, if you want to code for cell phones... should it not be better to use embeded/embebed (or as it is written) C? J2ME
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
modified on Friday, December 14, 2007 6:56:55 AM
|
|
|
|
|
J2ME !
|
|
|
|
|
eing ???
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
For mobiles, use J2ME (Java 2 Mobile Edition)
|
|
|
|
|
only J2ME , even for tools programm .as u know , all mobiles don't support some languages ... .making menu for these languages is necessary for use them .
thanx
s_mostafa_h
|
|
|
|
|
I am doing a TankGame program,and I write a CBullet class.I write a thread function to make it move when it is created:
UINT BulletGo(LPVOID pParam)
{
CBullet* bullet=(CBullet*)pParam;
while(TRUE)
{
switch(bullet->m_bCanGo.GetDirection())
{
case UP:
bullet->GoUp();
break;
case DOWN:
bullet->GoDown();
break;
case LEFT:
bullet->GoLeft();
break;
case RIGHT:
bullet->GoRight();
break;
}
if(!bullet->m_bCanGo)
break;
else
bullet->MoveWindow(bullet->GetPosition().x,
bullet->GetPosition().y,
bullet->GetThisRect().Height(),
bullet->GetThisRec().Width());
Sleep(30);
}
return 0;
}
int CBullet::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
m_bCanGo=TRUE;
m_pThread=AfxBeginThread(BulletGo,this); //begin thread
return 0;
}
BOOL CBullet::GoDown()
{
if((m_ptPosition.y+m_rtThis.Height())>m_rtParent.bottom)
{
m_ptPosition.y+=2;
m_bCanGo=TRUE;
return TRUE;
}
else
{
this->DestroyWindow();
m_bCreated=FALSE;
m_bCanGo=FALSE;
return FALSE;
}
}
When the bullet go down and hit the bottom of client rect the program apprear errors.Why...Don't the "break" in the BulletGo() end the thread?
|
|
|
|
|
what exactly is the error?
|
|
|
|
|
The application pops up a dialog about error saying that Debug Assertion Failed!
Program : D:\Code\TankGame\Debug\TankGame.exe
File : wincore.cpp
Line : 304
......
|
|
|
|
|
You need to synchronize the shutdown a bit better.
By the time you set m_bCanGo=FALSE you've destroyed the window,
yet your thread is still doing (attempting) operations on it.
Try something like this:
BOOL CBullet::GoDown()
{
if((m_ptPosition.y+m_rtThis.Height())>m_rtParent.bottom)
{
m_ptPosition.y+=2;
m_bCanGo=TRUE;
return TRUE;
}
else
{
<code> m_bCanGo=FALSE;
::WaitForSingleObject(m_pThread, INFINITE);
</code>
this->DestroyWindow();
m_bCreated=FALSE;
return FALSE;
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for you advice.But it helps nothing to the problem...
|
|
|
|
|
If that's the case, then you need to debug.
Can you post more specifics on the problem? Does it crash?
If so, on what line? If not, does the thread ever exit?
If not, why? Use breakpoints and single step to find out.
Etc...
Running in the debugger you should be able to find what line of
code is causing problems and trace back to why there's a problem.
Your original code is not going to work correctly. You
MUST manage synchronization of your threads!
Also, using a separate thread doesn't mean less CPU cycles are used,
as implied by your post below. One thread per moving object will start
to degrade performance once you have many objects going at once.
Plus it's wasteful of resources. Even one thread on a modern PC is
capable of tracking and rendering MANY moving objects.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I set a breakpoint on "return 0" in the thread function.When the bullet hit the bottom of client rect,the appliction jump to the breakpoint,and I step over,the debugger doesn't pop up error dialog until execute to the line AfxEndThread(nResult) in function UINT APIENTRY _AfxThreadEntry(void* pParam).
How do you think the two methods of conrol the enemies and bullets that one use threads and the other use timer in class?Which waste more CPU resource?
|
|
|
|
|
|
I have found the error:I can't end the thread after destorying the window,right?
|
|
|
|
|
Chen-XuNuo wrote: I can't end the thread after destorying the window,right?
Right Not if the thread is using the window!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am going to be crazy..
The problem still haven't been solved.
UINT BulletGo(LPVOID pParam)
{
CBullet* bullet=(CBullet*)pParam;
while(TRUE)
{
switch(bullet->GetDirection())
{
case UP:
bullet->GoUp();
break;
case DOWN:
bullet->GoDown();
break;
case LEFT:
bullet->GoLeft();
break;
case RIGHT:
bullet->GoRight();
break;
}
if(!bullet->m_bCanGo)
break;
else
bullet->MoveWindow(bullet->GetPosition().x,bullet->GetPosition().y,
bullet->GetThisRect().Height(),bullet->GetThisRect().Width());
Sleep(30);
}
return 0;
}
BOOL CBullet::GoDown()
{
if(m_rtParent.bottom==0)
GetParent()->GetClientRect(&m_rtParent);
if((m_ptPosition.y+m_rtThis.Height())<m_rtParent.bottom)
{
m_ptPosition.y+=6;
m_bCanGo=TRUE;
return TRUE;
}
else
{
m_bCreated=FALSE;
m_bCanGo=FALSE;
while( ::WaitForSingleObject(m_pThread->m_hThread,1) == WAIT_TIMEOUT)
{
Sleep(1);
}
delete m_pThread;
this->DestroyWindow();
return FALSE;
}
}
I destroy the window after ending the thread.
Is the judgement:
::WaitForSingleObject(m_pThread-&gt;m_hThread,1) == WAIT_TIMEOUT
right?If it is right,where is the problem..
|
|
|
|