|
thanx for replying;
Actually, the pen of the dc is already set up, i have just not included it in the my previous posting.
I am sure the drawings are painted because i can see them for a while and then they disappear
Now i tried getting rid of "if(drawings == TRUE)". And it is still not working
any more suggestions
llp00na
-- modified at 13:27 Tuesday 21st February, 2006
|
|
|
|
|
Drawing directly on a dialog box is usually never a good idea.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
thanx for replying;
Do you have any other suggestion ?
llp00na
|
|
|
|
|
Put some other control (e.g., static) on the dialog and draw on it instead.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
I totally agree with you David.
Now I have added an ActiveX Control (Microsoft Web Browser). And I am trying to draw on it but the shapes still disappear.
llp00na
|
|
|
|
|
There's nothing wrong with drawing directly on a dialog box - I do it all the time. Why do you think it isn't a good idea?
Steve
|
|
|
|
|
Why do you think a dialog box is provided. It acts as a container for other controls.
Besides it is always messy to do drawing directly on a dialog box. As David said drawing on static is much better. As you said nothing is wrong with it but is bad and messy. Besides when you draw on a static it is much easier to maintain the picture.
Owner drawn
Jesus Loves
|
|
|
|
|
Stephen Hewitt wrote: Why do you think it isn't a good idea?
The problem with drawing directly on the dialog is that anything at all could make the
image go away (e.g., an email alert popping up over it). Another problem with is that the dialog thinks it controls the background and painting of the dialog; you are asking for trouble by trying to override this. For someone who understands all of the ramifications of doing this, you can do all the right workarounds. But it still seems risky to draw/paint directly on a dialog.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
DavidCrow wrote: anything at all could make the image go away (e.g., an email alert popping up over it).
This isn't the case. Dialogs recieve WM_PAINT messages just like any other window when their client area has become invalid. If you put your painting code in the WM_PAINT handler (just as you would for any other window) every things works fine and as expected.
I do understand the ramifications - there are none. I do accept the argument that in most cases it is probably cleaner to do the drawing in a control. That said, for doing things like putting a background on a dialog putting the code in the WM_PAINT handler is the way to go.
Steve
|
|
|
|
|
Now i have partially solved the problem. what i did was removing:
if(drawings == TRUE){
drawShapes(dc);
}
from the if clause and including in the else clause.
Now i can see the drawings. my only problem is that the drawings disappear if the dialog box is minimized or if another window is overlaid on top of the it.
Any suggestions are very welcome.
void CTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon= GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
if(drawings == TRUE){
drawShapes(dc);
}
CDialog::OnPaint();
}
}
llp00na
|
|
|
|
|
|
Well I am not calling OnPaint() at all. On the contrary, OnPaint() calls the method which does the drawings for me. But these drawings disappear after minimizing or ovelaying the dialog box.
llp00na
|
|
|
|
|
|
please send me a simlple smtp mail sending project or program
now i am sending with the help of Outlook exp config using vc++
i need a code which is not depand on any extra tools
From
Renuchandran.K
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
renuchandran wrote: now i am sending with the help of Outlook exp config using vc++i need a code which is not depand on any extra tools
http://www.codeproject.com/internet/csmtpconn.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello.
Can any one help. I am writting a application which has a dialog which is used to display a database. I have derived the dialog from the from the base class
containing the data. I can access the data as exspected. The problem is I need to call the dialog from the base class. Is this possible using this method.
Or do I have setup a pointer to the dialog in the base class and copy all the data to dialog befor I call it as I have done in the past.
Thanks for any help
Desmond Mardle
|
|
|
|
|
Your dialog class is derived from CDialog , and your record set class is derived from CRecordset . Is that correct?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
Thanks For your replay. I have sorted it. I am not using CRecordset. I am using my own class.
I have set a pointer from my data class to the dialog. I transfer the data. Then call the dialog. I'm not using my data class as the base class of the dialog any more.
Regards
Desmond Mardle
|
|
|
|
|
Desmond Mardle wrote: I am not using CRecordset. I am using my own class.
Which connects to your data source how?
Desmond Mardle wrote: I'm not using my data class as the base class of the dialog any more.
That's good because it probably never should have been.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
In the general sense, you would not want to do what you are saying (access a derived class from a base class). In fact when you say
Desmond Mardle wrote: Or do I have setup a pointer to the dialog in the base class and copy all the data to dialog befor I call it as I have done in the past.
it appears that you do not need need to access the derived class from the base class, but rather you are having some other issue.
All of that being said, I am not sure that I grasp the problem you are describing. But from the information you have provided, I think this article may be of assistance. It describes separation of the database and the view of the database in the context of the model-view-controller design pattern. http://www.codeproject.com/gen/design/MVC1.asp[^]
|
|
|
|
|
hi. im new to vc++ and i need some help. im tryin to break a string into tokens, but the problem is that this loops runs one time more then it is supposed to .e.g. for a string with 4 tokens it runs 5 times on the 5th run it displays an empty message box and then i get "debug assertion failed" and something about Expression iStart>=0.
if i remove the while it runs once but without the error.
//m_LineList is a CStringList
POSITION pos = m_LineList.GetHeadPosition() ;
int strpos = 0;
CString str;
str = m_LineList.GetNext( pos );
CString temp="";
while ( str != '\0')
{
temp = str.Tokenize( "," , strpos );
MessageBox(temp);
};
|
|
|
|
|
Deviantizh wrote: while ( str != '\0')
What's this? I seriously doubt you'll be able to successfully make this comparison. Use the IsEmpty() method instead.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
I don't think the original string is modified by Tokenize, thus checking it will not work. You could check the return for an empty string, but you could have empty tokens. Off the top of my head, I'd suggest testing strpos (this solution was not tested; it's just a quick guess):
CString temp;<br />
while (strpos < str.GetLength())<br />
{<br />
temp = str.Tokenize(",", strpos);<br />
MessageBox(temp);<br />
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
-- modified at 11:49 Tuesday 21st February, 2006
|
|
|
|
|
thanx ill try that out
|
|
|
|