|
How would I pass the name of typedef which is stored in string variable as a parameter to an function which accepts the typedef data type?
For Example:
Name of the typedef is CODE, so the function will be called like this MyFunction(CODE).
What I'm trying to do is store the typedef name in string variable StrCode then call MyFunction((Type cast) strCode).
Question is how do I type cast the string variable to typedef in this suitation, I tried using reinterpret_cast, but it did not work.
|
|
|
|
|
This is called run-time type information (RTTI) and C++ generally isn't designed for it. The main reason was IMHO that well-designed program can do without RTTI, and accomplish this features by polymorphism etc. But, especially when you read objects from stream, RTTI is necessary.
VC provides the typeid operator and type_info class, but this is a nonstandard C++ extension. And it can be used only for opposite direction (convert typename to string).
So you probably have to write your own class, which manages a mapping from strings to typenames. Various libraries uses various techniques for RTTI. MFC does it through a massive macro gymnastic; a month ago I made RTTI for a particular purpose via templatized class factories...
These techniques are quite complicated to describe it here, so I could send you some tips by email. I don't know about any standard technique, but I'm quite interested about it. If there's anybody, who knows more, let me please know, we can discuss
Robert-Antonio
"Friends come and leave, but teddybears stay in forever."
|
|
|
|
|
|
Thank you very much, that was of great help!
|
|
|
|
|
http://www.codeproject.com/managedcpp/adonetinmfc.asp?target=ado%2Enet%7Cmfc
I did the same way as the above article said. I want to use the CTreeCtrl instead of CListCtrl. but I got the following errors and don't really know why i got those errors
<br />
An unhandled exception of type 'System.TypeLoadException' occurred in proj1.exe<br />
<br />
Additional information: Could not load type _TREEITEM from assembly proj1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.<br />
please help me
|
|
|
|
|
I am using Visual C++ 6 on Windows XP Professional.
I am busy writing an Application Wizard. On two of the dialogs I have an edit control that must initially must be displayed as disabled. After the user makes a certain selection then the edit control is enabled.
I have tried using GetDlgItem() and a cast to CEdit followed by called ModifyStyle on the CEdit control with WS_DISABLED as the first parameter and NULL as the second. However when it comes time to enable the control, it doesn't appear to be enabled even though one can enter text into it.
Help!! Any ideas?
I am the handsome one in the crowd.
|
|
|
|
|
For CEdit, have a look at CEdit::SetReadOnly, and for the other controls, CWnd::EnableWindow.
To get the control, GetDlgItem should work.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
I have an MFC application that has several buttons on it that correlate to a counter being increment on a standard left click. I was wondering if there was a way to differentiate between a left click and right click. If so the left click would incremente the counter while the right click would decrement the counter. I know how to do this in C# but sadly not in MFC.
Thanks
There are 10 kinds of people in those world. Those who understand binary and those who don't.
|
|
|
|
|
WM_LBUTTONUP & WM_RBUTTONUP may help you someway.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible
Prakash,
India.
|
|
|
|
|
Hi,
how to generate random. random number value lies between particular range. any one help to me. thanks in advance.
Have A Nice Day!
Murali.M
|
|
|
|
|
int k;
k = rand() / n;
Have A Nice Day!
Murali.M
|
|
|
|
|
|
you can try this
int min=10;
int max=30;
int randno = min + Rand()%(max-min);
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible
Prakash,
India.
|
|
|
|
|
You'd need to use min + rand()%(max-min+1) , otherwise, 30 would never appear in the result set.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanx
Prakash,
India.
|
|
|
|
|
Hi all,
How I can make a win32 Callback function as a data member of my class?
I tried it making a static function but then i can't acess the data memeber of my class.The callback function is keyboard hook proc function?
<br />
class MyClass<br />
{<br />
static LRESULT CALLBACK MyKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);<br />
}<br />
<br />
Myclass::MyClass()<br />
{<br />
m_Hook = SetWindowsHookEx(WH_KEYBOARD,MyKeyboardProc,NULL,GetCurrentThreadId());<br />
}<br />
Any idea?
Thanks in advance.
Abhishake
|
|
|
|
|
|
Hi Hspc,
thanks for reply. The link which you have send primarly talks about making the callback function as a static member function of class but what if I want to access the class data members. any pointer to that will be a valuable inputs.
Again thanks in advance,
Abhishake
|
|
|
|
|
the reason it is a static member is obvious if u think about it a little bit ... a callback that u register with the system cannot be duplicated everytime u instantiate a new object of the type ... if it were then which actual function would the system call as the callback?
HTH
"there is no spoon" biz stuff about me
|
|
|
|
|
Hi:
I make a programme based on IWebbrowser, and I want to insert a script to the htmlpage loaded by my programme.(the script maybe looks like:
...
)How could I do?
I find a article "http://www.codeguru.com/ieprogram/HtmlMemory.html" .It tells us how to modify the content of the SCRIPT,but didn't tell how to add to "SCRIPT" tag to the htmlpage.
Thanks
Benben
|
|
|
|
|
You would add a <script> tag just like you would any other tag.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks,
Could you tell me how to add "script" tag? I try IHtmldocement2::createElement, but it doesn't work?
Thanks
Benben
|
|
|
|
|
Hi!
What does &255 do?
I have microseconds in 6 integers, and will place them in a 3 byte unsigned char[3] = {1, 2, 3};
I'm trying to use &255, but it doesn't work so well.
Can someone help me with my problem?
|
|
|
|
|
It's the bitwise AND operator, which in this case, is ANDing with the value 255.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi! I'm new to programming in VC+++, maybe someone here could help me out.Im using an 'InvalidateRect' in my application's 'OnIdle' message handler and it is returning an error.
here is the code :
InvalidateRect( hwnd, NULL, TRUE);
and the error:
hwnd : undeclared identifier
hwnd seems to be a pointer to the main window? do I have to define it?
|
|
|
|