|
Thank you, this tutorial looks like it will be very usefull.
"I'd love to change the world, but nobody will give me the source code."-Anonymous
"If I were two-faced, would I be wearing this one?"-Abraham Lincoln
|
|
|
|
|
C++ is the most confusing, complex, and frustrating language I've ever tried to learn; it's also the most useful, and worth the effort. The MS documentation is completely useless unless you already know the language and the IDE, but there are some books that can help. The best I've found is Practical Visual C++ 6, by Bates & Tompkins, though I've wasted money on a lot of other books that taught me absolutely nothing (including the MS Press Visual C++ Reference Library).
Find a copy, work through the examples, and have fun. I've been trying to make sense of the language and the IDE since Visual C++ 4 was current, and made no progress whatsoever until I got this book. Now it's actually fun.
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
Iam creating an mdi application where in if we save the page each child window would be saved under one name.How can i group several pages or child windows and save as one project under one name and when i open it i must be able to view all the child windows created in that project.
How can it be done
|
|
|
|
|
In my app, i use ADO to retrieve data from Access and i user clistctrl to show the data.
When the number of record is huge, it's very slow, then i tried to use virtual list which read data dynamically, however the performance is still bad because in OnGetDisp the data is retrived automatically, and involved in calling recordset object many many times.
After that, i try to user VB, i found that performance of ListView ctrl in mscomctrl.ocx is great (I didn't bind list ctrl with adodc object, i add the items dynamically). I note that the class name in VB is different from that in VC, for example, in VB the name is ListImages, while in VC, it's CImages. So i decide to use this control in visually c++, but there is still a problem. Because i use bitmap in the ctrl,i have to let the control to show some pics as well. and i import CImage,CImages, CPicture, CImageList class using wizzard. When i use CreateDispath to create CPicture obejct, it always failed, i suspect the ProgID is incorrect, then i use oleview to try to get the name, but i can't find it, then i tried Clsid, copy it from oleview, and it still failed to create, the error message is "the control is not registered". At last i went to try CImage, i got the same result unfortuletely.
Finnaly, i give up the wrapper class, i use import directive to get the coclass, o, my god, it still doesn't work.
Pls, help me, how to use the control and other com objects in vc, or tell me another list ctrl class to use with great performance.
I'm sorry, it's a long thread.
thank you.
I love C++
|
|
|
|
|
I use this method to create image object
1.IImagesPtr img;
img.CreateInstance(__uuidof(ListImages));
2.CImage img;
img.CreateDispatch(""); //I can't find the ProgID
|
|
|
|
|
Hi there everyone,
I'll try to be brief in describing my difficulty.
I have been given good advice from this forum that it would be good to learn how to use the STL instead of always using MFC collections like CList. I have been convinced; seeing how many useful tools are available (I'm going to be using stable_sort for example). Here is the deal. My App has a class (CMyDBM) that had as a member a CList as follows:
CList<CPlayerRec*, CPlayerRec*> m_PlayerList;
Where CPlayerRec is a class that itself holds a fixed number of CStrings and some ints (it has no other classes or structs and nothing dynamic, just some CStrings and ints).
I then had a series of functions in CMyDBM that did various things. Among them was the copy constructor function. The project compiled fine at that point.
I then removed the CList member from CMyDMB and subsituted the following member:
std::vector<CPlayerRec*> m_Players;
I changed the copy constructor to the following:
CMyDBM::CMyDBM(const CMyDBM& initDBM)
{
CPlayerRec* ptrPlayerRec = NULL;
std::vector<CPlayerRec*>::iterator it = initDBM.m_Players.begin();
for( ; it != initDBM.m_Players.end(); it++)
{
ptrPlayerRec = new CPlayerRec;
*ptrPlayerRec = *((CPlayerRec*)(*it));
m_Players.push_back(ptrPlayerRec);
}
}
Now, when I try to build, I get the following error:
E:\Program Files\Microsoft Visual Studio\MyProjects\Stats\MyDBM.cpp(64) : error C2440: 'initializing' : cannot convert from 'class CPlayerRec *const * ' to 'class CPlayerRec ** '
Conversion loses qualifiers
My idea was to store in the vector a collection of CPlayerRec pointers that I could 'new' as I needed them and then access and delete them later. I am open to storing actual CPlayerRec objects; but then how can I create them 'on the fly' with new and then add them to the vector? I would also have to figure out where / how to delete them.
I appreciate you reading this lengthy post and offering any advice.
Thanks,
Eric
|
|
|
|
|
Hi all,
I made the following change to the code:
I removed the following line (the one with the error):
std::vector<CPlayerRec*>::iterator it = initDBM.m_Players.begin();
And I added the following two:
std::vector<CPlayerRec*> tempVector = initDBM.m_Players;<br />
std::vector<CPlayerRec*>::iterator it = tempVector.begin();
The code now compiles, but I am concerned that I kludged it. Did I just shut the comiler up from bitching or is this the correct solution?
If this is correct, then what kind of clean-up do I need to perform regarding tempVector at the end of the copy constructor code?
Thanks very much again,
Eric
|
|
|
|
|
You have basically casted away const-ness in what you have done there - in a round about way anyway, you make a non-const copy of the vector and then call begin().
Look at initDBM decliration - const CMyDBM& initDBM.
The version of begin that returns 'iterator' isn't const - therefore you get errors about calling a non-const method on a const object - or an object within a const object in this case. The version that returns 'const_iterator' is const and is what you should strictly use when your not planing on modifying the objects in the collection anyway.
Change it to :
std::vector<cplayerrec*>::const_iterator it = initDBM.m_Players.begin();
That should work
|
|
|
|
|
Diddy,
Thanks very much for the reply. I see exactly what you mean. I will try it as soon as I get home where the project is. I appreciate your help!
Best,
Eric
|
|
|
|
|
No problem
Hope it works
|
|
|
|
|
Hi,
How can I trigger the user with sound? Is there a function for Visual C++ 6.0
|
|
|
|
|
PlaySound will help you with this.
Toughest Steel Comes From Hottest Furnance
|
|
|
|
|
Beep(20,2000);
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Hi,
I had created a few dialogs in my program. Whenever the users moved the secondary dialog, the drawings (using MoveTo & LineTo) behind the secondary dialog (which is the main dialog) got corrupted.
How can I fixed the secondary dialog & how can I prevent the main dialog drawings from corrupted?
Need Help
Siew Hoon
|
|
|
|
|
Are you repainting the main dialog correctly?
Sounds like a case of paint-once - IE you are painting the main dialog and then leaving it, when ever windows invalidates the area for what ever reason, you're not repaiting.
Try opening the main dialog and dragging another app (say an open copy of notepad) over the main dialog, what happens?
If the drawings dissapear insure you repaint what's ever on the dialog (well, the area that has been invalidated) everytime you get a WM_PAINT message - not just once.
|
|
|
|
|
Hi,
I did not do any repainting. How to repaint?
Need Help
|
|
|
|
|
I mean where you say "the drawings (using MoveTo & LineTo)" etc.
How are you doing your drawings? (actually, better question, where are you doing them?)
Do you have something like this:
CMyDlg::OnPaint()
{
MoveTo(...);
LineTo(...);
}
Or are you just paintining once? Ie constructing the dialog, then painting on it?
Put up your painting code, including where you are doing it
|
|
|
|
|
Hi,
I don't have a OnPaint function. I only have OnDraw function as list below:
void CTempProfilerView::OnDraw(CDC* pDC)
{
// Inside a for loop
MoveTo(..);
LineTo(..);
}
Best Regards,
Siew Hoon
|
|
|
|
|
So its the _view_ thats not repainting? IE not a dialog...
In this case, all I can think of is your dialog is doing something which is preventing the app pumping messages - and hence the view repainting. Is the dialog that is causing the problem modal or modeless? Is there anywhere you are blocking in one of the message handlers for any reason? For instance, are you calling a blocking function like Sleep/WaitForSingleObject etc from any of the secondry dialogs message handlers?
Cheers
|
|
|
|
|
Hi Diddy,
Sorry I had replied so late as I didn't know you have replied my previous message. There was no email to inform me... : )
I don't know whether my dialog is modal or modeless. The dialog style was set as Child.
This dialog was created when I create a database using AppWizard. Listed below are the steps which I followed.
AppWizard Step 1: Select a "Single document" & "Document/View Support".
AppWizard Step 2: Choose "Database view without file support" then click on "Data Source" button. Select the ODBC, select the "filename".
AppWizard Step 3: Accept the defaults.
AppWizard Step 4: Deselect the print & print preview features.
AppWizard Step 5 & 6: Accept the defaults.
Best Regards,
Siew Hoon
|
|
|
|
|
No email? Very unusual!
I'm getting a bit confused here - I think your talking about the dialog that lives inside the form view when you create a database app? but im not sure. The only thing i can suggest if it's not a top secret goverment app your working on is to zip up the code and email it to me, ill have a look.
Cheers
|
|
|
|
|
Ok, now we have the opposite problem - an email, but the post has gone!
Unless you deleted it?
"Yes, it's the dialog that lives inside the form view. Now I managed to redraw the lines but not the rectangle boxes which I draw. The boxes got corrupted when the scroll bar is being scrolled.
It's not a government app. It's for my final yr project. I had zipped it up, it's abt 7Mbyte but I dunno how to send the attached file. There are no option for me to select. What is your email address? I can't see it."
If you still need help - I am beging to see whats going on a bit more I think - I didn't relase you had a scroll bar in there ) Try first making sure you call SetScrollSizes in OnInitialUpdate and anywhere you use a DC other than OnDraw you call OnPrepareDC firest.
If it still doesn't work - the easiest way to get it to me is FTP.
FTP to didster.servebeer.com port 21
user codeproject
pass codeproject
Let me know when it's there
I rember the old final year project days )
|
|
|
|
|
ok, i managed to send out my program to you through FTP today.
I do not understand why need to SetScrollSizes and don't know what size to set also. For the OnPrepareDC, I don't know how to use it.
|
|
|
|
|
Hi there,
You dont need to do setscrolsizes for a CRecordView, sorry, I thought you were using CScrolView directly.
OnPrepareDC... Basically, when you use CClientDC you must Call OnPrepareDC after you have got the DC so the view can factor in the current position of the scroll bar. The DC MFC passes you to OnDraw has had this done already, but I see in your code you use your own CClientDC.
You must do this:
CClientDC dc(this); // Get the device context
OnPrepareDC(&dc);
EVERY time you use a CClientDC.
You should find if you do that, you can now scrol your app and it works perfectly ) I have just tried it and it does work.
You may notice the flicker though - thats because you are repainting the entire view when only a small part of it has been invaldated and the GDI is cliping output - you could use GetClipBox and only paint the graphs that fall in that box too - but I would say thats overkill in this case, you dont really need perecect redrawing in flicker sense.
Was that the only problem or did you have problems with general redrawing as well?
|
|
|
|
|
Hi Diddy,
You are right, it works! Thank you very much!
This is the only redrawing problems I had. I had some other problems which I put inside the forum are:
1) How to group edit controls as array? (as you can see my program is very long)
2) How to add new database record? (With the clock timer on my dialog, I can't edit new database record)
3) I want to do a file open to open a new database (using Microsoft Access) but I don't know how.
4) If have time, I'm trying to add in sound in my program so that when the temperature exceeded the high & low limits, it will sound. With the small graph blinking.
P.S.: Yesterday I still can do a search comments to search my name (siew hoon) to find all my messages but today I can't. How can I find my message
Best Regards,
Siew Hoon
|
|
|
|
|