|
At what point do you get the compiler error? The line Type m_type; is invalid. You'd have to scope it with Outcome::Type m_type;
Bob Ciora
|
|
|
|
|
I changed it to this but I still get the same error message from gcc :
"error: parse error before `namespace'"
Do you think its a compiler bug or is it just not supposed to be supported? Its a bit weird don't you think considering that a class is essentially a namespace and you can have nested class declarations and nested namespace declarations, but not this way round?
class Outcome
{
public:
enum Type
{
kHalt,
kMove,
kJump,
};
namespace halt
{
void Low(void);
void Medium(void);
void High(void);
};
namespace move
{
void Low(void);
void Medium(void);
void High(void);
};
namespace jump
{
void Low(void);
void Medium(void);
void High(void);
};
Outcome::Type m_type;
};
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
You do not have to qualify type with the name of the class since it is declared inside the class. The original declaration of the Type enumerated variable was fine.
Shawn
|
|
|
|
|
Namespaces can contain classes, but classes cannot contain namespaces.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm guessing its because namespace functions have global linkage within the namespace but by default functions in a class only have local linkage via an object?
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
functions in a class only have local linkage via an object?
member functions of a class receive the this pointer, which allow the functions to point directly the object that is using the function. a particular point is the static member functions -> no this pointer as implicit parameter
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I can think of one reason.
Many classes can belong to one namespace. So by giving 'using namespace' you have access to all the classes that are contained in that namespace.
If what you mentioned is possible, then by giving, let's say, 'using namespace jump', you cannot create an object of class Outcome because all members of the class does not belong to that namespace.
« Superman »
|
|
|
|
|
Hi All,
I am launching many applications from my application in background. Say I launched MS Word. Now, I want the handle of the launched application. I have the handle to the mainframe window of newly launched application. I am able to get the menu pointer using CWnd::GetMenu() from the mainframe pointer. But this works only with the applications like Notepad and Adobe Reader where menu is the intigral part of the mainframe. Applications like MS Word and MS Excel have seperate docking windows for menu. At this time I am not able to get the menu from mainframe.
For such applications what I do is I enumerate all child windows of the mainframe and call GetMenu function on all child windows but still none of them returns me the menu pointer.
I get the handle of the docking menu bar window (This handle is the same I can see using spy++). I call CWnd::FromHandle() funtion to get the CWnd pointer to that window and then call GetMenu() of using that CWnd pointer but it returns me NULL;
Any clues?
--------------
Vaibhav...
|
|
|
|
|
You could try to use GetWindow instead of GetMenu.
« Superman »
|
|
|
|
|
Hey, I want menu handle not the window handle.
|
|
|
|
|
I want to get the handle of the menu and not of the window.
So how GetWindow() will not help me.
--------------
Vaibhav...
|
|
|
|
|
Okay let me tell you why I am doing all these.
We are developing a software which migrates the application specific
properties.
Per say I want to migrate all settings of MS Word from my pc to another pc.
i.e. all those preferences which I have set in my MS Word applications like,
spellings and grammer check, library, languages, margine settings, rulers etc
will get captured through my application and will migrate the same settings
onto another computer.
Now all of these settings are stored either into registry or into some
files. So I want to capture all such registry items and files. But my program
does not know the registry location for a particular application. Most of the
application specific data are stored under
HKLM/Software/Appliication_specific_key. But there is no gurantee that this
Application_specific_key is exactly as the name of the application. So how do
I capture identify the location in the registry which I need to capture. So
what I am doing is I am continuously monitoring registry and filesystem using
regmon and filemon utilities and hitting all menu items which will change
preferences of my application. Because all such preferences would be
accessible through menu only. I dont see any other way of editing the
preferences.
So this is how I go about it. If you have any better suggestion to achieve
the same goal, let me know.
Your help is appreciated in this regards.
--------------
Vaibhav...
|
|
|
|
|
How to automate autocad with VC++
which one to choose MFC/ATL,Autolisp/VC,ObjectARX/any other?
Please Help
|
|
|
|
|
Automation is just a limited part of COM so any programming language will suffice. It all depends on the rest of the application.
Johannes
|
|
|
|
|
I'm trying to use some Excel COM from Visual C++, but am having difficulty calling certain functions. For example, take the WorkSheets.Add method. The function declaration is as follows:
LPDISPATCH Add(const VARIANT& Before, const VARIANT& After, const VARIANT& Count, const VARIANT& Type);
By looking in the Excel VBA Help, I can get documentation for this method:
Add Method (Worksheets Collection)
Creates a new worksheet. The new worksheet becomes the active sheet. Returns a Worksheet object.
Syntax
expression.Add(Before, After, Count, Type)
expression Required. An expression that returns a Worksheets object.
Before Optional Variant. An object that specifies the sheet before which the new sheet is added.
After Optional Variant. An object that specifies the sheet after which the new sheet is added.
Count Optional Variant. The number of sheets to be added. The default value is one.
Type Optional Variant. The sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. The default value is xlWorksheet.
Remarks
If Before and After are both omitted, the new sheet is inserted before the active sheet.
OK, now for some example code. I can add a new worksheet quite easily using the following code:
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);<br />
ws.Add(VOptional, VOptional, VOptional, VOptional
The problem is that this default usage inserts the sheet before all current sheets in my workbook, but I want to insert it after all the other sheets. In Excel VBA, I can do this by simply running:
Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
However, I'm having real trouble finding what the data type of the 'After' argument needs to be in C++ and I can't find any sample code anywhere! I have found hundreds of examples passing numbers or strings, but not objects! Can anyone supply some sample code?
Using the _Worksheet.Move method would also accomplish the same thing, but I have the same problem, so any help would be greatly appreciated!
|
|
|
|
|
Just in case anyone needs to do this, I figured out how to do it. The 'after' parameter needs to represent the IDispatch pointer of the worksheet you want to add the new sheet after. So you have to do something like this:
COleVariant var;<br />
var.vt = VT_DISPATCH | VT_BYREF;<br />
var.ppdispVal = &(objSheet.m_lpDispatch);
// Add the new sheet AFTER the sheet referenced in 'matt'
NewSheet = objSheets.Add(VOptional, var, VOptional, VOptional);
|
|
|
|
|
Hello,
I need to check if a given machine exists on LAN or Not, the only information I can use to call the function is Machine Name nothing else.
Pls Help.
Thanks n Regards.
RuchirDhar Dwivedi
Software Engineer
Windowmaker Software Pvt.Ltd.
Baroda, India.
|
|
|
|
|
you have to make your function that will check for existance of Machine in Network
you can these api to enumerate the Machine on network:-
Use <code>WNetOpenEnum</code> to Open Handle then do
Enumertation by <code>WNetEnumResource</code> finally close
it by <code>WNetCloseEnum</code>
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I copy a .rc file to my program.
However, my funciton could not load the resource.
Such as string,loadstring() return 0.
Where should I reset?
|
|
|
|
|
Did you copy the associated resource.h file also?
« Superman »
|
|
|
|
|
|
the string table of the resource editor associate an ID to a string ; BUT :
.rc file :
IDS_MY_STRING "Hello World\n"
resource.h file :
#define IDS_MY_STRING 1018
(for example)
-> SO, if the ID is not #define d, the resource table don't know it.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
The string has been defined in resource.h file.
Here is the statement:
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
Maybe I should change the hInstance, because these code s are within a dll , not a exe file.
How to get the hInstance of current dll ? Not MFC, but Windows API.
|
|
|
|
|
Is the dll a resource only dll.
You may have to use FindResource or LoadResource.
« Superman »
|
|
|
|
|
Hi,
How can I write a multilanguage application in VB 6, VC6 ?
Thank !
To love in vain more than love no one.
|
|
|
|