|
This should be a simple problem, but I am unable to solve it! My environment is VStudio 2005 and MFC.
The issue is printing text onto a DC. Should be simple enough, but here are some constraints:
1. The text may be rotated 0, 90, 180, 270 degrees.
2. The text may need reformatted within the bounding rectangle, meaning word-breaks.
3. The text will need to be aligned horizantally and vertically within the bounding rectangle - left, right, and center horizontally, top, center, bottom vertically.
Rotating text is not a problem.
Normally, I could use DrawText to print the text, but on rotated fonts, DrawText seems to choke. I tried TextOut and ExtTextOut. These rotate and position just fine, but can't seem to do word-wrap.
Is there an API call or setup that I am missing? Or do I need to draw to a memory DC and somehow rotate it to fit?
Or can someone please point me to some code that will accomplish this easily?
Thank you for your time
|
|
|
|
|
It might be Q&D, but what about drawing the text onto an in-memory bitmap/surface and then rotating it, and then blitting it to the target bitmap/surface?
Other than that, maybe the GDI+ libraries have something to offer?
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Unfortunately, I am out of options at this point... In-Memory bitmap and rotate would have to be the answer. I was kind of hoping some built-in API.
|
|
|
|
|
Stephen,
I am not familiar with the World Transform functions, so I will have to go through the sections to pick up on them, but thank you for pointing me at them. From the initial look I had, they do look promising.
Santanu
|
|
|
|
|
Stephen,
Your suggestion was exactly what I needed. I used the SetWorldTransform API to rotate and align text along the required axes and let DrawText do the wordwrap part.
Thank you very much.
|
|
|
|
|
How do you reverse the action on a Spin control? Currently, down makes the number go up, and clicking the up arrow makes the value go down. How do you reverse the control, so the up arrow increases the number, and down decreases it?
|
|
|
|
|
littleGreenDude wrote: How do you reverse the action on a Spin control? Currently, down makes the number go up, and clicking the up arrow makes the value go down. How do you reverse the control, so the up arrow increases the number, and down decreases it?
They hide that information in the documentation[^]
led mike
|
|
|
|
|
A more useful response...
Set the range to anything other than the default 0 to 100 and the control behaves normally.
m_Spin1.SetRange(0, 52);
The up-down control is a victim of Windows' reversed y-axis.
Mathematically, the (0, 0) coordinate should be at the bottom left corner of the screen, with y increasing as you move up the screen. Windows, on the other hand, puts the (0, 0) coordinate at the upper left corner, with y increasing as you move down the screen.
|
|
|
|
|
Hey Clown, you make the questions and the answers ?!
|
|
|
|
|
Sorry, thought it was my circus too....
|
|
|
|
|
toxcct wrote: Hey Clown, you make the questions and the answers ?!
I don't want to start an argument but I don't see any answers provided by the clown.
you haven't told us what your problem is (apart from an inability to think clearly).
Pete O'Hanlon - the C# forum
|
|
|
|
|
The Clown wrote: A more useful response...
Set the range to anything other than the default 0 to 100 and the control behaves normally.
m_Spin1.SetRange(0, 52);
he asked how to do the trick, and then, he just tell how to solve it as anybody else would answered him
|
|
|
|
|
littleGreenDude wrote: A more useful response...
hmmm that link was pretty useful...
"Clicking the up arrow moves the current position toward the maximum, and clicking the down arrow moves the current position toward the minimum. By default, the minimum is 100 and the maximum is 0. Any time the minimum setting is greater than the maximum setting (for example, when the default settings are used), clicking the up arrow decreases the position value and clicking the down arrow increases it."
Send in the clowns.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everybody ,
i created a function (fnLBE_GdtIn(int enEing)) in a Win32 Dll.
In this function i use the stl string class (dynamic string arrays) to work with the strings.
The result (return values) are different dynamic string arrays which i have to convert to BSTR cause i have to return them to VB !!!!!
I know how to pass BSTR to VB but i don't know how to convert dynamic string arrays to BSTR !!!
Here is the code (it is not complete i haven't sent the filling of the arrays ans so on because it is to much code, hope this is enough !)
<br />
LBE_GDTIN_API BSTR _stdcall fnLBE_GdtIn(int enEing)<br />
{<br />
int i = 0, j = 0, k = 0, l = 0;<br />
ifstream f;<br />
string sRead;<br />
string *arrGdt;<br />
string *arrClean;<br />
string *arrRelease;<br />
string *arrSearch;<br />
int len = 0;<br />
<br />
arrSearch = new string[4];<br />
arrSearch[0] = "3101"; <br />
arrSearch[1] = "3102"; <br />
arrSearch[2] = "3103"; <br />
arrSearch[3] = "3110"; <br />
<br />
<br />
arrGdt = new string[len];<br />
arrClean = new string[len];<br />
arrRelease = new string[len];<br />
<br />
switch(enEing)<br />
{<br />
case 3101:<br />
while (k < len)<br />
{<br />
if (arrSearch[0] == arrClean[k].erase(4,arrClean[k].find("/n")))<br />
{ <br />
<br />
return arrRelease[k];<br />
}<br />
k++;<br />
} <br />
break;<br />
<br />
and so on .......<br />
Many Thanx For Your Help ...
hopefully & best regards
Croc
|
|
|
|
|
Why are using arrays of strings rather than an STL collection?
led mike
|
|
|
|
|
Hi mike,
that's right, I solved the prob like :
<br />
string ret;<br />
ret = arrRelease[k];<br />
now I have simple stl strings to convert !
Itried it with
<br />
return CComBSTR (ret.c_str());<br />
but it still not works
Could you help me with a convertion fron simple stl string to BSTR ???
hopefully & best regards
Croc
|
|
|
|
|
You need to convert the string to unicode, or just use unicode from the beginning. (I recommend the latter.) If arrRelease was an array or vector of wstring, then you could use something like return SysAllocString(arrRelease[k].c_str()) Also, I agree with Led Mike that STL containers like vector<string> are much more appropriate than string *
Nathan
|
|
|
|
|
Hi Nathan & Mike,
many thx for your answers, I solved the problem like this :
<br />
CComBSTR (LPCWSTR(arrRelease[k].c_str()));<br />
best regards
Croc
|
|
|
|
|
CrocodileBuck wrote: Hi Nathan & Mike,
many thx for your answers, I solved the problem like this :
CComBSTR (LPCWSTR(arrRelease[k].c_str()));
Bad move. The LPCWSTR cast causes the pointer to be interpreted as a pointer to unicode characters, but it doesn't actually convert the ansi characters to unicode. You can convert the actual string using MultibyteToWideChar, but it is fairly complicated to use.
Nathan
|
|
|
|
|
Does anyone know how to solve the error LNK1152?
|
|
|
|
|
If given enough information probably yes. But there it is quite doubtfull.
Anyway, I saw your other post about "linking" several projects and I think you don't understand what you are doing.
So please explain your problem in an understanble way and define exactly what you mean by "linking" the two projects.
If you would like to execute another executable (so, a stand-alone program which is not part of your application), then the solution that were already given are the way to go (ShellExecute or CreateProcess).
If you simply want to add existing source files into your project and call some functions from them, then you should explain what you did more in details. This two approaches are completely different so be sure upfront that the way you are choosing is the correct one.
|
|
|
|
|
I paint a Ellipse on a bitmap,but when I move the window the ellipse will disappear.
My application is dialog based,so I havn't use "OnDraw" to paint.
Who can help me..thank you...
|
|
|
|
|
Do u'r drawings in OnPaint ().
Come online at:-
jubinc@skype
|
|
|
|
|
Don Box ,hi.
my applition is fivechess,so I want when I pull mouseLButtonDown that the ellispe will appear the bitmap.
if my drawings in Onpaint(),I needn't pull mouse there will a ellispe appear the bitmap.
Can you answer me again..?
Thank you..
|
|
|
|
|
Plz write in full detail.
Come online at:-
jubinc@skype
|
|
|
|