|
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! ]
|
|
|
|
|
Cannot do it in VS 6.0 - no drag and drop in there. No "import .rc files" either. I can add it to the project as a regular file but then i have tones of errors because it has to be in sync with resource.h file and it's not.
-- modified at 12:43 Tuesday 18th July, 2006
|
|
|
|
|
Hi,
When I press the enter key in a dialog box, the default is CDialog::OnOk (I guess).
What I usually do is catch the enter key message and make it a tab key.
But for this particular project, I want OnButtonAdd function to be executed if the focus is on an edit box and the Return key is pressed.
I tried this:
BOOL CApplyValue::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message== WM_KEYDOWN && pMsg->wParam==13)
{
CEdit *e;
e = (CEdit*)GetDlgItem(IDC_EDIT_All);
if (e->GetFocus() == this)
OnButtonAdd();
pMsg->wParam=9;
}
return CDialog::PreTranslateMessage(pMsg);
}
No error come up with this, but it doesent work. So I must be doing it wrong. Please can you tell me the right way.
Thanks,
Tara
Fortitudine Vincimus!
|
|
|
|
|
If the CEdit has the focus, then the Dialog never recieves the WM_KEYDOWN message. The message is being processed by the CEdit. You need to derive a class from CEdit and use your PreTranslateMessage code there.
|
|
|
|
|
When the edit control receives focus, use CDialog::SetDefID() on the Add button.
"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
|
|
|
|
|
CDialog::SetDefID()
Thats a wonderful thing I have learnt today. Thanks a lot.
Fortitudine Vincimus!
-- modified at 10:52 Tuesday 18th July, 2006
|
|
|
|
|
Tara14 wrote: Thats a wonderful thing...
Only if it works, though. Let us know.
"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
|
|
|
|
|
Yes!! It did. It worked.
Because of this I also realised one more thing.
In the settings for a button in a dialog box resource, there is an option 'Default button'. If you select that option for any button, when the enter key is pressed that particular button is activated. Earlier, I had thought that the option 'Default button' had to do with its appearence!
Thanks.
Tara
Fortitudine Vincimus!
|
|
|
|
|
This is not the proper way of handling RETURN Key. If you have more than one edit box and if you want to handle RETURN in different ways for each edit box, then this method fails.
Check the below code:
BOOL CApplyValue::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message== WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
if (pMsg->hwnd == ::GetDlgItem(*this, IDC_EDIT1) //Replace with proper resource ID
{
//Do your processing for Edit box1
GetDlgItem(*this, IDC_EDIT2)->SetFocus(); //If you want to set focus to next edit box
}
else if(pMsg->hwnd == ::GetDlgItem(*this, IDC_EDIT2)
{
//Do your processing for Edit box2
}
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|