|
Hi,
My project has 4 dialogues.I inserted a tab ctrl and set its style as Popup style and border as dialogue frame .I set my dialogs as Child and Border None.
The proj worked fine earlier without tab.after insertinon of the tab ctrl it just hangs.There is no error in it.
If i set the dialogues style back to popup and border to dialogue frame then it works without my tab dialogue showing up.
Can anyone suggest me where i'm wrong?
Thanks
|
|
|
|
|
Hi,
I want a alert sound -the sound of piano keys pressed together(The sound we get during "Debug Assertion Failure")when my dialog box pops up.
How do I do it?
Thanks and Regards
Deepak Samuel
|
|
|
|
|
Use MessageBeep(MB_ICONEXCLAMATION);
John
|
|
|
|
|
Hi! You can also create your own wav file and play it. You can use this:
<br />
CString sFilePath = _T("C:\\WavFiles\\sound.wav");<br />
PlaySound(sFilePath, NULL, SND_FILENAME);<br />
or
<br />
PlaySound(MAKEINTRESOURCE(IDR_WAVSOUND), NULL, SND_RESOURCE);<br />
You have to include Header File: mmsystem.h and Import Library: winmm.lib .
I hope this helps!
Well... I am a beginner ...
|
|
|
|
|
I wrote a linked list to hande some object that I created. When I try to print the list, it prints garbage. I made a temporary project to test my class and it works fine, so the problem is how I am using it in my project. I think that it is a memory issue and that the objects are being written over after I store them in my list.
This is how I am using the list.
//funtion to create object that will be stored in list.
CApproach ApproachPage::ParseApproach(CString string)
{
......
CApproach approach(Chart_Name, Chart_Num, Chart_Rev_Date);
return approach;
}
//Insert class in List.cpp
int PrintList::Insert(CApproach* approach )
{
.....
}
//main.h
PrintList* list;
//contructor of main
list = new PrintList();
//main
list->Insert(&ParseApproach(codestring));
//prints garbage to the outputfile, but works in another project
list->print()
I learned to program in java so pointers and c++ memory are far from my specialty. Any help would be great. Thanks.
Kevin Shaffer
kshaff03@msn.com
|
|
|
|
|
The CApproach object returned from ParseApproach is a temporary object. You're passing the address of this temporary to Insert. When the temporary object is destroyed automatically the pointer to it points to garbage. You can either let Insert take a copy of a CApproach object instead of a pointer:
<br />
int PrintList::Insert(CApproach approach)<br />
or you can assign the result of ParseApproach to a local variable, but keep in mind that when that variable goes out of scope, the pointer to it will point to garbage:
<br />
CApproach result = ParseApproach(codestring);<br />
list->Insert(&result);<br />
list->print();<br />
You could also pass Insert a pointer to an object allocated on the heap, but you have to remember to delete it when you're done with it.
|
|
|
|
|
If this is not a homework assignment you should try and use one of the built-in lists link CList or better yet list. Clist is a MFC template class and list is STL. See the MDSN help for documentation. There really is no good reason to have to create your own linked list when there are very good lists available.
John
|
|
|
|
|
hi
I am trying to open PS/2 port , but I can't!!
Anyone can help me to open a PS/2 port (Mouse) and read its data .
my purpose is this :: i want unplug a ps/2 mouse and turn on the computer then plug the mouse to computer and read its data .
i did this action for COM1 port but I can't this for PS/2 .
please help me
thanks alot
|
|
|
|
|
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
|
|
|
|
|