|
Call string::size() to get the length of the string.
|
|
|
|
|
I just have a simple function to get the bounding rectangle. green color is without using the pen, red is with the pen. Why is the red rectangle so much bigger? even the green is not exactly correct.
http://img246.imageshack.us/my.php?image=testqq1.jpg[^]
void Test::DrawPreview(HDC hdc)
{
Graphics graphics(hdc);
Pen blackPen(Color(255, 0, 0, 0), 1);
Pen yellowPen(Color(255, 255, 255, 0), 20);
Pen redPen(Color(255, 255, 0, 0), 1);
Pen greenPen(Color(255, 0, 255, 0), 1);
Point pts[] = {Point(120,120),
Point(200,130),
Point(150,200),
Point(130,180)};
// Create a path that has one curve and one ellipse.
GraphicsPath path;
path.AddClosedCurve(pts, 4);
path.AddEllipse(120, 220, 100, 40);
// Draw the path with a thick yellow pen and a thin black pen.
graphics.DrawPath(&yellowPen, &path);
graphics.DrawPath(&blackPen, &path);
// Get the path's bounding rectangle.
RectF rect;
RectF rect2;
path.GetBounds(&rect, NULL, &yellowPen);
path.GetBounds(&rect2);
graphics.DrawRectangle(&redPen, rect);
graphics.DrawRectangle(&greenPen, rect2);
}
|
|
|
|
|
How much larger is the red rect?
I didn't test your code, but with the yellow pen's width at 20 the red rect should be a little
bigger.
|
|
|
|
|
I tried your code. Looks like they allow PLENTY of room for the thicker pen!
*Edit* Looks like a bug to me
|
|
|
|
|
CString m_strSpeech;
m_strSpeech = "Hi Have A Nice Day";
ISpVoice * pVoice = NULL;
if (FAILED(CoInitialize(NULL)))
{
AfxMessageBox("Error to intiliaze COM");
return;
}
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL,
CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
hr = pVoice->Speak(m_strSpeech.AllocSysString(), 0, 0);
pVoice->Release();
pVoice = NULL;
}
CoUninitialize();
this above i used to play a text "Hi Have A Nice Day". Output is ok. i done this dialog no other code. I placed this one in ok Button.
while running the application the memory size is 1,6XX k. I press ok button play starts. mean while memory goes to 5,XXX and return back to 3,XXX.
why it can't come back. what's the problem. any one help me out.
thanks in advance!
Have A Nice Day!
Murali.M
|
|
|
|
|
I dont know for sure, but my guess is you need to remember the result of AllocSysString() and call SysFreeString() on it.
Luc Pattyn
|
|
|
|
|
CoInitialize() involves loading up COM and setting up various things like data structures and windows for the STA. Some of that data is process-wide and won't be freed when you call CoUninit. So really, don't worry about it
Last modified: 5hrs 34mins after originally posted --
|
|
|
|
|
thanks for your reply.
but i called CoUninitialize();
Have A Nice Day!
Murali.M
|
|
|
|
|
There is already one memory leak indicated by Luc.
You can modify your code like this,
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL,
CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
BSTR bsSpeech = m_strSpeech.AllocSysString();
hr = pVoice->Speak(bsSpeech, 0, 0);
SysFreeString(bsSpeech);
pVoice->Release();
}
|
|
|
|
|
thanks prasad. I try with this one. but not. my problem of memory consumption if 1,XXX K. This is not due to String allocation.
Have A Nice Day!
Murali.M
|
|
|
|
|
in c++ we can used the cin and cout , plz tel me in VC++ what function we used.
a lot of thank 's
-- modified at 5:39 Saturday 16th December, 2006
-- modified at 5:41 Saturday 16th December, 2006
naveen padiyar
|
|
|
|
|
- On console apps keep using cin/cout (even printf/scanf are a valid option).
- On windowed apps you have to use any of the text drawing methods of MFC
(e.g. CDC::TextOut, CDC::DrawText, ... or the original GDI calls TextOut, DrawText, ... ). For fancy effects, give a look at GDI+.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
where do you need it? It differs according to your need. Btw, VC++ is not something totally different from C++. C++ is still inside VC++ . If you are making a console application using VC++, you can still use "cin,cout" if MFC (or SDK), and if you want(most probably) to get from a textbox (CEdit) ::GetWindowText(), ::SetWindowText()
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
To disable a menu item in an sdi app i tried
(pFrame->GetMenu)->EnableMenuItem(IDC_MY_ID,MF_GRAYED);
but it did not work. How to do this?
Thanks in advance.
KIRAN PINJARLA
|
|
|
|
|
Hi Kiran,
try this :-
pFrame->GetMenu)->EnableMenuItem(IDC_MY_ID,MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
Regards,
vinsankar
|
|
|
|
|
Thank you.
But it did not work.
KIRAN PINJARLA
|
|
|
|
|
Then try to post more info about...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
You can use the following Macro ,
ON_UPDATE_COMMAND_UI( MENU_ID, memberFxn ) and in the definition
void memberFxn( CCmdUI* pCmdUI )
{
pCmdUI->Enable(false);
}
Regards,
vinsankar
|
|
|
|
|
|
hi
ok as guys are not able to understand what i am asking i will try to be specific
run spy++ and in windows section(ctrl+w) you see different windows handel values,
i want to use one of those value in my program and send a message to that particular window, defined by the window handel id,
exm:
in spy++ one appliction window has id 2222
i want to send message to 2222 window handel id
how to do tht,
as far i know u simply cant do like this HWND h=2222;
my app
for suppose there is xyz window or application, i query for HWND in Spy++, it returns me 2222, i want to use tht value in my application to send a message to tht window,
SendMessage( hwnd a, ...,...,...);
how to do hwnd a = 2222;
any idea or suggestion,
the basic doubt is how to use a handel value provided by spy++, if app does nt have a window or a hidden application or tray icon.
-- modified at 17:10 Sunday 17th December, 2006
|
|
|
|
|
swarup wrote: it returns me 2222, i want to use tht value in my application to send a message to tht window,
SendMessage( hwnd a, ...,...,...);
how to do hwnd a = 2222;
You can use this value as handle in SendMessage .
swarup wrote: if app does nt have a window or a hidden application or tray icon.
How would you get handle , if there is no window ?
|
|
|
|
|
Actually he can, if the app has the window hidden.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
why cant you , if you dont see a window tht does mean one ap does nt hv a window, anyway tht is not my problem what is ma problem is i knw from external program the hwnd value and i want to use tht value in ma application to send message to tht hwnd value, any idea
|
|
|
|
|
As said earlier. You can use SendMessage . if you have handle to that window. No matter if its hidden.
swarup wrote: knw from external program the hwnd value and i want to use tht value in ma application to send message to tht hwnd value, any idea
Then what problem?
|
|
|
|
|
i know i have to use sendmessage, but how to code it in my application, now dont tell me use this way SendMessage(2222, "any message","any message","any message");
how to use a hwnd value returned or shown by spy++, in the VC++ program programaticaly
|
|
|
|
|