|
Thank you for your reply which I didn't see until this morning. Usually it sends me mail when someone replies and since I received no mail I didn't know that you had replied.
I came up with another solution, where basically I make a static text box to receive the information and I invalidate it whenever I need to update the information. Unfortunately I can't use the WM_INITDIALOG because the user can change the study.
So, I invalidate the static box when I need a change, then validate inside WM_PAINT (which it nicely gives me as a message). Once it is valid, I write on top of the static box with the color and text size which I need. So far, it seems to be doing the job.
Here is the code:
<br />
void CMyToolbar::SetPatInfo(void)<br />
{<br />
int oldColor, bkgColor, oldMode, fontSize = 160;<br />
int i, j;<br />
CFont hFont, *hOldFont;<br />
CBrush br1;<br />
CWnd *wnd1;<br />
CSize sz1, sz2;<br />
CRect rc1;<br />
CString textOut[4];<br />
CDC *pDC;<br />
CCardiacDoc *pDoc;<br />
CCardiacView *vw = CCardiacView::GetView();<br />
pDoc = vw->GetDocument();<br />
textOut[0] = pDoc->m_patName;<br />
if( textOut[0].IsEmpty()) <br />
return;<br />
textOut[1] = pDoc->m_patID;<br />
textOut[2] = pDoc->m_imageData[0].m_acqDateTime.Format("%d-%b-%Y");<br />
textOut[3] = pDoc->m_styName;<br />
if( vw->m_masterFlg <= CCardiacView::VW_CARDIAC_DISP2)<br />
textOut[3] = "Myocardial Perfusion";<br />
<br />
wnd1 = GetDlgItem(IDC_PATINFO);<br />
pDC = wnd1->GetDC();<br />
bkgColor = pDC->GetBkColor();<br />
sz1 = 0;<br />
for( i=j=0; i< 4; i++) {<br />
sz2 = pDC->GetTextExtent(textOut[i]);<br />
if( sz2.cx > sz1.cx) {<br />
sz1 = sz2;<br />
j = i;
}<br />
}<br />
<br />
oldColor = pDC->SetTextColor( RGB(255,0,0));<br />
oldMode = pDC->SetBkMode( TRANSPARENT);<br />
wnd1->GetClientRect(&rc1);<br />
wnd1->ValidateRect(rc1);<br />
sz1.cx = rc1.right;<br />
sz1.cy = rc1.bottom;<br />
br1.CreateSolidBrush(bkgColor);<br />
pDC->FillRect(rc1, &br1);<br />
while( fontSize > 80) {<br />
hFont.CreatePointFont( fontSize, "Ariel", pDC);<br />
hOldFont = pDC->SelectObject( &hFont);<br />
sz2 = pDC->GetTextExtent(textOut[j]);
if( sz2.cx <= sz1.cx) break;
pDC->SelectObject( hOldFont);<br />
DeleteObject( hFont);<br />
hFont.Detach();<br />
fontSize -= 20;
}<br />
for( i=j=0; i<4; i++) {<br />
if( j+sz2.cy > sz1.cy) break;
pDC->TextOut(0,j,textOut[i]);<br />
j += sz2.cy;<br />
}<br />
pDC->SelectObject( hOldFont);<br />
DeleteObject( hFont);<br />
pDC->SetTextColor( oldColor);<br />
pDC->SetBkMode( oldMode);<br />
ReleaseDC(pDC);<br />
}<br />
<br />
void CMyToolbar::OnPaint()<br />
{<br />
CPaintDC dc(this);
SetPatInfo();<br />
}<br />
<br />
void CMyToolbar::Invalidate(void)<br />
{<br />
CWnd *wnd1;<br />
CRect rc1;<br />
wnd1 = GetDlgItem(IDC_PATINFO);<br />
wnd1->GetClientRect(&rc1);<br />
wnd1->InvalidateRect(rc1,0);<br />
}<br />
|
|
|
|
|
You have chosen the harder way, but that's it... your choice.
However, here are some "first look" remarks:
<list> I put SetFont in WM_INITDIALOG message handler only as an example; you can put it also in any oter place, then call Invalidate() as well.
No need to write your own CMyToolbar::Invalidate function, as long as you can directly call Invalidate for the desired control.
GetDlgItem(IDC_PATINFO)->Invalidate();
As long as you have not handled WM_PAINT in the static control, but you draw text in it from another place, for sure you'll have troubles after another window will overlap; just test it and see if I'm right.
Ovidiu
|
|
|
|
|
Again I didn't receive any email to know that you had replied. In fact when I wrote my reply to you, I was convinced that you would never see it since it was so old. I just wrote the reply for the sake of completeness.
Not only were you right, you are ABSOLUTELY right in your analysis that I will have troubles since I don't handle WM_PAINT for the static control. Since I thought there was zero chance of anybody seeing this message, I opened a new message. I described exactly what you said would happen.
If I continue on with what I started then I need to figure out how to handle the WM_PAINT for the static control. So far, I can't find any way to do this. The static control has no messages which I can override. Since you told me that I need to handle this message (very correctly so!!!), could you please tell me how I get my hands onto it?
In parallel I will look into your original solution. Again, I didn't do it by your suggestion because I didn't know you answered so I had to figure out something for myself - and I chose the hard way.
I wasn't really serious about the WM_INITDIALOG, just my reply was "dead" in any case. All I needed was something which I could call more than once and where I could set the font size according to the length of the patient name (or the new patient name for the new study).
Thanks for all your comments. They are VERY helpfull.
Ilan
|
|
|
|
|
I decided that your method was SO much nicer that I would throw out what I did and use your method. Just for general education if you happen to know how I would capture the WM_PAINT for the static control, it would be nice to know. In any case, I will no longer pursue it so it is of minor importance.
I threw out the WM_PAINT message, threw out the invalidateRect and I just call it once. It turns out that I need an initialization routine for setting up the radio buttons depending upon the study type. It was most natural to just call my routine from there (like your WM_INITDIALOG suggestion).
My code is simpler now:
void CMyToolbar::SetPatInfo(void)
{
// font size can start at 16 if 3 lines are permitted.
// start with font size = 12 for 4 lines.
int fontSize = 120;
int i, j;
CFont hFont, *hOldFont;
CWnd *wnd1;
CSize sz1, sz2;
CRect rc1;
CString textOut[4];
CDC *pDC;
CCardiacDoc *pDoc;
CCardiacView *vw = CCardiacView::GetView();
pDoc = vw->GetDocument();
textOut[0] = pDoc->m_patName;
if( textOut[0].IsEmpty()) return;
textOut[1] = pDoc->m_patID;
textOut[2] = pDoc->m_imageData[0].m_acqDateTime.Format("%d-%b-%Y");
textOut[3] = pDoc->m_styName;
if( vw->m_masterFlg <= CCardiacView::VW_CARDIAC_DISP2)
textOut[3] = "Myocardial Perfusion";
wnd1 = GetDlgItem(IDC_PATINFO);
pDC = wnd1->GetDC();
sz1 = 0;
for( i=j=0; i< 4; i++) {
sz2 = pDC->GetTextExtent(textOut[i]);
if( sz2.cx > sz1.cx) {
sz1 = sz2;
j = i; // j will be the maximum string
}
}
wnd1->GetClientRect(&rc1);
wnd1->SetWindowText(textOut[0] + "\r\n" + textOut[1] +
"\r\n" + textOut[2] + "\r\n" + textOut[3]);
sz1.cx = rc1.right;
sz1.cy = rc1.bottom;
while( fontSize > 80) {
hFont.CreatePointFont( fontSize, "Ariel", pDC);
hOldFont = pDC->SelectObject( &hFont);
sz2 = pDC->GetTextExtent(textOut[j]); // the longest one
if( sz2.cx <= sz1.cx) break; // found a size
pDC->SelectObject( hOldFont);
DeleteObject( hFont);
hFont.Detach();
fontSize -= 20; // reduce font size by 2
}
wnd1->SetFont(&hFont);
hFont.Detach();
ReleaseDC(pDC);
}
I have a question about DeleteObject(hFont). Do I need it in my loop if I use hFont.Detach()? I noticed you didn't use it in your example, so I also didn't use it when I found the font I wanted. Will I add garbage if I change the patient to a new patient?
Thanks again,
Ilan
|
|
|
|
|
double (*pf)(int);
double *pf(int);
I don't understand, how are they difference?
|
|
|
|
|
first is function pointer
second method is returning the double *
first is pointer to function whoes return type is double and argument type is int which refers in code segment
oter method have its return type of pointer of type double
second is same as above
|
|
|
|
|
double (*pf)(int);
this declares pf as a pointer fo a function which gets an int parameter, and returns a double.
such a variable can be used like this :
double Foo(int i) { return (double) i; }
double (*pf)(int);
pf = &Foo;
double d = pf(4);
double *pf(int);
this declares a function called pf getting an int parameter and returning a pointer to a double (double*).
you can use it like this :
double* pf(int);
double* pd = pf(4);
double twice = (*pd) * 2;
|
|
|
|
|
i want to block the e-mail attachment in internet explorer. whenever user attaches or trying to attach something with the mail it block the activity. i need the code to block the gmail attachment using VC++.
any one knows please reply thanks
|
|
|
|
|
Hi Folks,
Want to convert, system current time (local time) to GMT and vice versa preferable using windows api or else MFC. Any code samples available please?
Thanks
C++beginer
|
|
|
|
|
See Here and here
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
PrabhuDev wrote: I have a cscrollview in which i am filling the whole area with some color
Where are you doing that ? If it is outside of the OnPaint (or OnDraw, I don't remember) function, then of course everything will be lost when the window is redrawn. Put all your drawing code ALWAYS in this function.
|
|
|
|
|
Hello. I am new to Visual C++.
I am doing a computer control software to control a receiver and i need to capture the signal and plot it out.
May I know which MFC class library is suitable to do graph plotting?? As far as i know there are MsChart control and CGraph class libray...what are the differences in these two?? Are both applicable in Visual C++??
I tried to find the download source for both of these class libray ..Is there any download link for all the MFC class library?? thanks in advance.
|
|
|
|
|
this may or may not be of help, but did you have a look at This[^] control ?
|
|
|
|
|
Wow, it's becoming popular
|
|
|
|
|
Cedric Moonen wrote: Wow, it's becoming popular
come on, we both know i knew it 'til its birth...
|
|
|
|
|
Cedric Moonen is right I was also searching for this library couple of week back.....
Regards,
-Dinesh
|
|
|
|
|
you can find it in his signature, in any of his posts...
|
|
|
|
|
toxcct wrote: you can find it in his signature, in any of his posts...
Not this one
Cédric Moonen
Software developer
|
|
|
|
|
I also redirect people on your charting control, Cedric. It is really good.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Hi All,
MapViewOfFile fails with "Not enough storage is available to process this command". Can any one explain the reason for the above message.
Thanks in Advance
Suraj
Suraj Gupta
|
|
|
|
|
This description is from MSDN , have you tried this,
Error Message:
Not enough storage is available to process this command.
User Action:
Do one of the following, then retry the command:
(1) reduce the number of running programs;
(2) remove unwanted files from the disk the paging file is on and restart the system;
(3) check the paging file disk for an I/O error; or
(4) install additional memory in your system.
|
|
|
|
|
I was facing the similar problem.Is the MapViewOfFile fails first time itself?.If its not then u have to UnMap the Previous view then u have to Map it once again.For this u can use the same handle ,which u got from CreateFileMapping.
regards
Vairavan
|
|
|
|
|
In my application i want to determine that is system is going into Stand By
mode. If this is the case then i want to set one registry flag .
How can i detremine that system is going into Stand By mode
or it is just awakened from Stand By mode .
|
|
|
|
|
You should capture WM_POWERBROADCAST message[^].
Also look at this[^]
I hope it helps,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
but my application is ATL DLL which construct a toolbar to IE window.
how could we handle this message. will my toolbar windoa could receive that message
or IE will receive.
please tell me how to handle that message
|
|
|
|