|
Well,
it on; CDialog::OnInitDialog(); And if I take it away I get this error; ASSERT(::IsWindow(m_hWnd));
So how can I fix that?
|
|
|
|
|
Buy a book. Seriously, the error messages are telling you what's wrong, did you consider researching what that means youself ? What do you think the line above means ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Yeee,
Well that dont help me.
I dont want to delite that line so how can I keep it and still run the program?
|
|
|
|
|
Look, I didn't tell you to delete a line, I suggest you take some steps to learn how to program.
It's more helpful than you think. If you don't learn to do your own research, you will never be able to code anything for yourself. These are simple issues with the way you've set up your MFC project, although to be honest, at this stage your descriptions are too vague for me to know exactly what you need to do. It sounds like you DO need to delete the line in question, it sounds like you're trying to call updatedata, or some other operation that is not valid where you're doing it, because the window has not been created yet.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
The OnInitDialog() method has nothing to do with the problem. Ravi has explained, in detail, what the problem is and how to rectify it. Every control ID referenced in the DoDataExchange() method must also be present in the dialog template. For example:
void CWorkFlowTab::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
DDX_Control(pDX, IDC_WFS_XB_ACTIVE, m_xbActive);
DDX_Control(pDX, IDC_WFS_CB_RECIPIENT, m_cbRecipient);
DDX_Control(pDX, IDC_WFS_CB_MESSAGE, m_cbMessage);
DDX_Control(pDX, IDC_WFS_XB_COMPL, m_xbCompleted);
DDX_Control(pDX, IDC_WFS_CB_RECIPIENT2, m_cbRecipient2);
DDX_Control(pDX, IDC_WFS_CB_MESSAGE2, m_cbMessage2);
} If any of the six IDC_xxx controls are missing from the dialog template (in the .rc file), I will get a run-time error such as the one you got.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Assuming you have a dialog, you will have a function like this
void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CONTROL, m_Control);
DDX_Control(pDX, IDC_MISSINGCONTROL, m_MissingControl);
}
Within it are DDX_Control lines, one of the lines relates to a control you have not added or have recently removed from your resource dialog.
Just remove the line containing the missing control to get
void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CONTROL, m_Control);
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Thank!
But here it is;
This is what I have;
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetEyeStatusDlg)
DDX_Control(pDX, IDC_BMP_HIDE, m_HideDisable);
DDX_Control(pDX, IDC_MESSAGE_LIST, m_ctlMsgList);
DDX_Control(pDX, IDC_TXT_MESSAGE, m_ctlMessage);
DDX_Text(pDX, IDC_MESSAGE_LIST, m_Add);
DDX_Control(pDX, IDC_EDIT_MESSAGE, m_editIcon);
DDX_Text(pDX, IDC_LOG_EVENT, m_LogEvent);
DDX_Text(pDX, IDC_STATIC_ANTAL_USER, m_Log_User);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_LOG_STATUS, m_lbxListBox);
And all of this is in the resoure.cpp file
So what can it be?
|
|
|
|
|
First of all, DDX_Control(pDX, IDC_LOG_STATUS, m_lbxListBox); should probably be above that comment.
Please consider thinking for yourself, and trying things for yourself. If you just comment out lines, you can't break anything. Try taking the lines out one at a time until the problem is solved. Or just ask yourself - which of these names refers to a control that I created but then ended up deleting ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Well I have find It but when I delite that line I get this again!
ASSERT(::IsWindow(m_hWnd));
|
|
|
|
|
Mostly likely cause - you've created another problem, of the type I described before ( you're trying to do something with the window before it's created ), and now that the earlier error is fixed, the code is getting to the right point for this to blow up.
Next step - put breakpoints in all your OnInit/OnCreate/constructor type code, and step through to see where it's breaking. Actually, if you just go into debug mode when then assert fails, you should be able to see where it's blowing up in the call stack.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Well I have find the problem and it's fix,
That for help
|
|
|
|
|
Well I have find the problem it works now.
That for the help - to self help.
|
|
|
|
|
Hi
I am new to GUI programming. I am learning MFC and able to create one
application.
But I have one problem that i am not able to solve yet.
Problem:
I want to display a message that tells the upcoming Birthdays. I don't know how
long birthday list can be, so I can't use Static control. I tried to use
DrawText() Function to draw text. I know DrawText() extends the base of the
rectangle to bound the last line of text. I am able to draw the text message but
have following problems.
I don't know how to get the correct height of the text
message rect.
How to change the dimensions of the Dialog box according
the text message.
Sometimes Text is not displayed, only blank area is
displayed. Don't know why?
I want to do something like this:
Link to
IMAGE
I Created DrawText() Function which paint the text. I called DrawText() in
OnPaint().
void CRUNDlg::DrawText()
{
CPaintDC dc(this);
CRect rect,rcDialog,temprec;
CFont fFont;
CFont *fOldFont;
int h; // i tried to use h to calculate height of text but in vain
// rect: for DrawText
// rcDialog: for Dialog dimensions
// temprec: for height calculation of text drawn
//
GetWindowRect(&rcDialog);
GetClientRect(&rect);
dc.SetTextColor(RGB(0,0,196));
dc.SetBkMode(TRANSPARENT);
temprec=rcDialog;
temprec.bottom=0;
temprec.bottom =rect.top=10;
fFont.CreateFont(20,0,0,0,FW_NORMAL|FW_BLACK,0,1,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");
fOldFont =dc.SelectObject(&fFont);
h=dc.DrawText("Birthday Alert",rect,DT_NOCLIP|DT_CENTER);
temprec.bottom+=rect.top;
fFont.Detach();
fFont.CreateFont(15,0,0,0,FW_NORMAL|FW_BLACK,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");
fOldFont =dc.SelectObject(&fFont);
rect.top+=h+5;
temprec.bottom+=rect.top;
dc.SetTextColor(RGB(14,14,255));
h=dc.DrawText("Following is a Birthday
List",rect,DT_EXPANDTABS|DT_NOCLIP|DT_CENTER);
temprec.bottom+=rect.top;
rect.top+=h+5;
temprec.bottom+=rect.top;
dc.SetTextColor(RGB(0,0,0));
h=dc.DrawText("vikram sharma\t21-11-88\nThis Is
Test",rect,DT_EXPANDTABS|DT_NOCLIP|DT_CENTER);
temprec.bottom+=rect.top;
GetWindowRect(&rcDialog);
ClientToScreen(&temprec);
if(!(rcDialog.bottom>= temprec.bottom))
rcDialog.bottom= temprec.bottom;
MoveWindow(&rcDialog);
CentreTheDlg();
}
|
|
|
|
|
You should consider using a CListBox or a CListCtrl to display a collection of birthdays.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hey,
Does anyone have any c++ code that will connect two computers and allow them to communicate? For instance, if I type "hello world" one of the computers, it will appear on the screen of the other computer. I need something simple and it I believe it uses WinSock. If you have any code, please email it to me at gary.grinev@uconn.edu
Thank you
|
|
|
|
|
|
Hi,
I think this is way to complicated. I need something very simple. Do you have any code that I can just paste in and work. That program had multiple header files and so on...
|
|
|
|
|
rct23333 wrote:
Do you have any code that I can just paste in and work.
Sorry, no. Building a chat server and client requires a fair amount of effort. The article I pointed you to contains a number of classes that will greatly simplify your work.
If the article seems more than what you were hoping to digest, I respectfully suggest you take on a simpler task or (better yet), spend some time understanding the basics of client server communication. There are several articles at CP that you are likely to find helpful. And if you have specific questions, feel free to post them. We're here to help. Good luck!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Good evening.
I am MFC/C++ beginner and I have a question:
I want to put ascending numbers into a bitmap window by clicking and subsequently save that to disk (e.g. click:"1", click:"2" etc).
I see two possibilities:
Use TextOut: works nicely, but I cant save that. Is there a trick to make the Text a part of the bitmap?
Use MaskBlt: Then I'd draw small "number" icons into the bitmap.
Using the Class Wizard, I can only generate OnLButtonDown, but that doesnt have "CDC* pDC" in the parameter list. Trying to fix it gives me a GPF.
Please would someone be so kind and put me on the right tracks?
Thanks for any help
Harald
|
|
|
|
|
VogelH wrote:
Using the Class Wizard, I can only generate OnLButtonDown, but that doesnt have "CDC* pDC" in the parameter list. Trying to fix it gives me a GPF.
You can't change those methods, they are overridden from the base class. You should never paint outside the OnPaint method anyhow. To force OnPAint to be called, just call Invalidate();
VogelH wrote:
Use TextOut: works nicely, but I cant save that. Is there a trick to make the Text a part of the bitmap?
Yes, draw it onto the bitmap, instead of onto the screen. Then draw the bitmap to the screen DC.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
>>Yes, draw it onto the bitmap, instead of onto the screen. Then draw the bitmap to the screen DC.
Thanks Christian for your reply. But how would I exactly do that? Could you please steer some lines of example code towards me? I always get confused by all those context things.
Ive gotten this far now:
void CView::OnLButtonUp(UINT nFlags, CPoint point) <br />
{<br />
CClientDC dc(this);
CString str;<br />
<br />
str.Format("%d",m_intNr);
dc.TextOut (point.x, point.y,str);<br />
<br />
CScrollView::OnLButtonUp(nFlags, point);<br />
m_intNr++;<br />
}
Harald
|
|
|
|
|
This is a disaster. DON'T use CClientDC, for starters the bitmap probably isn't there, it's probably being drawn there in OnPaint. do all drawing there. Store your mouse position in a variable and call Invalidate to force a paint message.
THEN you need to create a CDC and select the bitmap into it, then draw the text into the CDC. THEN when you draw the bitmap into the CDC passed into the paint handler, it will have the text drawn onto it, instead of both the bitmap and the text being seperately drawn onto the screen.
Just to mess you up even more - if you use a CBitmap, it will be the bit depth of the screen, you can't change that. You should get a DIBSection wrapper instead, then you can specify bit depth.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Many thanks Christian!
I start to get the picture slowly
Greetings,
Harald
|
|
|
|
|
How can I check if the pogram is exit with;
CTRL+ALT+DEL ?
I need to be enable to see if the program exit.
I can see if someone exit the program from ALT+F4 and ESC or from the program.
|
|
|
|
|