|
C:\Program Files\Internet Explorer\IEXPLORE.EXE C:\temp\test.xml
should work
|
|
|
|
|
Hello,
I want to draw into a DC some rotated text, drawing also the rectangle like the selection of that text. Everything works fine except...I cannot align the text vertically to the bottom of the rectangle. Function DrawText can do that but only for single line text.
I've tried also to create a bitmap with the unrotated text and rotate that bitmap but the bitmap it's not transparent and the rotation is slow...
Can anybody suggest me what to do?
Thanks in advance!
|
|
|
|
|
|
when looking up for the class members of the class CRect in the MFC documention, it seems that we can't see the following four member variables:
top,left,bottom and right. the same thing happens to many MFC classe, doesn't it?
how can I dig out these hidden members?
thank you very much!
-------------------
I am trying to love c++
|
|
|
|
|
Huh ?
which CRect are you talking about ?
you can have access to each member directly or get the TopLeft and BottomRight values as CPoint.
CRect cc;
cc.top = 1;
cc.bottom = 2;
cc.left = 3;
cc.right = 4;
CPoint topLeft = cc.TopLeft( );
CPoint bottomRight = cc.BottomRight();
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
what are you trying to do exactly ? i'm not sure i understand you.
you want to get these values ?
bu looking at the CRect[^] class members, you could use several operation to get what you need, such as BottomRight , CenterPoint , Height , Width , Size ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ewighell wrote: when looking up for the class members of the class CRect in the MFC documention, it seems that we can't see the following four member variables:
What do you mean by "see?" The CRect class is derived from the tagRECT structure, which is where those member variables come from.
ewighell wrote: how can I dig out these hidden members?
How exactly are they hidden?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I am sorry for not expressing myself properly.
I was just wondering why I could not see these four members in the mfc documentation.
I am new to mfc. so I want to see these members in the documentation for the CRect class before using them.
I don't konw if I have make my idea clear.
-------------------
I am trying to love c++
|
|
|
|
|
I got the answer, thank you all especially DavidCrow very much.
-------------------
I am trying to love c++
|
|
|
|
|
==========================
typedef struct
{
int a;
HWND hWnd;
HDC hDC;
}thread;
thread obj_opendevice;
void OpenDevice::Draw_PMRconnecting()
{
CWinThread *pThread = AfxBeginThread(draw_line,&obj_opendevice);
}
UINT draw_line(LPVOID param)
{
}
I have created a thread using this above code how do kill the thread
by using the handle in the structure .
HWND hWnd can i use this handle to close the thread .
I want to close the thread from anyexternal function so i cannot
use the AfxEndThread(0);
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
vikas amin wrote: do kill the thread
by using the handle in the structure
TerminateThread(...), but you must read remark section of this api in the MSDN
"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
|
|
|
|
|
Hii everyone;
I want to print a text output from a USB port attached printer with in my code. I am sending u the details of my code as an attachment.Basically this is the test application and i need to print the text(say "HelloWorld") on the printer using openPrinter, writePrinter,StartDocPrinter,StartPagePrinter API's. I have checked all the returned value of the API & all are working fine.
OpenPrinter return non Zero and gives the handle
StartDocPrinter return the JobId
WritePrinter returns non Zero
WritePrinter(hPrinter,(LPBYTE)(LPCSTR)_T(cstrTest),cstrTest.GetLength(),&pcWritten)
where
hrinter = Handle to the printer
cstrTest = CString cstrTest = "HelloWorld"
pcWritten = bytes written to the printer.
But after all is working fine , i am not getting any output from the printer. When my command executes then in the printerprinting document the status is printing after sometime it become deleting it goes off.
Can anyone suggest me to comeback.Remember i don't want to use StartDoc, StartPage API's. Basically i need RAW data to send to print & i don't want to take the Device Context of the Printer.
-------------------------------------------------------------------------------------
void MyFunction()
{
HANDLE pHandle;
DOC_INFO_1 pDocInfo;
memset(&pDocInfo, 0, sizeof(pDocInfo));
pDocInfo.pDatatype = "RAW";
pDocInfo.pDocName = "MyPrintControl";
pDocInfo.pOutputFile = NULL;
PRINTER_DEFAULTS lpdef ; // this is for the parameter in the OpenPrinter API.
ZeroMemory(&lpdef, sizeof(lpdef));
lpdef.DesiredAccess = PRINTER_ACCESS_USE;
lpdef.pDatatype = "RAW";
DWORD pcWritten = 0;
char cBuffer[30] = "My Testing\f"; // \f is for form feed
char cBuffer[10] = "ToPrint";
int x = -1;
if(x=OpenPrinter( "Lexmark 2200 Series" ,&pHandle ,NULL /* &lpdef*/))
MessageBox("OpenPrinter Successful","OK") ;
else
ShowError();
int JobID = 0;
if(JobID = StartDocPrinter( pHandle , 1 , (LPBYTE) &pDocInfo) )
MessageBox( "StartDocPrinter Successful" , "OK" ) ;
else
ShowError();
if( x = StartPagePrinter(pHandle))
MessageBox("StartPagePrinter Successful","OK");
else
ShowError();
if(x=WritePrinter( pHandle, cBuffer, sizeof(cBuffer), &pcWritten ))
MessageBox("WritePrinter Successful","OK");
else
ShowError();
EndPagePrinter(pHandle);
EndDocPrinter(pHandle);
ClosePrinter(pHandle);
}
|
|
|
|
|
Have you considered the following:
StartDoc();
StartPage();
TextOut();
EndPage();
EndDoc(); This is how I've always printed. I'm not sure what those other functions you are using do.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hii ;
Thanx For ur reply . can u plz paste the below code. & Tell me whether it is working or not .I mean to say that whether "TestPage_Please check it" is printing on 10,10 point on paper.
Plz check it.
void ForPrint()
{
HDC hdcPrinter;
static DOCINFO DocInfoStruct;
DocInfoStruct.lpszDatatype = "RAW";
DocInfoStruct.lpszDocName = "TestDocumentthrough DC";
DocInfoStruct.lpszOutput = NULL;
hdcPrinter = CreateDC("winspool","Lexmark 2200 Series",NULL,NULL);
//"winspool" is the name of the Driver
//","Lexmark 2200 Series" is the Printer name u can rename it wioth ur printer
StartDoc(hdcPrinter,&DocInfoStruct);
StartPage(hdcPrinter);
SetTextAlign (hdcPrinter,TA_CENTER) ;
BOOL bRet = TextOut(hdcPrinter,10,10,"TestPage_Please check it",20);
//It should print the Output on the point(10,10) & 20 letters
//should be printed
EndPage(hdcPrinter);
EndDoc(hdcPrinter);
}
|
|
|
|
|
AsimUmair wrote: can u plz paste the below code. & Tell me whether it is working or not .
More importantly, though, is whether it works for you.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi,
This is a class which encapsulates a char * and which has an operator== defined which I think should work. But it does not. Can you tell why?
Please whatch below in code at '***' for further explanation
class IBZXMLLAYER_API String {<br />
public:<br />
explicit String():m_szValue(NULL) {};<br />
String(String & toCopy):m_szValue(new char[toCopy.length()]) {strcpy(m_szValue, (const char*)toCopy);}<br />
String(char const * const szValue):m_szValue(new char[strlen(szValue)+1]) {strcpy(m_szValue, szValue);};<br />
~String() {delete [] m_szValue;};<br />
size_t length() {return strlen(m_szValue);}<br />
operator const char*() const {return m_szValue?m_szValue:"";};<br />
String & operator=(std::string const & strToCopy);<br />
String & operator=(char const * const szToCopy);<br />
<br />
<br />
bool operator== (String const & toCompare) const {return 0 == strcmp( (const char*)this, (const char*)toCompare ); };<br />
<br />
bool operator> (String const & toCompare) const {return 0 > strcmp( (const char*)this, (const char*)toCompare ); };<br />
bool operator< (String const & toCompare) const {return 0 < strcmp( (const char*)this, (const char*)toCompare ); };<br />
private:<br />
char * m_szValue;<br />
};
Regards
Werner
|
|
|
|
|
You are performing an explicit cast via (const char*)this.
It is not resolving to operator const char*().
If you _really_ want to do it this way (i wouldn't) then use operator const char*().
e.g
bool operator == (String const & toCompare) const {
return 0 == strcmp( operator const char*(), (const char*)toCompare );
}
[EDIT]
this is a pointer, so when you try to cast with (const char*) the compiler assumes you know what you are doing and treats the pointer as a (const char*) as opposed to what it is (String*).
toCompare is an instance of a String, so when you try to cast with (const char*) the compiler also assumes you know what you are doing, but it also assumes you have told it how to convert a non-pointer object to a pointer (operator const char*()).
[/EDIT]
...cmk
Save the whales - collect the whole set
-- modified at 6:53 Thursday 27th October, 2005
|
|
|
|
|
You are right,
(const char*)this
does - of course - not resolve to
operator const char*() of *this.
If I had used
static_cast<const char*>(*this)
the compiler would have complained when trying to cast this to char*
static_cast<const char*>(this).
Regards
Werner
-- modified at 7:19 Thursday 27th October, 2005
|
|
|
|
|
> If you _really_ want to do it this way (i wouldn't) then use operator const char*()
Why not would you?
Thank you.
Regards
Werner
|
|
|
|
|
Generally whenever i see a cast i wonder what is going on.
That is, the code is not as clear as it could be.
I would be more inclined to do something like:
long String::Cmp( const String &S )
{
if( m_szValue == S.m_szValue ) return(0);
if( !m_szValue ) return(-1);
if( !S.m_szValue ) return( 1);
return( strcmp(m_szValue, S.m_szValue) );
}
bool String::operator == ( const String &S ) const { return( Cmp(S) == 0 ); }
bool String::operator < ( const String &S ) const { return( Cmp(S) < 0 ); }
...
My Cmp() actuall takes another parameter that defines how the compare is done, i.e. case-insensitive, numeric, ignore (leading, middle, trailing) spaces, ...
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Dear Chris,
I argued with my colleague about this yesterday and thought about it in the evening as well.
I think, the problem actually is, that I wanted an extractor, but I overrode the cast operator instead. I did so because it has often been done in the Windows API (_variant_t, _bstr_t), rather than it had been much convenient to do so.
(1) I can see now, that this is much dangerous because it is syntactically equivalent to an old style cast.
(2) There is also a a point with _variant_t and _bstr_t - Extractors, which I don't like at all. They sound like (char * const) and this doesn't say at all, what it is actually doing. Syntactically they are like functions without a name. I will prefer something like std::string extractor c_str in the future.
(3) I rarely use true casts at all. I had some cases, where type conversions were necessary because I used results from one library as inputs for an other. But I didn't cast there, because this would hide the fact of conversion during compilation. So someone who compiled the program would not be warned and would not check, whether the cast is ok under the circumstances given.
Regards Werner
|
|
|
|
|
Hi,
I think you made an error in your constructors.
WernerPos wrote: String(String & toCopy):m_szValue(new char[toCopy.length()]) {strcpy(m_szValue, (const char*)toCopy);}
String(char const * const szValue):m_szValue(new char[strlen(szValue)+1]) {strcpy(m_szValue, szValue);};
you didn't forget to allocate space for the ending 0, but did forget to initialize it.
String(String & toCopy): m_szValue(new char[toCopy.length() + 1])
{
strcpy(m_szValue, (const char*)toCopy);
m_szValue[toCopy.length()] = 0;
}
String(char const * const szValue):m_szValue(new char[strlen(szValue)+1])
{
strcpy(m_szValue, szValue);
m_szValue[strlen(szValue)] = 0;
};
This causes to have a wrong result for
size_t length() {return strlen(m_szValue);}
because strlen gives the number of chars until the first '\0'.
bool operator== (String const & toCompare) const {return 0 == strcmp( (const char*)this, (const char*)toCompare ); };<br />
bool operator> (String const & toCompare) const {return 0 > strcmp( (const char*)this, (const char*)toCompare ); };<br />
bool operator< (String const & toCompare) const {return 0 < strcmp( (const<br />
char*)this, (const char*)toCompare ); };<br />
because strcmp alsoo requires the ending '\0' to compare the strings or which is greater or not.
Regards Kurt
codito ergo sum
|
|
|
|
|
: ->
before I get flamed or anything, my apologies
strcpy does alsoo copies the ending '\0'. (I've confused it with memcpy, or strncpy ).
But still, in the second constructor you need to add an additonal character to store the zero.
String(String & toCopy): m_szValue(new char[toCopy.length() + 1]) <br />
{ strcpy(m_szValue, (const char*)toCopy); }
My sincere apologies of someone who is of sleep deprived
codito ergo sum
|
|
|
|