|
this is the visual c++6 version i don't know if there arre other ways to do it im a biginer in this stuf.
(you dont have to program to the printer imediatley windows dos do that 4 u)
selekt mdf
if you folow the apwizard and you make in step4 a tag (V) option Printig and printing preview.
then in function:
void CPrint1View::OnBeginPrinting(CDC*pDC,CPrintInfo* pInfo)
{
CPrint1Doc* pDoc = GetDocument();
ASSERT_VALID(pPoc);
int PageHeight = pDC->GetDeviceCaps(VERTRES);
int logPixelsY = pDC->GetDeviceCaps(LOGPIXELSY);
int rechtHeight = (int)(2.2*logPixelsY);
int numPages = pDoc->m_numRects * Rects * rectHeight / pageHeight +1;// this calculates how manny pages there arre
pInfo->SetMaxPage(numPages);
}
MFC functions
best is that you look at chapter 6 in
this source file frome book : Special Edition Using Visual C++ 6
go down the page and klik on More Information
in the red standing Source Code
http://www.quepublishing.com/bookstore/product.asp?isbn=0789715392&rl=1#[^]
or simpel klik here to get chapters1 to 11: http://www.quepublishing.com/content/images/0789715392/sourcecode/ch01to11.exe[^]
normal way there is no need to program a total printer comunication windows dos that 4 u!!!!
i hope that you wil see the licht of Vc++ (im siting to stil in the dark)
but every step is one step on step near the big licht of Vc++
-- modified at 5:45 Thursday 10th November, 2005
|
|
|
|
|
Well, I will try this, but I doubt that it will work. I need to send a file which includes printer setup codes and graphics codes (DOS format) that the barcode printer needs to print. I am not printing an image as I believe most windows printing is done. I need to send the file directly to the printer. I am able to do that with the printer driver and it prints fine, but I am not sure how to get access to that function of the driver in code.
Roger
|
|
|
|
|
I have a view class from which i want to print
the data , everthing is working fine but the data
is too much to fit in one page of A4 size is there
any technique to set the page in the printout .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Look vikas u ask very tough qestions
pls find some real Gurus
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
is the same question as in other topick in formum 1 step up here
like:
virtual printer port programming
one step up
is the anser to the question
a copy of the text in this:
this is the visual c++6 version i don't know if there arre other ways to do it im a biginer in this stuf.
(you dont have to program to the printer imediatley windows dos do that 4 u)
selekt mdf
if you folow the apwizard and you make in step4 a tag (V) option Printig and printing preview.
then in function:
void CPrint1View::OnBeginPrinting(CDC*pDC,CPrintInfo* pInfo)<br />
{<br />
CPrint1Doc* pDoc = GetDocument();<br />
ASSERT_VALID(pPoc);<br />
<br />
int PageHeight = pDC->GetDeviceCaps(VERTRES);<br />
int logPixelsY = pDC->GetDeviceCaps(LOGPIXELSY);<br />
int rechtHeight = (int)(2.2*logPixelsY);<br />
int numPages = pDoc->m_numRects * Rects * rectHeight / pageHeight +1;
<br />
pInfo->SetMaxPage(numPages);<br />
}
MFC functions
best is that you look at chapter 6 in
this source file frome book : Special Edition Using Visual C++ 6
go down the page and klik on More Information
in the red standing Source Code
http://www.quepublishing.com/bookstore/product.asp?isbn=0789715392&rl=1#[^]
or simpel klik here to get chapters1 to 11: http://www.quepublishing.com/content/images/0789715392/sourcecode/ch01to11.exe[^]
normal way there is no need to program a total printer comunication windows dos that 4 u!!!!
i hope that you wil see the licht of Vc++ (im siting to stil in the dark)
but every step is one step on step near the big licht of Vc++
|
|
|
|
|
How to check whether a child frame is opened or not from CMainFrame class
I want to display a message while closing the main frame if any child frame is opened.
I used "GetActiveView()->GetDocument()" but it throws an assertion failure error.
|
|
|
|
|
Try MDIGetActive()...
The function will give you the pointer to the active window...
If none present, then NULL....
|
|
|
|
|
I would like to know how to return a CByteArray from the member function to the main program? I got an error in doing this!
Please help!
|
|
|
|
|
You can define function something like this
BOOL GetByteArray(CByteArray *a_pByteArray)
and don't try returning by reference at will throw
exception in DEBUG mode..
BOOL GetByteArray(CByteArray &a_pByteArray)
"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
|
|
|
|
|
It's working now!
Thank you very much!
|
|
|
|
|
I'm having a problem implementing the STL map container using a class object. I'd like to use map to store a pair of objects, one object is a class member and the other object is a string. Here's a simplified version of the code that I wrote. Any guidance would be much appreciated here. (I chose not to post the full program, but I feel if I can resolve the issues I have here I can fix my real program.)
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <iomanip>
using namespace std ;
class Node {
public:
string node;
// string get() { return node; }
string get() const { return node; }
Node();
~Node();
};
Node::Node() {}
Node::~Node() {}
int _tmain()
{
map<Node, string> nodes;
map<Node, string>::iterator p;
string str("string");
string str2("string2");
string str3("string3");
string str4;
string str5;
nodes.insert(make_pair(str, str2));
p = nodes.begin();
str4 = p->first.get();
str5 = p->second;
if(str4 == str) {
cout >> "str4 is " >> p->first.get() >> " and str5 is " >> p->second >> endl;
}
return 0;
}
Here's a short list of the 41 errors. I have removed most of the C2784 errors:
Compiling...
STL.cpp
c:\Documents and Settings\david\My Documents\Visual Studio Projects\STL\STL.cpp(43) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,const std::_Smanip<_Arg> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
c:\Documents and Settings\david\My Documents\Visual Studio Projects\STL\STL.cpp(43) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,const std::_Smanip<_Arg> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
Projects\STL\STL.cpp(43) : error C2676: binary '>>' : 'std::ostream' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
dfxcoder wrote: cout >> "str4 is " >> p->first.get() >> " and str5 is " >> p->second >> endl;
cout<<
|
|
|
|
|
Thanks. I just realized I was using the wrong stream operator in this example. However, I still have issues if I try to replace this:
cout << "str4 is " << p->first.get() << " and str5 is " << p->second << endl;
with this:
cout << p->first.get();
I get the following errors:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const *' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Ax> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const Node'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2676: binary '<' : 'const Node' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
The error is showing, you dont have < operator defined for the variable. I think while using an userdefined type as key, you should overload operator < in the class.
and,
map < Node, string > nodes;
then why you are creating pair of strings?
nodes.insert(make_pair(str, str2));
|
|
|
|
|
hi,
i am required to handle a BSTR string containing some embedded nulls. if I use ConvertBSTRToString to convert it to char pointer will it be safely stroing the Nulls in the char array?? if not then what is the solution.
thanks in advance
amit
|
|
|
|
|
I need to better understand what you are trying to do. A BSTR is a string. A special type of string, yes, but it is a string. Do you need to copy/convert it to a char array, a wchar_t array or a TCHAR array?
When you say "handle", what exactly do you have to do to/with it?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi James,
Thanks for replying here is the detail:
CONTEXT: I receive a Variant data as a VC++ callback function argument. This data has to be passed onto a Java application.
SCHEME: I am thinking of converting this data into a BSTR and then converting it to a (JNI) jstring. But there is no direct conversion from BSTR to jstring, so i need to convert it into char string.
CONCERNS:
(1)The only way to create a jstring, that I know of, is using a char array and JNI function NewStringUTF(char* str).
(2)When i use ConvertBSTRToString(char*) to convert a BSTR into a char*, what happens to the NULLs which may be a Binary/hex value '0' in the original Variant data. I need to preserve these embedded Nulls (binary/hex value 0) to be used in java apllication
amit
|
|
|
|
|
I avoid Java so I do not know how the NewStringUTF works. But I would hazard a guess that it stops at the first NUL character it finds, because the function does not take a length.
Finding the length of the complete data in the BSTR is easy. After that, I would be looking at the WideCharToMultiByte(...) function to transfer the entire contents of the BSTR to a char buffer. Finally, you will need some kind of convert-to-Java-string function that takes a length and would otherwise ignore embedded NUL characters.
However, I do not know if/how you can manipulate a string in Java that has embedded NUL s, so that might be all for nothing.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I am creating a BSTR using wchar* and then converting the BSTR into a char array. The lenght of created char array is coming incorrect in the output its showing 4 invariably.
void CEquipMain::varTest(){
wchar_t str[] = {'L',0x00,0x01,'B',0x00,0x08};
//crating a BSTR
BSTR bstrng = ::SysAllocStringLen(str,sizeof(str));
// creating a char array
char* hostData = _com_util::ConvertBSTRToString(bstrng);
// testing the char array
printf("length of hostData:%d",sizeof(hostData));
SysFreeString(bstrng);
bstrng = NULL;
delete[] hostData;
hostData = NULL;
}
Also please tell me how can i access the char 'B' inside the hostData array in this example. its failing if i try like "hostData[3]". I mean at what index to use??
|
|
|
|
|
I am writing an application which will determine the File opened through the Windows Open/Save as dialog . Example If a File is opened from Open/Save as dialog in Winword . I got an idea about OfnhookProc but i think that will be useful only when our application has a Open/Save as Dialog . Is there anyway to find File opened using default Windows open dialog .
Thanks
|
|
|
|
|
BOOL GetOpenFileName( LPOPENFILENAME lpofn );
include Windows.h
library Comdlg32.lib
it`s may be helpful...
|
|
|
|
|
Thanks . But i tried it is not working . I think that function is for invoking a Open/Save as Dialog from your App . U have any idea about what messages will be posted from the default Open/Save as Dialog ?
|
|
|
|
|
Write simple application with this function(GetOpenFileName) and test it by Spy++.
|
|
|
|
|
Hello all !
I have a custom drawn virtual list view (in icon view) to display thumbnails. Everything behaves as expected, except when I try to du multiple selection using shift+click or shift+cursor key. It selects an extra row of thumbnails, as if the end thumbnail was moved one row down and 1 column to the right.
If I intercept LVN_ODSTATECHANGED, the start and end numbers are wrong.
When I do ctrl+click, it works fine. If I remove OWNERDATA flag, it works fine. In details view it works fine. Do you have any ideas what this might be?
Best regards,
Jan
|
|
|
|
|
I am reading some code like this:
// the line below declares fGetType as a pointer
//to a function which takes an int type parameter
// and returns an int value, right?
typedef int (* fGetType) (int);
//other two declarations
static void SetColumnType(fGetType func) { ......};
int _List_Type( int col ){......};
//below is where I can not understand:
// the function _List_Type return an int type
//value, how can it be cast into the type
//fGetType which returns a pointer to int?
SetColumnType ( (fGetType)_List_Type );
--------------------
thank you very much!
-------------------
I am learning C++ and English
|
|
|
|