|
In fact there's a fault in my codes when dynamically loading GetModuleFileNameEx(). But Ive corrected it. So it can perfectly run now. What I need to do now is just to add exception handlers. Thank yall.
|
|
|
|
|
Has someone the same problem with the listbox after a security update?
1) No focus frame is displayed:
A CListBox does not display the dotted focus frame rectangle if a list
box item is left clicked with the mouse the first time. The focus frame
is not displayed even when navigating with the up and down keys.
2) In the following scenario two focus frames appear:
- Enter the list box with a left mouse click on the first list box item
for the first time.
- Then move e.g. 3 items down (the focus frame rectangle is not shown)
- Now press the ALT-key
- Move one item down
-> Result: two focus frames are displayed in the list box.
All is fine if
- you enter the list box with a key e.g. TAB-Key for the first time.
- if you enter the list box with a mouse click for the first time and
then press the ALT-key.
The Problem was introduced with a new shlwapi.dll on Feb. 2010.
MS10-007 update from February 9, 2010
http://support.microsoft.com/kb/975713
I created a simple MFC dialog demo application with C++ VS2005
with a CListBox in a dialog (with all properties of the list box set to
default) and added a few strings in the function OnInitDialog.
If I copy the old shlwapi.dll (6.0.2900.5512) to the demo dialog
directory the focus frame of the list box works as expected.
The new shlwapi.dll (6.0.2900.5912)
Andreas.
|
|
|
|
|
Hi!
I've defined two classes. I've used the object of the first class inside the second class and the object of the second class inside the first class. I've forward declared both the classes. But I got the following error
error C2061: syntax error : identifier 'initialMenu'
My Code is:
class InitialMenu;
class PlayMenu;
class InitialMenu : public IEventReceiver
{
private:
SAppContext &Context;
PlayMenu *playMenu;
public:
InitialMenu(SAppContext &context) : Context(context)
{
}
virtual bool OnEvent(const SEvent& event)
{
playMenu = new PlayMenu(Context);
return true;
}
};
class PlayMenu : public IEventReceiver
{
private:
SAppContext &Context;
InitialMenu* initialMenu;
public:
PlayMenu(SAppContext &context) : Context(context)
{
}
virtual bool OnEvent(const SEvent& event)
{
initialMenu = new initialMenu(Context);
return true;
}
};
How to resolve this error?
|
|
|
|
|
You should split the class declarations into header files and class definitions into CPP files.
|
|
|
|
|
If you look at the line that the error refers to you may notice the incorrect constructor call thus:
initialMenu = new initialMenu(Context);
It's time for a new signature.
|
|
|
|
|
Good spot - I'm surprised that he's not getting an error message about trying to create a PlayMenu when the class has been declared but not defined but I completely missed the typo.
Cheers,
Ash
|
|
|
|
|
As you said in a previous post: "who teaches this stuff?".
It's time for a new signature.
|
|
|
|
|
Without knowing which line the error happened at it's a bit hard working out why you're getting that error.
Having said thay if you implement your classes the way you do within the same translation unit you'll never get it to work - you've got a cyclic depenedency between the two clases. Each has to know the size of the other to be able to create instances of the other. Split them up into pairs of .h and .cpp files and it'll have a better chance of working.
Oh, and remember to implement destructors or use some sort of resource management class instead of the pointers. And beware of any class that calls itself a context (or manager) they're usually global state in disguise.
Cheers,
Ash
|
|
|
|
|
I think your spelling wrong:
virtual bool OnEvent(const SEvent& event)
{
initialMenu = new <big>initialMenu</big>(Context);
return true;
}
virtual bool OnEvent(const SEvent& event)
{
initialMenu = new <big>InitialMenu</big>(Context);
return true;
}
|
|
|
|
|
Sorry for my spelling.^_^
|
|
|
|
|
dear radha,
can you please consult MSDN and google, before posting your query here!, if you type C2061 in MSDN, it will let you know, why it's throwing the error!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi All,
I have a scenario where I need to implement something like what setjmp does. I am well aware of using the setjmp API but the problem statement requires this to be implemented in a different manner.
I have a variable that would store the address of the next function to be called. This variable could be passed as a parameter to another function and to another one from that function and so on...
For this I will need the address of the function that is currently executing and the address to which I want to jump to. Any ideas on how can I read the addresses or implement this?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I do not understand why you want the address of a function at runtime.
You could simply store the addresses of all available functions in a pointer array and use that array in code.
|
|
|
|
|
How do I store the addresses of functions?
These functions may also be defined in different files across the applications code.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
If you have a function -
void fun() {}
you can take its address as -
void* funptr = fun;
|
|
|
|
|
Thanks for that .
But I have a different issue over here. With all the functions loaded into the memory and millions of LOC I doubt this to be a feasible solution in my case.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Why do you need the address of the function that's currently executing? When a function returns you end up back at where you were executing before. So if I have a function pointer (declared as void (*function_pointer() ) and call it:
function_ptr();
when whatever function the pointer points to returns you'll be back executing the next statement in the calling function.
Incidentally a lot of finite state machines use the technique of storing their states as a function pointer, at least when implemented in C. It might pay to do some research on them - they may hold the key to what you want.
Cheers,
Ash
PS: If you're using C++ you don't want a function pointer, look at using an interface pointer instead.
|
|
|
|
|
I will explain the situation.
File A.cpp:
jmp_buf buf;
void func1()
{
cout<<"abc";
longjmp(1,buf);
}
void func2()
{
cout<<"def";
}
int main()
{
if (!setjmp(buf))
func1();
else
cout<<"Do nothing";
}
In this case I am able to do the navigation from func1 and back to main. Just like we do for a LABEL and GOTO case but this happens across function and file calls as well.
In my case I have another file say DEF.cpp wherein resides a function called CallMe
I am able to make the call to that function as well from main. but if I want that CallMe should call another function then I should also return back to the main function, for which I would need the address in the call stack to which I want to return to.
Let me know in case I have misunderstood something
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Ah, I see what you want to do and now I see it I don't think it's a good idea in C++. setjmp and longjmp have so many problems in C++ that if you think you understand the complexity of using them you're usually wrong. You'd have all the same problems (what destructors get called, what happens if an exception is thrown which are undefined by the standard) with any hand rolled system you come up with.
Cheers,
Ash
|
|
|
|
|
Thanks for your inputs. I have already done some investigation regarding the use of setjmp and longjmp and the other overheads underlying their usage, but still just wanted to get a second opinion before I throw it away...
Thanks again.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
HI,
Is there a mechanism in C++ apart from GNU where we can get the address of a label. I noticed in GNU compiler there is an operator '&&' (ITS NOT AN AND OPERATOR) ex:void *ptr;
...
ptr = &&foo; //(where foo stands to be the name of a label)
prefixed to the name of the label to get the address.
Can we do something like this on the visual studio compiler.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
&& refers to an R-value reference, it's not the sort of thing you're looking for.
You really ought to get yourself a good book on C++. Yes, there is an operator for getting the address of an object in a C++ program, it's the unary & operator. So:
int *p = &n;
assigns the address of the variable n to the variable p.
Cheers,
Ash
|
|
|
|
|
Ah! I specifically mentioned that this operator was on C++ for the GNU compiler. Probably you missed it, it does acquire the address of the label using "&&" but it is not there in C++ with the VS compiler.
This link[^] states the implementation and yes I have read a few books but none of them explains this concept for VS
I am a HUMAN. I have that keyword (??? too much) in my name........
_AnsHUMAN_b>
|
|
|
|
|
&& is an operator supported by g++ 4.1 and later and VC++ 2010. It might have been something vendor specific in earlier versions - I can't comment as I try and avoid anything outside of the C++ standard as it's not portable.
You can read more about r-value references here[^].
Cheers,
Ash
|
|
|
|
|
Why don't you use c++ exception semantics?
It might be as below.
struct TException;
void func1()
{
cout<<"abc";
throw new TException("func1");
}
void func2()
{
cout<<"def";
}
void main()
{
try {
func1();
}
catch (TException* e) {
e->printSomthing();
delete e;
}
catch(...) {
cerr<<"general exception which I dont know"<<endl;
}
}
|
|
|
|