|
|
Absolutely.
You could also go
return method1();
at the end of method2 if you wanted to. It's completely available to you.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
|
This Visual C++ is rather strange to me and I like to know about pointers... I´ve been working with Visual C++ only a two months and now this hole thing is just banging the head in the wall... So how these pointers are used? Meaning that where you construct the pointers and when you use them?
There were before a question, where somebody disclaim a working with directories etc. And there is pointer
pListoBox-> How you generate this kind of pointer in the code? Here is code which I copy / pasted earlier discussion (This code is written Carlos Antollini):
while(haveFile)
{
havefile = finder.FindNextfile();
if(finder.GetFileName().Find(".") == -1 && !finder.IsDirectory())
pListBox->AddString(((LPCTSTR)finder.GetFileTitle());
}
|
|
|
|
|
Pointers can be used anywhere in the programs you write. These are to save memory on startup and are faster to access and easier passed between methods.
We can allocate memory, use the resources, & deallocate the memory, keeping our system in good shape.
So, if we had.
someFunction() {
CListBox myListBox //Allocate memory on stack.
myListBox.AddString(""); //Call method.
}//Object destroyed on exit (out of scope).
or we could have
someFunction() {
CListBox* pListBox = new CListBox; //Allocate memory on stack.
pListBox->AddString(""); //Call method.
delete pListBox; //Destroy memory, give the system back the memory on the heap.
}
We can easily pass our pointers to other functions, saving time, no overhead in copying objects, copy by reference or copy by value, value is slower.
Hope this helps a bit....The best way to get experience with pointers is to use.
Gerry.
|
|
|
|
|
I think you can go read "A Beginner's Guide to Pointers"
which written by Andrew Peace. You can find this article in this site, it is quite helpful.
http://www.codeproject.com/cpp/pointers.asp
Hope this can help you...
|
|
|
|
|
Thanks for advises! I go and look that article...
And thanks very much of that code before, it clears also this thing much!
|
|
|
|
|
Thanks for advises! I go and look that article...
And thanks very much of that code before, it clears also this thing much!
|
|
|
|
|
I will look that article and thanks also that code, it helped out for understanding pointers!
|
|
|
|
|
I'm writing program about database.
In my database i have 3 tables:
CDINFO, PERSON, GETGIVE
And i have 3 fields in CDINFO table:
FILMNAME ---> Text
FILMCODE ---> Integer
COUNT ---> Integer
I'm using of three objects of CDaoRecordset for opening each table ...
Now, i want to add new record in CDINFO:
COleVariant var;
char *szFilm = new char[50];
var.vt = VT_INT;
GetDlgItemText(IDC_EDIT1, szFilm, 50);
var.intVal = GetDlgItemInt(IDC_EDIT2);
m_rsCDINFO->AddNew();
m_rsCDINFO->SetFieldValue("FILMCODE", var);
m_rsCDINFO->SetFieldValue("FILMNAME", szFilm);
m_rsCDINFO->SetFieldValue("COUNT", var);
m_rsCDINFO->Update();
SetDlgItemText(IDC_EDIT1, "");
SetDlgItemText(IDC_EDIT2, "");
delete[] szFilm;
This code have not any error or warning, but when i'll running this code, program indicate to me error about: "Out of memory" !!!
Please tell me, what is my wrong ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Not sure, but can you not run BoundsChecker against it, to identify any memory leaks.
Gerry.
|
|
|
|
|
I use several dialogs in my project that are hosted in a splitter pane. The dialogs are created with new and create. They show up normal. Then I like to put them in a list or assign it to a general member. Something like this:
In some class:
CWindow * m_pWindow = NULL;
In another class:
CLocProp *pdlgProp = new CLocProp;
pdlgProp->Create(m_hWnd);
// here pdlgProp is send with sendmessage as a LPARAM (pointer is casted)
// in the class with the messagehandler:
m_pWindow = (CWindow*) lParam;
delete m_pWindow; // Debug assetion that this pointer is not valid
In the good old MFC days this was not a problem. With all the template stuff it gets difficult to hold a grip of this Windows stuff. Is it save to cast it to a CWindow*? If not, how should this be done? What if I want to put dialogs of a different type in a list. Then I need a common base class (CWindow).
Also, if I don't send the dialog through the lParam parameter, An assign it to CWindow* directly after its creation and then delete it, I also get the assertion.
Please help!
|
|
|
|
|
What can I do to reconstruct the project ????
|
|
|
|
|
You don't need the dsw file to open a project. If you still have the dsp file (the actual project file), open that instead and a new dsw will automatically be generated.
--------------
"Aagh!! I'm a victim of a Random Act of Management!"
|
|
|
|
|
|
Do you get "Out Of Memory" when you open the project file? Maybe you are just running too many apps at the same time...?
Try to shut down VC and delete all auto-generated files in the project dir(after backing them up, of course;) ): dsw, clw, aps, ncb, opt, plg etc. Also delete all temporary files in the Release & Debug directories. Then open the dsp and recompile. This usually helps when VC starts acting strange...
--------------
"Aagh!! I'm a victim of a Random Act of Management!"
|
|
|
|
|
You rescued me !!!!!
|
|
|
|
|
I'm sure this question has been asked and aswered before, but I couldn't find it. How do I set the color of the text in a static text box?
Thanks!
|
|
|
|
|
Override WM_CTLCOLOR for the CStatic.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
When I set the m_strFilter on an SQL query as
m_pSet->m_strFilter="[MyStringField] ="+"'"+MySearchString+"'";
Everything work great unless there is an apostrophe in MySearchString. Then the Jet engine coughs and sputters to a halt.
Any ideas on how to handle CStrings with single qoutes in them?
Richard
|
|
|
|
|
CString str ="[MyStringField]\" + "MySearchString + "\"";
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
I'm a little confused, maybe someone can point me in the right direction. I have never done bitmaps in win32 apps before, and no I don't mean I've never put a bitmap in a dialog, or toolbar, I mean displaying on the actual app. I need help because I have a project due in a week or so, and need to display a certain bitmap in the app. Yes, I took training, but you tend to forget what you don't need over the years, and I need to know what header file to insert into the main program source file. I REALLY NEED HELP ON THIS ONE.
"The world doesn't care about your self esteem. The world expects you to get something done BEFORE you feel good about yourself." ~ Bill Gates
|
|
|
|
|
|
Hi,
I want to learn how to create a toolbar which docks on the desktop, similar to the LiveTask bar used with Creative Soundblaster products. I want to be able to autohide, and add other menus / controls to it. The thing i have in mind is also similar to the office startup toolbar or even the windows start menu bar that pops up at the bottom of your screen.
Whats it called and where can i find some sample code / further reading ?
Thanks
Jase
|
|
|
|
|
You want to read this article,
Shell application toolbars.
http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/s274.htm
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|