|
Thanks for your response. Can you please also tell me that how can i use the operator BSTR of your class. Example if i have string
std::string strName = "Jim";
BSTR bstrName;
Now please tell me how i use your class to copy my std::string in BSTR.
Thanks.
|
|
|
|
|
std::string strName = "Jim";
BSTR bstrName;
MyString s;
s.get() = strName;
bstrName = s;
Thats it. But before you go using it, you should definitely read up on C++ operator overloads and conversion operators. COnversion operators are what allow you to do what we did above in the line:
bstrName = s;
Basically the compiler sees you have a conversion operator for the type of the assignment (in our case a BSTR) and then calls it for you.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Hi,
I have a Application which uses a user-defined Dll.This Dll has many String constants defined in DLL resource string table.My problem is that I want to use that StringConstants ID defined in Dll in the main application..
So any idea ....how to do it.
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
The first parameter to LoadString() is the instance handle of the resource DLL. For example:
HINSTANCE hInstance;
TCHAR szBuffer[128];
hInstance = LoadLibrary(_T("MyResourceLib.dll"));
LoadString(hInstance, ID_MSG_SOMESTRING, szBuffer, sizeof(szBuffer));
|
|
|
|
|
Hi professionals!
Where can I download DirectX 8.1 debug symbols of Visual C++ 6(SP5)?
John Seo(seojt@kogsoft.com)
|
|
|
|
|
Is it possible to download the DDK for Windows 2000 (Driver Development Kit)
from somewhere?
Microsoft distributes it on CD.
I could not find a link for downloading.
Thank you in advance,
seval
|
|
|
|
|
|
Hello,
I use "CreatePopupMenu()" to display a menu with right mouse click on a button.
This is an "ownerdraw" menu, so I draw bitmaps and I write text into each line.
My problem is there are too many lines to display. So I would like to add a vertical scrollbar into the popup menu.
|
|
|
|
|
Hi, I need my CListView derived class to have its horizontal scroll bar always visible (sometimes, of course, disabled). I tried following code:
BOOL CFileView1::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
__DWORD newStyle = dwStyle | WS_VSCROLL;
__return CWnd::Create(lpszClassName, lpszWindowName, newStyle, rect, pParentWnd, nID, pContext);
}
but with no effect...
Will somebody help me?
Standa.
|
|
|
|
|
Hi Standa,
DWORD newStyle = dwStyle | WS_VSCROLL | LBS_DISABLENOSCROLL;
return CWnd::Create(lpszClassName, lpszWindowName, newStyle, rect, pParentWnd, nID, pContext);
May help you.
Best of luck
KVRN Kiran Kumar.
|
|
|
|
|
CFileFind won't help you much there. You will have to look into clipboard formats, specially CF_HDROP. Check out this MSDN article[^] for example.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi, everyone!
I have only noticed that reference variable are used as
parameter of a function before (or return value). For
example,
Source Code:
--------
function (const T& t)
--------
But today when reading the source code of some other's
today. I noticed that a local variable is declared as
reference type. Before I only noticed that lcoal variable
are used as pointer to origin type and origin type.
Source Code:
--------
T *pt;
T t;
--------
But now I noticed that a variable is declard like this in a
function,
Source Code:
--------
T t1;
T & t2 = t1;
--------
I want to know if a reference is used as a local variable, are there
any special things to notice? Or simply just the same as the reference
variable of a function parameter?
Thanks in advance,
George
|
|
|
|
|
In the second way of usage, references are merely a convenient way to designate other variables much the same way as pointers do, but without the -> mess. You only have to keep in mind a subtle but important difference between references and pointers. Consider the following:
T t1;
T t1b;
T * pt2=&t1;
pt2=&t1b; The same cannot be done with references:
T t1;
T t1b;
T & t2=t1;
t2=t1b; The last sentence does not make t2 "point" to t1b : instead, it copies t1b into t1 , exactly as if you had wrote
t1=t1b; In C++ jargon, this fact is commonly expressed as references do not rebind. Keep it in mind and be happy.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddy!
George
|
|
|
|
|
Hi ppl
well my problem is with explicit linking here.Actually there is this function called "SetLayeredWindowAttributes" that i want to link explicitly following is the code:
typedef BOOL (CALLBACK*LPFNSETLAYEREDWINDOWATTRIBUTES)(COLORREF,BYTE,DWORD);
...
BOOL CMainFrame ::TranparentWindow()
{
HINSTANCE hDLL; // Handle to DLL
LPFNSETLAYEREDWINDOWATTRIBUTES lpfnSetLayeredWindowAttributes; // Function pointer
COLORREF color = RGB(100,100,100);
BYTE alpha;
DWORD what;
hDLL = LoadLibrary(_T("USER32.DLL"));
if (hDLL != NULL)
{
lpfnSetLayeredWindowAttributes = (LPFNSETLAYEREDWINDOWATTRIBUTES)GetProcAddress(hDLL,"SetLayeredWindowAttributes");
if (!lpfnSetLayeredWindowAttributes)
{
// handle the error
FreeLibrary(hDLL);
return FALSE;
}
else
{
// call the function
BOOL status;
status = lpfnSetLayeredWindowAttributes(color,alpha,what);
}
}
}
I am calling this function on the OnCreate message handler there are no linker problems as well when the program is executed it give me an error regarding ESP tellimg me something about conflicting calling conventions anyone having any idea wats the problem here please do tell me
Thanks in advance
Ahmed Ajmal
|
|
|
|
|
Seems you're missing the first parameter (an HWND ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone!
I think my knowledge about interface of C++ is not enough.
So, I want to learn some online tutorials. I have used
Google to search "interface tutorial", but fail to find
any useful materials.
Can anyone tell me where can I find some tutorials on how to
use interface of C++?
I want to know basic ideas and experience and tricks about
interface of C++.
Thanks in advance,
George
|
|
|
|
|
Hello,
I have a class and I want to override its [] operator. So I did like this:
int operator [] (LPCTSTR x)
{
.....
}
Now I want my operator to return long, doubles, strings etc. I don't want to manually write dozen of operators, but handle it with templates:
template <typename T>
T operator [] (LPCTSTR x)
{
T t;
....
return t;
}
This complies fine. My problem is that I don't know how to call my template operator. I tried:
MyClass m;
m["str"]<int>;
m<int>["str"];
m.operator <int>[] ("str");
but all I got were compiler errors.
Any ideas?
Thanks
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
The syntax for calling your templatized operator is as convoluted as it can get:
m.template operator[]<int>("str"); Unfortunately, VC++ 6.0sp5 does not swallow this (don't know for other MS compilers). An alternative, that also simplifies notation, is as follows:
template <typename T>
struct Type2Type
{
typedef T type;
};
struct MyClass
{
template <typename T> T operator () (const char * x,Type2Type<T>)
{
T t;
...
return t;
}
};
int main()
{
MyClass m;
m("str",Type2Type<int>());
m("str",Type2Type<double>());
return 0;
} This solution alas drops the nice [] notation in favor of simpler parentheses, but I don't think you have a better alternative.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have written a dll (which suppose to be used by VB) to wrap/hook to
another third party dll (which cannot be used by VB - source code is not
available). Inside my dll program, I use run-time linking (loadLibrary) to
load the third party dll. When my dll program use the 'GetProcAddress' for a
function, the OS detect an unknown error, and the program is closed
automatically.
example:
typedef int (*ReadInfo)(LPSTR,UINT);
HMODULE hinstLib = LoadLibrary("C:\thirdparty.dll");
if (hinstLib != NULL)
{
ReadInfo proc_Query;
proc_Query = (ReadInfo) GetProcAddress(hinstLib,
"ThirdPart_ReadInfo");
.......
}
Finally, I found out that if I add one line 'Sleep(50)' before the
'GetProcAddress', the program run smoothly.
typedef int (*ReadInfo)(LPSTR,UINT);
HMODULE hinstLib = LoadLibrary("C:\thirdparty.dll");
if (hinstLib != NULL)
{
ReadInfo proc_Query;
Sleep(50);
proc_Query = (ReadInfo) GetProcAddress(hinstLib,
"ThirdPart_ReadInfo");
.......
}
Does any one know the cause of the problem? and how do I solve it in a
better way? (Giving a delay 'Sleep(50)' is not a good soultion)
Thanks!
|
|
|
|
|
Hi all,
When I choose both Auto Arrange & Ascending Sort styles, the List control seem to be not sorted right?
What's wrong? I want my list control is auto arranged and ascending sort based on Item text? How can I do?
Thanks in advanced.
|
|
|
|
|
I want to change the color and the shapes of the scroll bar in the edit box! how should i do! Please help!
If you have the similar sample about it . Please send me!
|
|
|
|
|
You can change the color with the SetSysColors method.
-Nick Parker
|
|
|
|
|
|
QUESTION 1: We are convinced that those students who do well on quizzes will do well in the class. Therefore, we want to compute a final average that is limited to those students who did well on the quizzes. Suppose there is a file named grades.txt in the current directory containing grades for all of the students in ECE 1331. Each line in the file has 9 values, separated by spaces: the first 8 values are the quiz grades for a student, while the 9th value is that same student's final grade in the class. There is one line in the file for each student. Give the MATLAB commands you could put in a script file to read in the file and then compute and display, properly labeled, the average of the final grades made by only those students who had a grade of 85 or more on at least 6 of the 8 quizzes. For example, if only 30 of the students made 85 or more on at least 6 of the 8 quizzes, then you would compute the average of the final grades of just those 30 students and display it. Remember to use loops and not array operations! .
QUESTION 2: Write the Matlab code segment that uses a while loop to determine how long it will take to accumulate $1,000,000 in a bank account if you deposit $5,000 initially and $5,000 at the end of each year; the account pays 8 percent annual interest. The annuity formula is given as follows:
FV = PMT(1+i){(((1+i)^N)-1)/i}
where FV is the final value, PMT is the payment amount you add every period, i is the interest rate in percent per period, and N is the number of periods.
Your code should output the result to the command window. Label which parts of your code are:
pre-loop initialization
loop control
loop body
post-loop cleanup
|
|
|
|
|