|
So, you may be asking yourself, with a subject like that, why use this forum? Simple, I did not go elsewhere, as codeproject always has the answer for me. Also, I know nothing of C++. Anyway, my problem.
At uni, we have been told we must learn to program in C. Fair enough. But please, what environment should you use for this? I was told (though I am not sure on this) that naming your file with a .c extension, instead of .cpp should do this for you. Anyway, tried that in VS.net, and it cant find <stdio.h>
So, I tried the same code in Borland C++. It gave me some error about not giving a correct output in my function.
So, you may say I am stupid, and made a mistake. But, I copied (and check often), the code from the C Language book (The bible of C I am told).
Please solve this for me.
|
|
|
|
|
What is the exact code you are trying to compile?
It is strange that stdio.h could not be found. Sounds like you may have an incomplete or corrupted installation of VS.NET.
- Mike
|
|
|
|
|
It depends on what the Uni provides. Back in my day, the universities often steadfastly refused to acknowledge the existence of windows, so you were often doing c programming from a unix prompt with a shell account using the... help me out here.. cc compiler? Ie cc source.c target
or some such command line.
They're going to have to guide you on an environment, because eventually you'll be writing programs and swapping source files and if they don't work in all environs, you'll be wasting your time. My second guess is that they're going to at least start you with pure ANSI c and c++, so TECHNICALLY the environment may not matter as long as you understand your personally chosen environment. In Visual Studio, you can write console programs and stick to completely ANSI code and have no trouble whatsoever. In the Borland environment-- I have no idea.
Hope this helps. As far as your particular error, you might send a snippet of code which directly relates to your error.
Paul
|
|
|
|
|
If you want to test code from Kerningham and Ritchie,
you can use VC of course.
All you have to do is (VC6)
First:
click on File - New
you can now choose the type of project you want to create
select WIN32console application
name it test (the IDE will append .dsw)
click OK
Second:
Select File - New again
you can now choose then type of file vou want to create
select sourcecode (.cpp)
name it main (the IDE will append .cpp)
click OK
Now you can cut and paste your sourcecode to the main.cpp file and compile it.
(usually the first test would be compiling "Hello World")
sledge
|
|
|
|
|
Hi
I'm new to MFC so I'm sure the solution is easy...
I have created a SDI application using App Wizard without support of document view. I have two views in a splitter, CFormView and CEditView..
The program starts up and all but when I try to type anything in the edit view an unhandled excpetion is thrown : Access violation.
Heres the initialization of the views:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) <br />
{<br />
m_Splitter.CreateStatic(this,1,2);<br />
if (!m_Splitter.CreateView(0, 0,<br />
RUNTIME_CLASS(CDBView), CSize(200,400), pContext))<br />
{<br />
TRACE0("Failed to create second pane\n");<br />
return FALSE;<br />
}<br />
if (!m_Splitter.CreateView(0, 1,<br />
RUNTIME_CLASS(CFileView), CSize(0, 0), pContext))<br />
{<br />
TRACE0("Failed to create second pane\n");<br />
return FALSE;<br />
}<br />
return CFrameWnd::OnCreateClient(lpcs, pContext);<br />
}
Where CDBView is a CFormView, CFileView is a CEditView and CMainFrame is a CFrameWnd.
Daniel
|
|
|
|
|
Just use your debugger to trace line by line which part of the codes is throwing exception. Usually is cause by your variables are not getting initialized or accessing deleted pointers.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi there:
Is there anyone out there with any experience with groupware? If they have, Which one? and Do they think it might work for a software co-operative? This is an intranet type of software with PIM integrated into it.
J.
----------------------------
|
|
|
|
|
Exchange works pretty well. I (much) prefer it over Lotus Notes.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Hi all,
I am getting problem with CRichEdit control.
I am writing what I am getting.
I have changed the para formatting by using this code
PARAFORMAT pf;<br />
pf.cbSize = sizeof(PARAFORMAT);<br />
pf.dwMask = PFM_ALIGNMENT;<br />
pf.wAlignment = PFA_LEFT;<br />
m_RE_Output.SetParaFormat(pf);
Then I have changed the para formatting by using this code
PARAFORMAT pf;<br />
pf.cbSize = sizeof(PARAFORMAT);<br />
pf.dwMask = PFM_ALIGNMENT;<br />
pf.wAlignment = PFA_RIGHT;<br />
m_RE_Output.SetParaFormat(pf);
This is what I was doing is a normal code.
Now the problem beings when I place the cursor in the RichEdit and place some more text the formatting changes, I mean the left goes right and the right remains at right as it should.
I donot know why the CRichEdit behaves like this.
Thanks.
Help greatly appreciated.
The Phantom
|
|
|
|
|
Hi,
I am thinking of making the transition from using the Windows API SDK with mostly C to MFC - well, more than just thinking, I really want to do it. I have been using the Windows API and learning C with a modicum of C++ for the past couple of years, and have created several small programs (with a lot of help from the kind people here), but now I want to take it a stage further. I have an idea for a Windows program that I'd like to make as professional as possible with a nice GUI, and I think that MFC is the way to go for two reasons:
Firstly, given that my program is designed to look a little like a cross between Explorer and a word processor, with a tree view on the left and a rich edit box on the right in a dockable window, I can easily generate the basic GUI of my program using appwizard.
Secondly, there are a lot more code examples, both here and elsewhere, that would be very useful for my program that use MFC than the SDK, and so far I have spent a lot of unnecessary time struggling to convert code from MFC to straight C/WinAPI.
That's the waffle over, then. Considering that I learn much more easily if I am motivated by a goal (in the case the goal is the software I want to write) rather than by following dry tutorials which teach me how to write small programs I'll never use, I'd really appreciate some tips or advice on where to start with making this transition:
1) I know this is a question that comes up a lot, but what books would people recommend to help me make this transition? Before you shout: I have searched this forum, the FAQ and elsewhere, and the two books that seem to come up the most are Richard Jones's 'Introduction to MFC Programming', and Jeff Prosise's 'Programming Windows with MFC'. I am thinking of buying the Jones, because I am not very familiar with OOP and this is supposed to be easier as an introduction. Is this a good way to go? Or are there other books I may have missed?
2) I am guessing that in order to learn MFC I am going to need to improve my knowledge of C++ drastically - like I say, aside from some limited use of classes, I have mostly used straight C so far. I have the SAMs book by Jesse Liberty, which I am returning to right now, as well as other books which are way out of my league (I don't think I've ever opened my Stroustrup ). Should I learn more C++ before turning to MFC? Or can I learn what I need to know about classes and OOP as I go along whilst learning MFC? And if so, are the books above helpful for this too?
3) As a quick test, I tried using the MFC appwizard to create a program with the sort of GUI I want for my app. Within a few clicks, voila, I had a GUI that I loved. But when I opened up the CPP files I was terrified - I couldn't believe how alien it all was compared to a simple SDK program. How easy or difficult have other people found the transition from the SDK to MFC, if you've made it?
And finally, two stupid(er) questions:
4) Not really an MFC question, but...: In an application that is NOT dialog-based, is it okay (ie. good practise) to mix it up with lots of dialogs created in the resource editor? Eg. Say you have a menu in a non-dialog app but use it to call dialogs. I thoroughly expect the answer to this to be, "Duh, yes, of course, it's pretty much the same thing anyway," but I just wanted to double-check as it's something I do a lot with the SDK.
5) Is there a very simple example of a text editor using MFC available? I ask this as a final thought, before searching, so if this is the sort of thing I will turn up straight away on a search, ignore it. It just occurred to me that I might be able to learn quite a bit from such an example.
Please bear in mind that programming isn't my career path (I'm on my belated way to becoming a teacher) and thus I don't have the same amount of time that a professional, or someone younger, might have to research and learn everything in detail, so I would greatly value the input and advice of the experienced programmers here.
Thank you for any input,
KB
|
|
|
|
|
- I strongly recommend Prosise's book.
- Should I learn more C++ before turning to MFC?
That's exactly what I did several years back. I started creating a few (non-GUI) classes and used them in my Win32 apps. You don't have to be a C++ expert to use MFC, but it's helpful to know the fundamentals. It can save you a lot of head scratching!
- I couldn't believe how alien it all was compared to a simple SDK program
Don't worry, we've all been there. You'll soon get over it as you start modifying the code the app wizards create for you. Remember, the unknown is usually almost always daunting.
- simple example of a text editor using MFC
You could brew your own by creating an SDI app whose view class is a CEditView . Good luck and have fun!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thank you for your reply, it's very encouraging. At first I was scratching my head to your answer to question 4, before I realised that SDI is just "Single Document Interface" (as opposed to MDI) - just the terminology can be daunting at first.
Everyone seems to recommend the Prosise book, so I think I am going to splash out and buy both, so I can use Prosise's as a reference. Looking through the indexes (indices?) on Amazon.com I see that Prosise's book covers such things as RTF files and tree views, so I can turn to that once I've gone through the basics in Jones and am ready to take on the main aspects of my program.
Thinking about your reply to no. 2, I have decided to go through some C++ basics before looking at these books though. I have just bought a very nice and cheap book called "Teach Yourself C++ in 10 minutes" (somewhat ridiculously) by Jesse Liberty. I've started going through it and I really like it, as it recaps on the basics of C and then moves into very short (supposedly 10 mins each) lessons on C++ - OOP, classes, etc. I like it because it means I can grasp the bare basics of some of the C++ concepts without having to wade through 1,000 pages (nothing worse than slogging through a book and thinking "I'm not going to learn how to use a class until page 600, and I'm a slow reader..."), and I can refer to my other C++ books with a more need-to-know approach after I've got some of the concepts (and terminology - one of the problems of being self-taught) pegged.
It's very encouraging to hear that someone else has taken a similar route when learning MFC.
Thanks again,
KB
|
|
|
|
|
I have a Dialog app where I have a PropertySheet
Within this PropertySheet I have multiple pages(CpropertyPage)
it so happens that tabs 3 and 4 correspond to the same class ( say CPage3 derived from CPropertyPage).
I want to name the title on the tab to "page3" and "page4"
As of now in the resource the Dialog is named as "zombie" so both tabs show the name Zombie
I tried modifying the name using
this->SetwindowText(pageName)
but this doesnt seem to update anything !
Please help
Engineering is the effort !
|
|
|
|
|
Use the CPropertySheet::GetTabControl() to get a pointer to the tab control, then use CTabCtrl::SetItem() to set the text.
TCITEM item;
item.mask = TCIF_TEXT;
item.pszText = _T("My Page Title");
m_Sheet.GetTabControl()->SetItem(nPage, &item);
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks it works
had another question .
I need to either Disable a tab so as to prohibit the user from entering that page
or keep the tab enabled but disable the page.
. I dont know how to do the former but i tried doing
this->showWindow(SW_HIDE) in the PropertyPage class for the latter , but didnt work
Would like to know both methods of doing it . Thanks
|
|
|
|
|
Is there a MS Word Control that I can embed inside a dialog window?
Thanks
|
|
|
|
|
You probably could by having an activeX container on your dialog.
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
|
Hi!
Can everybody tell me a web address or send me an actual documentation of these
active X control which can be "imported" by using windows 2000 included system file imgedit.ocx.
German Name is "Steuerelement für Bildbearbeitung".
I only got the documentation 2.6 which is very bad.
|
|
|
|
|
Hi,
I'm trying to make a soft which needs to get the precise (ms) length of ac3 files. I'm a beginner with programming and I've no idea how to do this. I tried using a DOS application (ac3dec..) but couldn't find one doing what i wanted. The deduction of audio length from file size didn't work (at all) so I don't have an idea.
The only way I found to get the audio length was to convert AC3 to WAV using azid, then to get the wav's file size to find its length (which is also the AC3's) but this takes quite a lot of time and doesn't fit my needs.
If anyone had any idea, I'd be very glad!
Pwalo.
|
|
|
|
|
I created a rectangle region with the following code
pDC->SetMapMode(MM_LOENGLISH);
pDC->Rectangle(440, -90, 640, -150);
pDC->Rectangle(440, -200, 640, -260);
pDC->Rectangle(440, -300, 640, -360);
pDC->SetTextColor(RGB(196,48,157));
pDC->TextOut(465, -105, "Player 1 Start");
pDC->TextOut(465, -215, "Player 2 Start");
pDC->TextOut(497, -315, "Be Gone");
Now i want to do an action when i hit the LButtonDown on the first rectangle. I was thinking i could use PtInRegion. but i am not able to do it. Please tell me how i can click on each rectangle and do an action.
|
|
|
|
|
The Rectangle function uses screen coordinates to define the rectangle's boundries.
So using negative numbers would cause the rectangle to be drawn outside of the display area of the DC.
If you assigned the screen coordinates to CRect objects instead of hardcoding them in your Rectangle() calls, you could then call each CRect's PtInRect() member.
|
|
|
|
|
Ok, i tried doing a CRect and created the rectangle. in the LButtonDown function i did a CRect rect(&r). then if (rect.PtInRect(point)) message. this is not working. what do i have to do?
|
|
|
|
|
Are your rectangles displaying correctly? Did you change the coordinates so they are not negative?
If you are using &r when you construct your CRect, and the rect was built using those negative numbers you had, it won't work:
<br />
RECT <br />
The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle. <br />
<br />
typedef struct _RECT { <br />
LONG left; <br />
LONG top; <br />
LONG right; <br />
LONG bottom; <br />
} RECT; <br />
<br />
Members<br />
left <br />
Specifies the x-coordinate of the upper-left corner of the rectangle. <br />
top <br />
Specifies the y-coordinate of the upper-left corner of the rectangle. <br />
right <br />
Specifies the x-coordinate of the lower-right corner of the rectangle. <br />
bottom <br />
Specifies the y-coordinate of the lower-right corner of the rectangle. <br />
Using a negative number for any of those members will produce a rectangle that won't be correct.
|
|
|
|
|