|
I don't think I would be able to do that, but I can make a CString that says, for example IDC_STRIPVIEW_DEVICE_3_CHECK_BTN when i=3, but all I need to know how to do is pass that to string to the GetDlgItem function and have it accept it as an unsigned integer resource id.
Adam
|
|
|
|
|
GetDlgItem expects an integer ID. You could map indexes to an array of strings but that just
adds an unnecessary level of indirection since you'd need to convert that string back to an int
to call GetDlgItem. So, you might as well use i to index an array of actual control IDs
(integers).
That brings me back to what I was thinking...
#define IDC_BUTTON1 1000
#define IDC_BUTTON2 1001
#define IDC_BUTTON3 1002
#define IDC_BUTTON4 1003
#define IDC_BUTTON5 1004
#define IDC_BUTTON6 1005
...
for(i=0; i<number of sub entities; i++)
{
pBtn=GetDlgItem(i + BUTTON1);
pBtn->ShowWindow(SW_SHOWNORMAL);
}
-or-
for(i=IDC_BUTTON1; i<IDC_BUTTON6; i++)
{
pBtn=GetDlgItem(i);
pBtn->ShowWindow(SW_SHOWNORMAL);
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
Suppose I have a dll called MyDLL.dll which is statically linked to External.dll . Now I load MyDLL.dll from my application like this:
handle = LoadLibrary("MyDLL.dll");
Now, if MyDLL.dll and External.dll are present everything works just fine and LoadLibrary succeeds (i.e. handle != 0).
When I delete External.dll, then I get this behaviour:
a) In debug mode an error message box pops up saying that External.dll was not found.
b) In release mode I don't get this error message box. handle is simply 0. So I call GetLastError() along with FormatMessage() and get an error code of 126 (specified module not found).
Ideally, I'd like to suppress the message box in a) and get its message string so I can write a more detailed description of the problem into the log. I thought GetLastError() and FormatMessage() would take care of this, but apparently they only return some hardcoded standard messages.
So my primary question is whether there is a way to get this message string somehow?
If there is no way to get the message string, I'd like b) to always display the error message box. According to the MSDN docs ( http://msdn2.microsoft.com/en-us/library/ms680621.aspx ) I need to call something like SetErrorMode(0) ( maybe something like SetErrorMode( SetErrorMode(0) | ~SEM_FAILCRITICALERRORS) ).
This call does not seem to have any effect. The current error mode is 4 ( == SEM_NOALIGNMENTFAULTEXCEPT), but the error message box still does not pop up, it keeps failing silently (handle == 0).
Can somebody help me?
|
|
|
|
|
Nitrogenycs wrote: I thought GetLastError() and FormatMessage() would take care of this, but apparently they only return some hardcoded standard messages.
So my primary question is whether there is a way to get this message string somehow?
If FormatMessage gives you the error string, then I am confused on what other message string you desire to obtain?
|
|
|
|
|
FormatMessage just gives me the error string relating to the error code 126. This is some general message like "Could not find the specified module".
The message box that's popped up shows a more detailed description of the problem, including the name of the missing dll, in this example "External.dll". This is what I really need in order to find the cause of the problem. Sometimes a user misses specific dlls (for example I forgot to include them in the package) or did not have the necessary prerequisites installed.
|
|
|
|
|
Why not just concatenate the string your using for LoadLibrary to the end of the generic message to form your own custom message that tells them exactly which dll they are missing?
|
|
|
|
|
Because the dll being loaded is not the problem. The dll being statically linked to the dll being loaded is not present and is what causes the problem. Actually, the dll being loaded might be linked against several other dlls. And I need to know which of those is missing. Missing dlls are not the only problem, they could also be somehow malformed, so I need to get the actual error message that the windows dll loader gives.
|
|
|
|
|
I'm wondering if there is a way to use the STL map class in such a way that you pass in, say, 4 parameters, the first being a key, and the other 3 being values of any type. What I mainly want is an associative container that is not limited to key/value pair.
Thanks.
|
|
|
|
|
This is easy achieved using an object (e.g. a vector) as the template type of the map.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hmm... now why didn't I think about that...
I like it.
Thanks.
|
|
|
|
|
There is multi_map and multi_hash_map .
|
|
|
|
|
AFAIK, a multi-map is a map, but the keys do not have to be unique. I haven't checked the hash map though.
|
|
|
|
|
Multiple-key map
Maps are a kind of associative containers that stores elements formed by the combination of a key value and a mapped value, much like map containers, but allowing different elements to have the same key value.
From: http://www.cplusplus.com/reference/stl/multimap/[^]
It should let you store multiple values per key, which is what you said you wanted. I've never used it myself, but it doesn't look much harder than a normal map .
multi_hash_map is just the hash_map version of it It exists in the stdex namespace in the VC++ compiler only.
Hope it helps!
|
|
|
|
|
HEllo,
I keep getting linker error "member variable already defined" when I include one file(.h) in two .cpp files.
How should I get rid of this linker error?
I have tried using #pragma once below the file #include "PlanConsts.h"
#pragma once
but still the file is included twice.
Thanks.
Prithaa
|
|
|
|
|
You shouldn't define variables in header (.h) files: only declarations there. Note that #pragma once (as well as multiple inclusion) has nothing to do with your problem.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
prithaa wrote: I have tried using #pragma once below the file #include "PlanConsts.h"
Where did you put this pragma ? Your sentence is not very clear.
The #pragma once must be placed at the top of every header file (*.h).
|
|
|
|
|
create the PlanConsts.h file as this way
#ifndef _PLANTCONSTS_H
#define _PLANTCONSTS_H
...header file contents...
..........................
..........................
#endif
I think this would solve the problem
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Hello,
thanks for all your replies.
I created planconsts.h has you said
#ifndef _PLANTCONSTS_H
#define _PLANTCONSTS_H
...header file contents...
..........................
..........................
#endif
but still I get the linker problem that the "variable already defined"
Thanks
Prithaa
|
|
|
|
|
can u post a little bit of ur code
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Maybe it's because the names you're trying to use for your constants are already defined in a header file that you didn't create. Try doing a search for all instances of one of the named constants. If they only show up in one header file, your #pragma once stuff is hosed up.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi,
I'm doing a project which requires extraction of all the methods and members of a class in CPP files and such similar other informations. One big hurdle is these methods might use values/variables from other modules/classes. so I'm in need of creation of a complete symbol table which is becoming very tough tat can span to those other modules too. can anybody suggest an open source project which has these functionalities, and as well creation of the symbol table wherein I can use these symbols.
I tried with lex/yacc but then the scope of an extraction remains only within a file, else I need to write my own routines to extract the cross module dependency information, which ofcourse due to paucity of time is becoming a foolish decision.
Hope you get my objective. Please help.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
You could try doxygen which can be downloaded from www.sourceforge.net[^] and will have it's own homepage elsewhere as well If you want a simple-ish parser than can handle most C++ stuff.
Alternatively you could just compile the code with Visual Studio, with all the debugging info switched on, and then use Microsoft's own symbol engine in dbghelp.dll to interrogate the .pdb (Program databse) file of the project. WinDbg which is widely available does this.
I recommend John Robbins' book Debugging Windows Applications for all the details on debug symbol information, how to get it and use it.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hi
Thanks for the informative reply. Actually to make things more clear I'd like to say that we are testing a software that has it's build not only in Visual Studio but many other compilers as well(viz. GCC) hence there would be lot of dependcies and as well incompatibilities with other compilers.
It is therefore a need to write our own testing software and that has to have a capability of mainatining a Symbol Table. So the way of proceeding suggested by you is not able to provide me the solution to the problem I'm facing now.
All my objective is to gather and maintain all the methods and variables pertaining to a class / even global that span accross the whole build. Will any exisitn project be able to do this??
please help.
Once again thanks a lot for the reply.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
In that case ripping the parser from doxygen (which I think is pretty cross platform) might be the best way to go but it will be a lot of work. Remeber if you're using GCC it compiles on Win32 as well and you get the source with it which contains a full parser to generate the symbols. You also get GDB the GNU Debugger with it which may give the necessary clues to be able to read and interpret GCCs symbols. Either way it's going to be a BIG project. Good luck with it
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi
I see that CImage is not supported by Visual c++ 6 from the answers that were given to my questions in Code Project forum .Now I want to ask a basic question; Can we add the CImage libraries to Visual C++ 6 manually.If it is possible how can we do that.
Thanks
|
|
|
|