|
Like Chris said you need to move that to the OnPaint message.
void CDialog::OnPaint(...)
{
if (m_bDisplayThankYou)
{
DrawThankYou(pDC);
}
}
|
|
|
|
|
OK,
Here is what I have tried now....
When the user clicks the button to trigger the drawing of text, I set a boolean value to true (RegKeyAvail).
And I also implemented this...
void CMartinPhDDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if(RegKeyAvail){
dc.SelectObject(&Welcome_font);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(COLORREF RGB(255,0,0));
dc.TextOut(30,30, "WELCOME");
Welcome_font.DeleteObject();
}
if (IsIconic())
{....
However, now the text isn't showing up at all. I know that the OnPaint is being called because I have set breakpoints in there and the functions walks through the dc.TextOut call, but does nothing......
|
|
|
|
|
goodoljosh1980 wrote: dc.SetTextColor(COLORREF RGB(255,0,0));
that compiles?
and, where do you create Welcome_font ?
Do the chickens have large talons?
|
|
|
|
|
Yeah, it compiles...
That is how I set the color of the text I want.
The Welcome_font is a member variable of the main dialog and is created in the
BOOL CMartinPhDDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetWindowRect(m_rect);
//Hide all diagrams to begin with
top_diagram.ShowWindow(0);
Intro_Stylus_Diagram.ShowWindow(0);
Welcome_font.CreateFont(90, 0, 0, 0,
FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DECORATIVE, "Times New Roman");
|
|
|
|
|
are you calling Invalidate() UpdateWindow() after you set the boolean?
By the way, don't delete the font object in the OnPaint method if it is not being recreated there. You are creating the font object once in your OnInitDialog but then deleting it everytime OnPaint runs.
|
|
|
|
|
I was calling Invalidate() in the OnPaint...
Once I moved it...the text showed up and it doesn't get erased!!!
THANKS TO EVERYONE!
|
|
|
|
|
That's because OnPaint is eventually called as a result of Invalidate().
By putting an invalidate in there, you said "I've drawn (it's valid)", swiftly followed by "it's invalid again".
Steve S
Developer for hire
|
|
|
|
|
If that were true, couldn't I just put an Invalidate() in the program when I wanted it to repaint itself?
That is, I call my TextOut functions...then tell it to Invalidate() (which eventually calls OnPaint())????
|
|
|
|
|
Invalidate is a function that cause the window to redraw itself. But all it does is call the OnPaint method, which didn't know anything about your drawings on the dc. Everytime OnPaint gets called, it gets a clean dc to draw on, OnEraseBkgnd makes sure of that, and your TextOut stuff would be gone with it.
That's why everyone told you that your text drawing need to be called from within the OnPaint method.
AliR.
Visual C++ MVP
|
|
|
|
|
Thank you for the help.
I do have an additional question, now though.
I have a number of screens (100s of them) that I am going to be drawing line by line.
Instead of having my OnPaint with all those boolean checks, can I call a function with CPaintDC as a member to draw them "outside" of the OnPaint()?
Thanks again.
Josh
|
|
|
|
|
Yes you can. Pass the dc as a parameter to the method.
AliR.
Visual C++ MVP
|
|
|
|
|
goodoljosh1980 wrote: if(RegKeyAvail){
This check is actually not necessary. Much like the view renders whatever the document has in it, the OnPaint() handler should draw whatever value is in a member variable. If that value starts out as blank, so be it.
void CMartinPhDDlg::OnPaint()
{
CPaintDC dc(this);
dc.SelectObject(&Welcome_font);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(COLORREF RGB(255,0,0));
dc.TextOut(30,30, m_strText);
Welcome_font.DeleteObject();
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how to write the code for make the image show full screen.
|
|
|
|
|
|
Can you be more specific
whitesky
|
|
|
|
|
What image?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to make screen saver project using the picture *.jpg or *.Bmp.
|
|
|
|
|
|
|
Maximize the window that is displaying the image. Also remove the title bar and border.
AliR.
|
|
|
|
|
Max++ wrote: how to write the code for make the image show full screen.
try CDC::StretchBlt.
"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
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
Does anyone knows how to merge two resource files together in VS C++?
I have two projects (one in VS 6.0 and another in VS.NET) with two different .rc files and i need to merge them together. If I try to do it straightforward way, just adding one of the .rc's as a file to the other project it will show it as a resource in the Resource Window in VS but it won't load due to some errors like "invalid control type" or "undefined keyword or key name". I know taht this file had to be in sync with .h file and if I add it without updating the .h file it won't work... but how do I update the .h file so that all the resource IDs are known? I really don't want to create all the dialogs with all their contents if I can merge the two files together.
Any ideas how it can be done?
Thanks in advance!
-- modified at 10:12 Tuesday 18th July, 2006
|
|
|
|
|
|
Thanks Randor, maybe i'll try it if i get too desperate.
I found an article about multiple resource and header files in one project on msdn site (http://msdn2.microsoft.com/en-us/library/6t3612sk.aspx), i'll post here if i have any luck including one RC file into the other.
|
|
|
|
|
open the RC you want to copy, select the elements you want to duplicate, and then drag n drop them to the target rc (within Visual C++, of course).
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|