|
Respected All
Regards!
The article from Hermann about Print is
"Easy to use class for ScreenCapture to printer"
I used it and working well and i bcome able to take print while using this class brillient work by him but the always the print did not come on the center of the page and that's start print from the Top Left corner of the page, now i want to take Print at the center of the page.
the link of the page is
http://www.codeproject.com/printing/prntscreen.asp
please guide for possible change in this class so that i may able to take print at the middle of the page while printing.
Regards
David
david
|
|
|
|
|
why don't you ask on the forum at the bottom of the article ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
How can I avoid multiple instance of an MFC application? My C++ code didn't kill my application even I write exit(). I don't want to close application from task manager at each time. Any suggestions...
here is the my code that dosn't kill application.exe
try
{
m_pEtmenFed->flag=false;
Disconnect();
// I get an exception here
}
catch(...)
{
}
try
{
//This part doesn't work..
exit(m_nExitCode);
//CDialog::OnClose();
}
catch(...)
{
}
|
|
|
|
|
|
Here is how I solve this problem -> I have read about it on codeproject a few years I think:
In BOOL CXXXApp::InitInstance()
I have this piece of code:
HWND hWnd = ::FindWindow(NULL,"My Application Window Name"); <br />
if (hWnd) <br />
{ <br />
::ShowWindow(hWnd, SW_SHOWDEFAULT);<br />
::BringWindowToTop(hWnd);<br />
::SetForegroundWindow(hWnd);<br />
return FALSE; <br />
}
So if the window is present the new instance will bring it on top and returns FALSE which closes the new instance.
Regards,
Dan.
|
|
|
|
|
micutzu wrote: HWND hWnd = ::FindWindow(NULL,"My Application Window Name");
Oops could lead to hang ups. I did this once it got hung up. The article referred to by toxcct is a good one.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I have taken this error from code referred by toxct
Etmen.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CInstanceChecker::~CInstanceChecker(void)" (??1CInstanceChecker@@UAE@XZ)
Etmen.obj : error LNK2001: unresolved external symbol "public: struct HWND__ * __thiscall CInstanceChecker::ActivatePreviousInstance(void)" (?ActivatePreviousInstance@CInstanceChecker@@QAEPAUHWND__@@XZ)
Etmen.obj : error LNK2001: unresolved external symbol "public: int __thiscall CInstanceChecker::PreviousInstanceRunning(void)" (?PreviousInstanceRunning@CInstanceChecker@@QAEHXZ)
Etmen.obj : error LNK2001: unresolved external symbol "public: __thiscall CInstanceChecker::CInstanceChecker(void)" (??0CInstanceChecker@@QAE@XZ)
Debug/Etmen.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
|
|
|
|
|
Try and get the latest version from PJ's website:
Link[^]
~RaGE();
|
|
|
|
|
Hey,
You have to add those files to the project. You have caopied them, But didn't add them to your project.
The compiler had no problem, since the header files were there in the same folder. But when linking, the object file must have the signatures of the function that you have used in your program.
The errors you have posted means, CInstanceChecker class is not compiled and the manged names are not generated, which made the linker show these errors.
Add those files to your project and everything will work fine.
Cheers
Jugs
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Below I give my code from the project. I have taken exception in the indicated line, what can be reason for this?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/////////////////////////////////////////////////////////////////////////////
// CEtmenApp initialization
BOOL CEtmenApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
if (instanceChecker.PreviousInstanceRunning())
{
AfxMessageBox(_T("Previous version detected, will now restore it"),
MB_OK);
instanceChecker.ActivatePreviousInstance();
return FALSE;
}
CEtmenDlg dlg;
m_pMainWnd = &dlg;
// If this is the first instance of our App then
// track it so any other instances can find it.
if (!instanceChecker.PreviousInstanceRunning()) //EXCEPTION!!!
instanceChecker.TrackFirstInstanceRunning(); // EXCEPTION!!!!
|
|
|
|
|
MuratMetu wrote: if (!instanceChecker.PreviousInstanceRunning()) //EXCEPTION!!!
dude !!! which exception ????
it works for me, so i still believe you're doing something wrong...
did you included the headers correctly ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I use correct headers, it says 'DEbug Assertion Failed'
The only difference is that I use
CEtmenDlg dlg;<br />
m_pMainWnd = &dlg;
In the example code you use it is written
CMainFrame* pMainFrame = new CMainFrame;<br />
m_pMainWnd = pMainFrame;<br />
<br />
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))<br />
return FALSE;
|
|
|
|
|
I am giving full method that I written
<br />
<br />
BOOL CEtmenApp::InitInstance()<br />
{<br />
<br />
if (!AfxSocketInit())<br />
{<br />
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);<br />
return FALSE;<br />
}<br />
<br />
#ifdef _AFXDLL<br />
Enable3dControls();
#else<br />
Enable3dControlsStatic();
#endif<br />
<br />
<br />
<br />
if (instanceChecker.PreviousInstanceRunning())<br />
{<br />
AfxMessageBox(_T("Previous version detected, will now restore it"), <br />
MB_OK);<br />
instanceChecker.ActivatePreviousInstance();<br />
return FALSE;<br />
}<br />
<br />
<br />
<br />
CEtmenDlg dlg;<br />
m_pMainWnd = &dlg;<br />
<br />
<br />
if (!instanceChecker.PreviousInstanceRunning())<br />
instanceChecker.TrackFirstInstanceRunning();<br />
<br />
<br />
<br />
CString cmdLine = m_lpCmdLine;<br />
CString token = GetNextCmdLineToken(cmdLine);<br />
while (!token.IsEmpty())<br />
{<br />
if (token == '-')<br />
{<br />
token = GetNextCmdLineToken(cmdLine);<br />
if (!token.CompareNoCase("arazi"))<br />
{<br />
dlg.m_araziDizini = GetNextCmdLineToken(cmdLine);<br />
} else if (!token.CompareNoCase("coklu_calisma"))<br />
{<br />
dlg.m_bCokluCalisma = true;<br />
} else if (!token.CompareNoCase("kostur"))<br />
{<br />
dlg.m_bKostur = true;<br />
} else if (!token.CompareNoCase("cc_sunucusu"))<br />
{<br />
m_strCCServer = GetNextCmdLineToken(cmdLine);<br />
}<br />
} else dlg.m_senaryoDosyasi = token;<br />
token = GetNextCmdLineToken(cmdLine);<br />
}<br />
<br />
<br />
int nResponse = dlg.DoModal();<br />
if (nResponse == IDOK)<br />
{<br />
}<br />
else if (nResponse == IDCANCEL)<br />
{<br />
}<br />
<br />
return FALSE;<br />
}<br />
<br />
<br />
|
|
|
|
|
This is not working for your dialog-based application because at the time you call
PreviousInstanceRunning() you do not have a valid window handle for your application.
I suggest you find a mechanism to plug the window handle of your dialog, during OnInitDialog , into the hMainWnd member of the CWindowInstance class. Then it will probably work for you.
Because inside the ActivatePreviousInstance is the call like this:
HWND hWindow = pInstanceData->hMainWnd;<br />
if (hWindow)
And if you understood the code and had single stepped through it, you would find that this handle is probably always NULL (0) and the IsWindow call will fail every time.
|
|
|
|
|
Greetings,
A few friends and I have recieved funding for a project that we are working on. We're still in the planning stages but we've hit a stone wall. We've ordered 2 new IBM eServers that arrive in a few months to experiment on. Only problem is, none of us have experience writing server applications that need to ultilise more than 1 server. I was wondering if anyone might be able to recommend any good books on the subject?
Any help will be greatly appreciated,
Thank you,
Gordon R. Speirs
|
|
|
|
|
Dear Sir/Maddam,
I am kumar studying MCA from Bangalore University.
I'm in 3Sem, in this sem i've to do a project on Encryption using
C/C++.
So please can u guide me on going further.
Waiting for response.
(kumar)
|
|
|
|
|
|
Hi all ,
If I have an empty destructer , does it automatcly calls to the delete() function ?
or should I include it within it ?
thanks very much
|
|
|
|
|
why should it call delete ? to destry you object instance ? no, because the destructor is not there to destroy the object but to free the possible memory it could have alocated from its construction to the moment the destructor is called.
basically, if you allocate some memory dynamically from within the object methods (sonctructor included), free the memory at last in the destructor. if you don't, then let it empty. you could also use it to reset the fields to their default values...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I think calling delete will call the destructor. So no need to call delete while the object is already being destroyed.
I believe that in the destructor, you should close any open handles, deallocate any allocated memory etc.
this is this.
|
|
|
|
|
ita_cas wrote: If I have an empty destructer , does it automatcly calls to the delete() function ?
or should I include it within it
A Destructor is basically for giving your object a chance to perform any cleanup operation that is required. Like if it has allocated any memory then here it can do the necessary clean up. Closing all open handles etc.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Actually, delete is an operator, and destructors are called when an object is deleted. Here's an example:
class A {
public:
~A();
};
class B: public A {
~B();
};
class C: public B {
~C();
};
C *c;
delete c; When the line delete c; is executed, destructors are called in the following order: C::~C(); B::~B(); A::~()A; , and then the memory itself is freed. The same thing happens in this case:
{
C c;
} when execution passes the closing brace, the c object is deleted by falling out of scope, and the destructors are called in the same order as before.
Software Zen: delete this;
|
|
|
|
|
hi
after i use ShellExecute() to run exe file i coudn't close it from my program by non of th function that i no like fileclose()
so i need help to close exe file from my program
|
|
|
|
|
did you try CWnd::PostMessage(WM_CLOSE); ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: did you try CWnd::PostMessage(WM_CLOSE); ?
Humm... Nice .. But CWnd should be pointing to Other Window otherwise it will close it self!
Better option will be ::PostMessage(WINDOW TO CLOSE HANDLE,WM_QUIT,...)
"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
|
|
|
|