|
Can't you just read in the various .doc files to a single variable?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to display a unicode string in my CStatic(label) control. But I don't want to bulit my application unicode(add _UNICODE/UNICODE in preprocessor).
Is there any solution?
|
|
|
|
|
You can never display UNICODE text in a non-unicode application. Therefore, your only solution would be to display it as an image.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
|
This is not the case. Take the following example ANSI application:
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MessageBoxW(NULL, L"This string is UNICODE!", L"Unicode", MB_OK);
return 0;
}
In this case all the UNICODE define (and related ones) does is map the macro MessageBox to either the MessageBoxA function (non-UNICODE) or the MessageBoxW function (UNICODE). By using MessageBoxW we get the UNICODE version regardless the the setting.
Steve
|
|
|
|
|
Thanks for pointing it out, I think I've been avoiding ANSI builds for all good reasons. I've never tried what you've suggested.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I think you could use code similar to the following:
::SetWindowTextW(m_Static.m_hWnd, L"Unicode text here");
Where m_Static is your static control.
this is this.
|
|
|
|
|
Yeah, I have tried that. But what it displayed only "????????????"
So I think the only way is building it in unicode
|
|
|
|
|
It worked perfectly when I tried it just then.
Also, you may want to investigate the CCM_SETUNICODEFORMAT message.
Steve
|
|
|
|
|
Convert the Unicode text to ansi text.
If this is not possible than you need a Unicode application.
Greetings from Germany
|
|
|
|
|
Hi,in my coding i have this FOR lop in OnDraw(),i have to calculate Average Value for like 2mins.
THis is my function..I use While Loop..But the control it does not exit form the loop.The coding get hanged at one time.I dont know why it occurs.When debugging it continously running(i think the fucntion call is in OnDraw())..
The value that i have to calculate is not one time value.Its continously changing value i have to calculate the average for first 2 mins and 1 hour like that.Thats why i have that function in OnDraw().I dont know where the mistake is.Pls help me out
/////
for(int i=0;i<4;i++)
{
DrawAvgValues(pScreenDC,i,iGroupIndex[i]);
}
/////
void CHourAvgView::DrawAvgValues(CDC *pMemDc,int pos, int INDEX)
{
float TotalPV =0.00;
float AvgPV = 0.00;
float PV;
int nMinute = (CTime::GetCurrentTime ()).GetMinute();
int nHour = (CTime::GetCurrentTime ()).GetHour();
int Time = nMinute+ (nHour*60);
int TtlTime = Time+2;
SLiveTagData oLiveTagData;
CTagBase *pTageBase;
while(Time<=TtlTime)
{
int nowMin = (CTime::GetCurrentTime ()).GetMinute();
int nowHour = (CTime::GetCurrentTime ()).GetHour();
int nowTime = nowMin+(nowHour*60);
if(nowTime ==Time)
{
POSITION position= goLiveList.FindIndex(INDEX);
if(position)
{
pTageBase = (CTagBase*)goLiveList.GetAt(position);
switch(pTageBase->GetTagType())
{
case CONTROLLER:
{
PV = oLiveTagData.PV;
TotalPV = TotalPV+PV;
break;
}
case INDICATOR:
{
PV = oLiveTagData.PV;
TotalPV = TotalPV+PV;
break;
}
default:
break;
}
}
Time=Time+1;
}
}
AvgPV = TotalPV/2;
int spos = ESimSetDM.dmPelsWidth/10;
x = (spos) * (pos +1);
y= (ESimSetDM.dmPelsHeight/2)+200;
char Avg[10];
sprintf(Avg, "%06.2f", AvgPV );
pScreenDC->SetTextColor(RGB(255,255,255));
pScreenDC->TextOut(x,y,Avg);
}
Anu
|
|
|
|
|
Why don't you use a timer instead ? It seems that you need to recalculate everything every minute. So, why do you make a busy loop ? First it will block in the function (preventing any window message to be processed, so your GUI will freeze) and second, you will consume CPU for nothing.
It would be much easier to start a timer (with a resolution of 1 minute) and to do your processing each time the timer fires.
|
|
|
|
|
Anu_Bala wrote: I dont know why it occurs.
Because Time is never greater than TtlTime .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
Sleep() function makes application sleep for specified time, but it blocks
the thread from processing anything.
How can i make application sleep for some time but still process the
messages? (e.g. equivalent to DoEvents in Visual Basic 6)
-----
Don't look back... See your stomach...
|
|
|
|
|
The sleep() lets sleep the thread where it's inside.
If you let sleep the WinThread, so all the windows will sleep too.
You need to use workerthreads, there in you can let sleep the threads as long as you want and
the windows will not be affected ...
Good luck
|
|
|
|
|
This is for UI thread:
void Delay(DWORD dwMsecs, BOOL bBlocking)
{
static BOOL bInDelay = FALSE;
if (bInDelay)
return;
bInDelay = TRUE;
DWORD dwStrtmsecs, dwCurmsecs;
MSG msg;
dwStrtmsecs = dwCurmsecs = ::GetCurrentTime();
do
{
if (!bBlocking)
{
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
::PostMessage(NULL, WM_QUIT, 0, 0L);
break;
}
else
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
dwCurmsecs = ::GetCurrentTime();
if (dwCurmsecs < dwStrtmsecs)
dwStrtmsecs = dwCurmsecs;
} while ((dwCurmsecs < (dwMsecs + dwStrtmsecs)));
bInDelay = FALSE;
}
|
|
|
|
|
Wow, thanks a lot... there's lot to learn out there, i guess...
|
|
|
|
|
How to communicate UI thread from worker thread?
Thanks in advance.
-- modified at 2:32 Wednesday 11th July, 2007
Have A Nice Day!
Murali.M
|
|
|
|
|
In general, the way it is done is simply pass a pointer to a class or structure to your thread function (you can pass an argument to this function when you start the thread). Then, you can simply change variables of this class/structure. But beware that they need to be protected with critical sections (to avoid that both threads access the same variable at the same time).
|
|
|
|
|
I think in many ways we don't specially cosider UI thread and worker thread in communication,we just use thread-communicate,you can use any mechanism of thread-communicate to transfer message from one thread to another,such as postmessage,sendmessage and so on.Of course what I referred above are all in one process.
|
|
|
|
|
To be able to use PostMessage and SendMessage, you need to have a window that will receive the messages. If you have a worker thread, generally you don't have a window, so this is not really an option.
|
|
|
|
|
The UI thread of course has a window procedure which the worker thread can post or send message to.
|
|
|
|
|
Of course. But it is not possible the other way around.
|
|
|
|
|
You can use events for symchronization you can also use Other synchronization objects like Critcal section.
You cant pass messages to worker thread.
If you wanna communicate from worker thread ->UI thread you can pass messages.
i Hope it is useful.
Thanks,
SandipG.
|
|
|
|
|
Also, check out PostThreadMessage()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|