|
|
Hi all,
How can i make my application to choose a printer other than the default printer programmatically?
thanks
kleser
|
|
|
|
|
Call:
OpenPrinter()
StartDoc()
StartPage()
EndPage()
EndDoc()
ClosePrinter()
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks for your reply, this works with MFC?
thanks
|
|
|
|
|
Kleser wrote:
thanks for your reply, this works with MFC?
Yes. You can try CPrintDialog.
Danny
|
|
|
|
|
Kleser wrote:
this works with MFC?
Yes. You'll also want to check out the CDC class as it has most of these as member functions.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Search MSDN for SetPrinterDevice - there is function you can write in CApp to change app current printer by name. Then default MFC printing routine will use it. Contact me in private, if you will not find it - I will send it to you.
Igor Green
http://www.grigsoft.com/
Compare It! + Synchronize It! - files and folders comparison never was easier!
|
|
|
|
|
Message when clicking on a Edit Box with the mouse
--------------------------------------------------------------------------------
How can i get a message when i click on a Edit Box with the mouse? Many thanks in advance. Serj.
|
|
|
|
|
Create a handler for the WM_LBUTTONDOWN message and then call MessageBox() . Is that at all what you were looking for?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I've got problems to get the handler with the edit box. My code is:
void CSubtitlesDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CEdit* pW = NULL;
pW= (CEdit*) GetDlgItem(IDC_EDIT_SUBTITLES_LIST);
GotoDlgCtrl(pW);
AfxMessageBox("Click sobre la lista de subtítulos");
SetFocus();
}
|
|
|
|
|
I would suggest getting out of the habit of using GetDlgItem() and use member variables instead. Create a CEdit member variable in your CSubtitlesDlg class and then do:
void CSubtitlesDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
GotoDlgCtrl(&m_editSubtitles);
AfxMessageBox("Click sobre la lista de subtítulos");
SetFocus();
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
see if the OnFocus() event handler don't work better...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
(using VS.net 2003 and boundschecker 7.2 )
I have a weird behaviour with bounschecker and my simple statically linked MFC application.
I created a basic MFC application from VS.net wizard; then, I selected in the project settings to "Use MFC in a Static Library".
when running the application I get "allocation conflicts" when closing a the document ( when closing the application ) telling me that in the method void CView::PostNcDestroy() the line that contains delete this; I have a conflict (for example ) :
"Allocation Conflict: Attempting to call CObject::operator delete on 0x027D7CA0; pointer was allocated by _malloc_dbg."
If I use the "Use MFC in a Shared DLL" I have no such allocation conflict.
Do I have to set another project setting somewhere ?
Anyone have an Idea before trying to contact compuware ?
thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
When I have a C++ class, let's call it CCLassX,
I construct one on the heap using
CClassX* pC = new CClassX();
versus
CClassX* pC = new CCLassX;
what is the difference?
|
|
|
|
|
I think this is a ClassX case of the same behaviour.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Blake Miller wrote:
what is the difference?
None. It's just syntactic sugar.
Good music: In my rosary[^]
|
|
|
|
|
I think, both are same only as both will allocate different memory.
|
|
|
|
|
No, they'll produce the exact same code and will behave exactly the same.
Good music: In my rosary[^]
|
|
|
|
|
Both expressions are equal. You can remove the brackets when the constructor of CClassX does not have any parameters.
Don't try it, just do it!
|
|
|
|
|
i think about one more think anybody evoked in the previous answers :
if the constructor is declared as explicit , the compiler may need you to call explicitely the constructor (for example with new class() )...
if some can confirm/infirm my assertion...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Explicit only says that stuff like this:
void function(const CString& str);
function(_T("A LPCTSTR which is an accepted constructor parameter for CString")); will fail, because you have to be explicit about constructing CString objects (assuming that CString(LPCTSTR) was indeed marked as explicit).
Good music: In my rosary[^]
|
|
|
|
|
Blake Miller wrote:
When I have a C++ class, let's call it CCLassX,
I construct one on the heap using
CClassX* pC = new CClassX();
versus
CClassX* pC = new CCLassX;
the difference is that in second line CCLassX is written with 'L'
and in first line with 'l'
to be more serious ...
I think if we have class , for example :
CClassX
{
int x;
double y;
};
and
1 . CClassX* pC = new CClassX();
2 . CClassX* pC = new CClassX;
then
in first case x and y variables will be initialized and be equal to 0
in second case x and y variables will not be initialized.
is there anything more
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 18:17 Friday 23rd September, 2005
|
|
|
|
|
Giorgi Moniava wrote:
in first case x and y variables will be initialized and be equal to 0
in second case x and y variables will not be initialized.
never...
i think you didn't read the other poster answers (or you have a bad knowledge about implicit compiler actions, but calling new CClassX (without parenthesis) will call the default constructor (wich is more often the one with no parameters).
i say "more often" because consider the following :
class X {
int i;
double d;
public:
X(i = 1; d = 1.) {
}
};
here, we explicitely define only one constructor, but it is the one that will be the default constructor...
calling both new X() or new X will cause the following assertions :
X* p = new X;
p->i == 1
p->d == 1.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
never...
just try ,
Declare class
CClassX
{
public :
int x;
double y;
};
and then in main construct two objects on the heap
...
CClassX* pC1 = new CClassX();
CClassX* pC2 = new CClassX;
...
and try
cout<<pC1->x<<" "<<pC1->y; //here output will be 0 0
cout<<pC2->x<<" "<<pC2->y; //here output will be random numbers
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Then that is a compiler specific detail. It's not in the standard! The Visual C++ compiler for instance, initializes all members to seemingly "garbage" values in debug mode. The garbage however, is useful, as it gives the programmer a good hint on what is wrong (uninitialized variables are easily detected). IIRC, the compiler initializes member variables with byte strings containing repeating the pattern 0xcd . Members of deleted objects are given 0xfe .
I wouldn't rely on this behaviour, because it's probably subject to change with any release, and it is not portable.
--
Keep talking! You're the fool, I'm the preacher.
|
|
|
|