|
There's no difference. I forget the exact legal details but a pointer to a function can be used without having to de-reference it.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Klaus Probst wrote:
Why does this work as well?
Because it's a special case - you don't have to use * when calling a function through a pointer to the function.
Actually, using the * is probably the special case - a function pointer cannot be dereferenced, because a function is not an object. The language allows * to be used on calls thru function pointers in order to remain consistent with all other pointer usages, where * is required to dereference.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks Mike (and Taka!). I figured as much (since it obviously works), but I need to dredge my old C++ reference and take a look at this one a bit more closely.
Thanks again.
___________
Klaus
[vbbox.com]
|
|
|
|
|
IIRC, the reasoning goes something like this:
The name of a function is actually just a pointer to the first instruction of that function in memory somewhere. Kind of like when you declare an array of int's, the variable is actually a pointer to the first element.
So when you call a function foo(), you are just jumping to that particular place in memory. (*pFoo)() "dereferences" that "pointer" but since C++ doesn't really have a concept of a function object, it is taken to mean calling the function as well.
The "hack" in the language is really when you take the address of the function in the first place - we need the & operator to differentiate it from just a plain call to the function.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
My MDI App has two Document Types.
One we can call a workspace.
One we can call a doc.
Ive registered each document type with the application using the framework. I have also added the code that only allows "1" workspace to be opened at a time. I have also destroyed the "view" of the workspace, because I want the data to be displayed in a dockable tree ctrl, which i have also created, and is a member of MainFrame.
My Questions....
How do i get access to the workspace document (the current one) from my tree ctrl.
If I have both a workspace open and multiple "docs", how can I place a call to GetDocument and get only the "workspace" document?
excuse my silly questions, im not experienced with MFC or doc/view. Im moving along though. HELP ME KEEP MY MOMENTUM =)
Ryan Baillargeon
|
|
|
|
|
If there is only one workspace doc then you could do this
POSITION pos = ((CYourApp*)AfxGetApp())->m_pDocTemplate->GetFirstDocPosition();
CYourDoc *pDoc = (CYourDoc*) ((CYourApp*)AfxGetApp())->m_pDocTemplate->GetNextDoc(pos);
where m_pDocTemplate is your workspace template...make it public or add a public function to get a pointer to it
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Hi all,
Can someone tell me how to get the messages from a child window opened with ShellExecute(...) and then respond to them. I tried setting the hwnd parameter to this->m_hWnd from a dialog app.. then i ran a spy++ and didn't see any messages going from the opened web browser back to my dialog app.
example.
From a Dialog app, i'm opening and html page in Internet Explorer and I need the Dialog app to be able to respond to dialog boxes that IE presents , like error messages and such. It sounds like i should be able to from the API docs...
-- MSDN ----------------------------
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
hwnd
[in] Handle to a parent window. This window receives any message boxes that an application produces, such as error reporting.
...
---------------------------------
could someone let me know if my understanding of this is wrong.
Thanks for any help..
Rick
|
|
|
|
|
RickGavin wrote:
hwnd
[in] Handle to a parent window. This window receives any message boxes that an application produces, such as error reporting.
I dont think that'll work when you spawn a new app. This works only for shell commands like "open" and "print". I might be wrong though.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
You are misunderstanding the purpose of the hwnd parameter. When you start a new process, it's off in its own process space, it is not a child of the launching process or its windows. hwnd is only used by the shell if an error occurs. hwnd is one of you windows, which is used as the parent of error dialogs if any are displayed.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks for setting me straight.
Since that obviously won't work, do you know a way to accomplish the task?
i.e. open a browser and then monitor it for any dialogs, and then pragmatically ok or cancel said dialog box, so that the user doesn't have to answer his/her self?
Thanks again
Rick
|
|
|
|
|
Hello,
When ever you save a document it changes the title to saved.doc or what ever the saved name is.. is there a way to prevent this from happening? I need the title of the application to stay the same even after saving.. Its probably an easy one..
Thanks,
Rob
|
|
|
|
|
Use SetTitle() and specify the caption name.
SetTitle is a member function of your document class.
|
|
|
|
|
Where would I put the code.. I have already tried this..
BOOL CMyDocumentDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
SetTitle("My Document");
return CRichEditDoc::OnSaveDocument(lpszPathName);
}
And it doesnt work..
|
|
|
|
|
how about
BOOL CMyDocumentDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
BOOL bRet = CRichEditDoc::OnSaveDocument(lpszPathName);
SetTitle("My Document");
return bRet;
}
I am not sure whether it works or not. I am just suspicious that OnSaveDocument will call SetTitle() automatically.
|
|
|
|
|
nope I think when this function returns the title gets changed..
Thanks though
Rob
|
|
|
|
|
Got it.. Had to over ride the SetTitle and force the name there..
Thanks,
Rob
|
|
|
|
|
I have a member variable declared as:
CArray<cpoint, cpoint=""> m_dotArray;
When I am using it, I use CArray::Add to add new dots to it. But I don't want to add duplicate dot, so I derived CMyArray in the following manner:
template <class TYPE, class ARG_TYPE>
class CMyArray : public CArray < TYPE, ARG_TYPE >
{
public:
int AddThis(ARG_TYPE newElement);
};
template < class TYPE, class ARG_TYPE >
int CMyArray < TYPE, ARG_TYPE > ::AddThis(ARG_TYPE newElement)
{
ARG_TYPE existingElement;
for ( int i = 0; i < GetSize(); i ++ )
{
existingElement = GetAt(i);
if ( existiingElement == newElement )
return -1;
}
Add(newElement);
return 0;
}
but when compiling the following error is reported:
error LNK2001: unresolved external symbol "public: int __thiscall CMyArray < class CPoint, class CPoint > ::AddThis(class CPoint)" ......
What did I miss?
TIA!!
|
|
|
|
|
Is this code visible to your project ? Is it part of your project ?
Have you ever tried std::vector ? Unlike CArray, it's powerful, flexible and does not suck.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
yes, I have added both the .h and .cpp to my project. Also, I have include the header file when I declare the member variable.
I did a few Build->Clean and Rebuild All, in the hope of getting rid of this problem. But without any success.
I didn't know anything about std::vector, I would try to read something about it. Before that, what is the correct way of deriving any class from CArray? I think I am not following the correct syntax.
|
|
|
|
|
If you search for 'vector graus' in the articles you should find my article on vectors.
I don't know how you would derive from CArray. I'd probably try to contain a CArray instead and see if that worked, assuming I had to.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
std::vector - code bloat...
CAtlArray
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
CAtlArray, hmm, I should keep it in mind for future use, since I don't need the serialization function here at all.
Thank you.
|
|
|
|
|
lol - you just don't give up, do you ? I've never used CAtlArray, is it part of WTL ? How complete is it ? That is, does it offer algorithms etc, or is it merely another container of the sort I could write in an afternoon ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
or is it merely another container of the sort I could write in an afternoon ?
For 10 points, explain how a "mere container" is a bad thing.
-c
Please stand by
|
|
|
|
|
I'm with Cristian. std::vector is the way to go.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|