|
I'm a relatively new programmer and I was wondering if there was an easy way to read a text file of numbers seperated by spaces into a matrix. Here's what I got:
int i, j;<br />
short ImageArray[IMAGE_SIZE_X][IMAGE_SIZE_Y];<br />
<br />
char *FileName = C:\Image.asc;<br />
<br />
ifstream ImageFile;<br />
ImageFile.open(FileName);<br />
<br />
for(i=0; i<IMAGE_SIZE_Y; ++i)<br />
{<br />
for(j=0; j<IMAGE_SIZE_X; j++)<br />
ImageFile >> ImageArray[i][j];<br />
}<br />
ImageFile.close();
I know I'm reading it wrong but I don't know the correct way to do it. Any help would be greatly appreciated.
|
|
|
|
|
I've seen a few programs out there that are very small in size and actually do something (ex.: .kkreiger)... When I look at their import functions list I see only LoadLibrary and GetProcAddress. The question is: How do you remove all those additional dependencies from your programs (C++)?
|
|
|
|
|
|
Hi,
I'm resizing the workarea of Windows in the initialization of my program so that my application will show always, like taskbar.
My problem is that sometimes, not always, the workarea reverts back to the original size.
It usually takes 1-20 seconds after I start my app to happen.
Any ideas on what is causing this behaviour and more importantly how to fix it?
I'm using Visual C++ 6 and my app is dialog based using mfc.
thanks
ahto111 at hotmail
|
|
|
|
|
I use microsoft VC++.
I have a group of header and source files that I want to compile into a library to be linked in my program.
How can i do that in Microsoft Visual Studio 6 ??
Thanks in advance
|
|
|
|
|
|
Hmmm,
I get this error and I dont now what it means!
Can anyone explane this to me, what is I doing wrong?...
TRACE1("Error: no data exchange control with ID 0x%04X.\n", nIDC);
ASSERT(FALSE);
AfxThrowNotSupportedException
|
|
|
|
|
Your DDX section refers to a resource id that isn't present in your dialog or view.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ok and how can I fix this?
|
|
|
|
|
Um... add the control to your dialog/view.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
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
|
|
|
|
|