|
|
OK, I've never used GDI+, but in standard GDI, the font is created with the rotation factor. Check that to see whether the value of 900 for Orientation needs to be changed to 2700 where it is constructued, or visa versa.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thanks for the reply. The computer is too heavy for me to turn it upside down.
I tried the following, but for some reason, I only see the ellipse, but no text 'HAPPY DAY!', am I missing something here?
Pen pen(Color(255, 0, 0, 255));
PointF origin(x, y);
WCHAR string[256];
x = 200;
y = 200;
graphics->RotateTransform(90.0f);
graphics->TranslateTransform(x, y, MatrixOrderAppend);
wcscpy(string, L"HAPPY DAY!");
graphics->DrawString(string, -1, &myFont, origin,
&stringFormat, &blackBrush);
graphics->DrawEllipse(&pen, 0, 0, 200, 80);
Thanks!
|
|
|
|
|
|
I am drawing both the text and ellipse on an image that I uploaded using graphics.DrawImage().
I agree that this method shall work because I can see the ellipse, but not the text... weird...
Anyways, thank you again for pointing me to the right direction.
|
|
|
|
|
Perhaps You are drawing the ellipse over the text ?
try it in this order
graphics->DrawEllipse(&pen, 0, 0, 200, 80);
graphics->DrawString(string, -1, &myFont, origin, &stringFormat, &blackBrush);
|
|
|
|
|
Thanks. It doesn't work either.
Anybody ever tried to rotate a line of text before using GDI+?
|
|
|
|
|
|
Hey, you are the best! Thank you so much, Daniel. My code is finally working!!!!!!
I shall call TranslateTransform() first before calling RotateTransform().
Still, don't know why this doesn't make a difference when drawing the ellipse though... but hey, who cares now... hee hee...
|
|
|
|
|
It is my first time here asking for help, and I had a very happy experience. All you guys are great! Thank you all.
Best wishes to you all.
|
|
|
|
|
I don't know which forum to post this, but since I'm a C++ developer and this forum is the most frequented, I post it here.
I have put the following lines to make mc generate a message table for 3 locales:
;
LanguageNames=(English=0x409:MSG0409)
;
LanguageNames=(EnglishCA=0x1009:MSG1009)
;
LanguageNames=(FrenchCA=0xC0C:MSG0C0C)
My problem is that the MS Message compiler (mc) don't output accented characters correctly. Here is an example entry:
MessageId=100
Severity=Success
Facility=Itf
SymbolicName=MSG_APPSTART
Language=English
Service has started successfully.
.
Language=EnglishCA
Service has started successfully.
.
Language=FrenchCA
Le service a démarré avec succès.
.
When I want to get the message using FormatMessage , I get the following when specifying 0x0c0c as the language:
Le service a dTmarrT avec succFs.
As one can see, the accented characters are messed up. Here is a snippet of the MSG0C0C.bin file outputted by mc:
L L e s e r v i c e a d ˜m a r r ˜ a v e c s u c c ¦s
letters above have a space between them, except for the one where should have been the accented characters.
I can't find anything in MSDN about message compiler an internationalization that explains how to make mc recognize foreign chars correctly, or how to put them in the .mc file.
Tx for your help.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I got some modeless dialogs.
I set the tab order for them.
But:
Tab does not work. Everytime I hit at the Tab-Key a sound is heared and nothing else happens.
If I call the same dialog modal the tab works as usual.
Can anyone give me a hint who to aktivate the tab functionality?
|
|
|
|
|
In your message loop you need to make a call to IsDialogMessage if the HWND is your Dialog. If your window is not a dialog, then call Translate and DispatchMessage like normal.
If your dialog message is processed by IsDialogMessage, then you do not need to Dispatch it because this function does that.
Coincidentally if you have a function that is not a dialog, but does have a set of controls that you would like to tab through, you can dispatch your messages to that window with IsDialogMessage as well.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I have a multi-threaded application and have the following problem, which I am not sure how to solve.
I have 2 threads running. The 1 thread I would like to SUSPEND or place in SLEEP mode. This is so that I can give the processor a chance to do other things. This thread I only need to work every half an hour.
If I place the thread in Sleep, I cannot get it out of that mode until the Sleep ends.
Also if I should need to kill the thread and it is in sleep, I am going to have to wait a half an hour ( at the most) before the thread dies.
How do I manage this?
Thanks in advance for any ideas.
Regards
Rui
|
|
|
|
|
Ruca wrote:
If I place the thread in Sleep, I cannot get it out of that mode until the Sleep ends.
You shouldn't be using Sleep for this. You have three choices:
1. The most complicated, but more elegant and powerful: Use WaitForSingleObject and use an event object with the timeout value being the Sleep period
2. I do not recommend, but easier: Use SuspendThread from the thread 2 for suspending thread 1. Then set some bool and ResumeThread for resuming the execution.
3. The most horrible: If the program is terminating, you can use TerminateThread
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
You could also use a timer catching the WM_TIMER message. To make the trade terminate, send it the WM_QUIT message, which it will also catch.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
|
The suggestion is NOT to use Sleep, because it is blocking, so you are unable to tell the thread to cleanup and quit.
The use of either WaitForSingleObject with a 1800000 milliseconds time-out or SetTimer and catching the WM_TIMER and WM_QUIT messages is better.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
A console application in debug mode, using STL:
#include "stdafx.h"
#include <iostream.h>
#include <vector>
using namespace std;
typedef vector<int> intvector;
struct S
{
intvector v;
};
int main(int argc, char* argv[])
{
S *pS=new S;
intvector::iterator it;
cout<<"before crush"<<endl; <code>
for (it=pS->v.begin(); it!=pS->v.
end(); it++);
delete pS;
return 0;
}
If i run it step by step it will crush on the attempt of executing the for line. If i modify it like this:
for (it=pS->v.begin(); it!=pS->v.end(); it++); and repeat the step by step procedure, everything will be ok.
Could you tell me what is the difference between the two variants?
This message is related to the one i wrote yesterday. I thank everyone who sent me answers. I still think it was not about memory...
rechi
|
|
|
|
|
Hmmm... Don't know if it helps, but I think this is a compiler bug.
1. In VS.NET I compile it and run it fine
2. In VC++ 6.0 the whole MSDEV crashes and exit! I never saw this!
3. I've changed your code to this, for spotting the error:
int main(int argc, char* argv[])
{
S *pS=new S;
intvector::iterator it = pS->v.begin();
cout<<"before crush"<<endl;
while (it!=pS->v.end())
it++;
delete pS;
return 0;
}
And it works fine, even on VC 6.0!
I'm using SP5 of VS 6.0.
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
Daniel Turini wrote:
I think this is a compiler bug
That's the point (on VC 6.0). Unfortunately, it took me a day to find out.
Thanx for your suggestions!
rechi
|
|
|
|
|
I've been wrestling with this one for four days now. Time to ask the experts...
I'm trying to run an application as Administrator... My app is supposed to have the functionality of Linux' SU...
Im trying to do this with CreateProcessAsUser, which spits out error 1314, meaning something like "missing client privilige."
I believe those privileges refer to those of the calling process, whose lacking SE_ASSIGNPRIMARYTOKEN_NAME privilege. When I try to assign that one, using a method that uses AdjustTokenPrivileges, that one spits out error 1300, "haven't assigned your privilege". Errors 1300 and 1314 are the only errors spit out.Some other notes: The assure method is a debug routine, it does not interfere anywhere... That's not really my admin password, mine is trice as long and quadruple complex Besides SetPrivilege and CreateProcessAsUser no functions called return an error...
What's going wrong? What should I change? Comments, suggestions, questions and URL's are welcome... BTW, I've got working SU code using the largely undocumented CreateProcessWithLogon fucntion, but this one doesn't work in NT 4.0, which is where this code should work...
The code:
<br />
STARTUPINFO *si = (STARTUPINFO *)allocm(sizeof(STARTUPINFO));<br />
PROCESS_INFORMATION *pi = (PROCESS_INFORMATION *)allocm(sizeof(PROCESS_INFORMATION));<br />
si->cb = sizeof(STARTUPINFO);<br />
<br />
LogonUser(<br />
"Administrator", <br />
".",<br />
"09nnj!ty&56t",<br />
LOGON32_LOGON_INTERACTIVE,<br />
LOGON32_PROVIDER_DEFAULT,<br />
&hToken <br />
);<br />
assure("LogonUser");<br />
<br />
OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken2);<br />
assure("OpenProcessToken");<br />
<br />
DuplicateTokenEx(<br />
hToken,<br />
TOKEN_ALL_ACCESS,<br />
NULL,<br />
SecurityImpersonation,<br />
TokenPrimary,<br />
&hToken3<br />
);<br />
assure("DuplicateToken");<br />
<br />
ImpersonateLoggedOnUser(hToken3);<br />
assure("ImpersonateLoggedOnUser");<br />
<br />
SetPrivilege(hToken2,SE_INCREASE_QUOTA_NAME,true);<br />
assure(SE_INCREASE_QUOTA_NAME);<br />
<br />
SetPrivilege(hToken2,SE_ASSIGNPRIMARYTOKEN_NAME,true);<br />
assure(SE_ASSIGNPRIMARYTOKEN_NAME);<br />
<br />
CreateProcessAsUser(<br />
hToken3,<br />
NULL,<br />
"Taskmgr",<br />
NULL,<br />
NULL,<br />
0,<br />
CREATE_DEFAULT_ERROR_MODE |<br />
NORMAL_PRIORITY_CLASS,<br />
NULL,<br />
NULL,<br />
si,<br />
pi<br />
);<br />
assure("CreateProcessAsUser");<br />
Regards,
Georg Haan (.NL)
|
|
|
|
|
|
Thanks for your comment, but there must be a way to use impersonation functions without upgrading to a (local) service? ImpersonateLoggedOnUser works fine by the way, and the RCMD example Mr. Saurwein refers (see next message) to doesn't upgrade itself to service neiter...
Regards,
Georg Haan(.NL)
|
|
|
|
|
The RCMD sample from the SDK shows how to do it:
if(!OpenThreadToken(
GetCurrentThread(),
TOKEN_DUPLICATE,
TRUE,
&hImpersonationToken
))
{
DisplayLastError("OpenThreadToken");
goto cleanup;
}
if(!DuplicateTokenEx(
hImpersonationToken,
TOKEN_IMPERSONATE | TOKEN_READ |
TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE,
NULL,
SecurityImpersonation,
TokenPrimary,
&hPrimaryToken
))
{
DisplayLastError("DuplicateTokenEx");
goto cleanup;
}
RevertToSelf();
CloseHandle(hImpersonationToken);
if(!CreateProcessAsUser(
hPrimaryToken,
NULL,
COMMANDLINE,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi
))
{
DisplayLastError("CreateProcessAsUser");
goto cleanup;
}
Take a look at the flags passed to DuplicateTokenEx() and OpenThreadToken();
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|