|
Use the following files
#import "E:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE11\\mso.dll" \
rename_namespace("Office") named_guids
using namespace Office;
#import "E:\\Program Files\\Microsoft Office\\OFFICE11\\msoutl.olb" \
rename_namespace("Outlook"), raw_interfaces_only, named_guids
using namespace Outlook;
cheers
Ganesh
ganesh.takawle@solversa.com
|
|
|
|
|
I have build an activeX controller in ATL VC++ that uses a window and shows camera captured frames, it works well in VisualC environment.
In Visual Basic 6, however, When I tried to integrate the control into a project, it was loaded ok but when I tried to save or run the project, I got a system Error
&H80004005 (-2147467259).
When I tried the same under .net environment, this problem didn't appear.
DO you have any idea what can be the problem or how can I debug it ?
Thanks
Amos.A
|
|
|
|
|
Hi
Can some one help me. I need to make a window with multiple viewports like in 3DS MAX, using WTL. Each viewport must be rendered with OpenGL.
|
|
|
|
|
Hi,
I want to use the string argument in switch case statement. Can you please give some sample program.
Thanks
|
|
|
|
|
itkid wrote:
I want to use the string argument in switch case statement.
Not possible in C and C++.
|
|
|
|
|
switch only works with integer types (char, short, int, long)...
to use strings, replace the switch with if... :
CString str;
ReadString(str);
ASSERT(!str && !str.GetLength());
<font color=blue>if</font> (!strcmp(str, <font color=gray>"string1"</font>)) { <font color=green>
<font color=green>
}
<font color=blue>else if</font> (!strcmp(str, <font color=gray>"string2"</font>)) { <font color=green>
<font color=green>
}
<font color=blue>else</font> { <font color=green>
<font color=green>
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
description:
I made a dll(ATL-base) that recognize the text "Hello" when I click the mouse right button on the Internet Explorer.
I already add a my menu to context menu. If I select it something happen.
my goal:
Now I want to modify my .dll to recognize the mouse left button.
I need the mothod OnClick event.
So I'm reading the Internet Explorer 5(MS).
In "Sinking Events for DHTML Objects in visual C++" on this book(Thanx to Douglas Troy he recommended the section ),
I want to modify the OnDblClick event to OnClick.
the problem:
class CMfcObjMdlDlg;
class CHTMLDocEvents : public CCmdTarget
{
DECLARE_DYNCREATE(CHTMLDocEvents)
.
.
.
I need to use CCmdTarget ....
It is MFC way. I have to change my dll(ATL-base) to MFC I think.
So I found a reference about that(http://support.microsoft.com/default.aspx?scid=kb;en-us;173974#XSLTH3125121122120121120120[^].
I already applied this method in my .dll.
But failed.. haha(-_-)a
I don't understand some description what it saying..
:::section5:::...entry point is set to wWinMainCRTStartup in the Output category of the Link field in the...
What is wWinMainCRTStartup ?
How do I have to modify and to apply?
:::section4::: what is meaning of _tWinMain function with the following...
I coudln't understand _tWinMain function .
:::section6:::function of a COM interface, window procedure, and exported function
I have to apply the AFX_MANAGE_STATE(AfxGetAppModuleState());.
I found exported function by dumpbin.exe.
What is another thing such as COM interface, window procedure?
please reply to my question~
|
|
|
|
|
When I applied the method of MSDN there was so many errors like atl_cstringex.h(17) : error C2872: 'CString' : ambiguous symbol.
How to change it?
|
|
|
|
|
Just to point you in what may be a better direction....you can sink DHTML events in ATL - you don't have to use MFC...
Here's an fragment of an ATL class implementing event sinks....it actually instantiates the IE control and then handles events in the methods OnMouseOut and OnMouseOver.
class CBrowserView : public CWindowImpl<CBrowserView, CAxWindow>,
public IDispEventImpl<1, CBrowserView, &DIID_HTMLElementEvents2, &LIBID_MSHTML, 4, 0>
{
public:
typedef IDispEventImpl<1, CBrowserView, &DIID_HTMLElementEvents2, &LIBID_MSHTML, 4, 0> HTMLElementEventsSink;
BEGIN_SINK_MAP(CBrowserView)
SINK_ENTRY_EX(1, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS_ONMOUSEOVER, OnMouseOver)
SINK_ENTRY_EX(1, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS_ONMOUSEOUT, OnMouseOut)
END_SINK_MAP()
void __stdcall OnMouseOver(IHTMLEventObj* pEvent);
void __stdcall OnMouseOut(IHTMLEventObj* pEvent);
};
You need to call HTMLElementEventsSink::DispEventAdvise to register your event sink and HTMLElementEventsSink::DispEventUnadvise to unregister your event sink. You pass these functions a parameter, which is the IUnknown pointer of the object whose events you want to handle.
Anyway - hope that helps...
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
sorry to reply lately.
I've just seen your answer.
Thank you for your knowledge
It might be good to try on my program right now!
|
|
|
|
|
i am writting a socket program in WTL.but i find no socket in WTL,
so I make a MFC dll .but it run in error.why?
|
|
|
|
|
I have a .dll that i am writing and cannot use standard MFC classes such as CString to parse a blob of data. So i am using std::string but i have never used this before and am so confused. I need to search a string for a key word. Once i find the keyword, i have to parse the data afterwards to pick out the necessary data that i need.
I am using the find method but just stuck and confused to accomplish my goal. Can anyone offer some examples or help? E.g.
If i have a string that looks like
xxxcdfdftbvbfggbnghghg Name: Todd Shields ccfgfgnfgnrri DOB:091580 hgertrtreggeegegggggggggggg
But i want to get the name and the DOB. There is no standard in terms of how much space is allocated for name or DOB. I just have to find it and get the name and DOB from the string.
Any input is appreciated.
|
|
|
|
|
LCI wrote:
So i am using std::string but i have never used this before and am so confused
This is one good reason to prefer the standard library, you'll know it when you need it
What you really need is regex, I wonder if you're able to use the regex implimentation that boost offers ?
Otherwise :
string s = "xxxcdfdftbvbfggbnghghg Name: Todd Shields ccfgfgnfgnrri DOB:091580 hgertrtreggeegegggggggggggg";<br />
<br />
size_t n = s.find_first_of("Name : ") + 7;
size_t nLast = s.find_first_of(" ", n);<br />
nLast = s.find_first_of(" ", nLast + 1);
<br />
string name = s.substr(n, nLast - n);
This is REALLY fragile. Ideally, you'd know the string that comes after ( ccfgfgnfgnrri in this case ), so you can search for the item AFTER the name, instead of having to count on there being a certain number of whitespace chars IN the name. The date is obviously easier, but either way, CString wouldn't help much, regex is the real way to deal with this.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
This is REALLY fragile. Ideally, you'd know the string that comes after ( ccfgfgnfgnrri in this case ), so you can search for the item AFTER the name, instead of having to count on there being a certain number of whitespace chars IN the name. The date is obviously easier, but either way, CString wouldn't help much, regex is the real way to deal with this.
It looks like the string actually contains key-value pairs. In that case he'd know the next token. BTW, find_first_of, substring, ... are regular expressions translated to human-readable form.
|
|
|
|
|
Sloppy Joseph wrote:
BTW, find_first_of, substring, ... are regular expressions translated to human-readable form.
That's a pretty weird point of view.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Regular expressions are unreadable. That's why every one should be commented. I imagine that if I were writing a regular expression for this I might well come up with comments such as "find first of."
I once had to maintain a Perl script which was a mass of uncommented regular expressions and I've taken a dim view of them ever since. They're very powerful and I should use them more but they're a pain in the neck.
Recently I was trying to do a RegEx search in the VS IDE. My discoveries for this particular RegEX were that:
1. It worked using a tool such as Expresso.
2. I had to change the syntax to get it to work in VS.
3. I couldn't get either the origibal or the changed syntax to work in TextPad.
That's another reason why I hate regular expressions.
Maybe I just don't have the mental make-up to be comfortable with RegEx. Maybe it's why I also hate Perl. It's the only language out of Perl, C, C++, VB (all variants), C#, Java, Fortran, Eiffel, Pascal, Python, JavaScript, that I hate.
Kevin
|
|
|
|
|
Kevin McFarlane wrote:
Regular expressions are unreadable.
As is C++, C# and Japanese, for people who don't know them. I agree that they can take a moment to work through, but they are hardly unreadable.
Kevin McFarlane wrote:
1. It worked using a tool such as Expresso.
2. I had to change the syntax to get it to work in VS.
3. I couldn't get either the origibal or the changed syntax to work in TextPad.
TextPad ? I agree that it's a pain that you need to mangle regex to get it to work in the IDE. But Expresso regex will work in C#/VB.NET code, no hassles. I do it all the time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
C++ and C# resemble something like ordinary English. (Though I'd prefer those languages to be even more readable than they are.) Regular Expressions don't. Mentally you just have to do a lot more work to understand them.
Re: Expresso, I was referring to RegEx search in the Search/Replace dialog. There I found there were differences.
Perhaps it's just a mindset thing. It's probably why I detest Perl. Though it's not just the RegEx why I hate Perl. But I think Perl is one of those languages you either love or hate depending on your mental makeup. My current boss loves Perl. He didn't seem to mind when I said I hated it.
Kevin
|
|
|
|
|
Kevin McFarlane wrote:
Re: Expresso, I was referring to RegEx search in the Search/Replace dialog. There I found there were differences.
Yeah I know. Like I said, I hate that, too.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Great.. thanks for all your input.
I also wrote a small method that will strip all the spaces from the end of an basic_string up until is reaches text.
So a string like "This is a test " .. would be
"This is a test" once the method is complete.
Something is not working correctly though.
typedef std::string::size_type size_type;
std::string AnyString;
char MySpace = ' ';
size_type CHAR_INDEX;
CHAR_INDEX = AnyString.size();//AnyString.rfind(MySpace);
for (size_type i = CHAR_INDEX;AnyString[i]== MySpace; i--)
AnyString.erase(i,1);
The above source only works when stripping one space, like from
"2003 " to "2003".
If i have "2003 ", it does not work. Can anyone tell me what i am doing wrong here?
|
|
|
|
|
LCI wrote:
for (size_type i = CHAR_INDEX;AnyString[i]== MySpace; i--)
AnyString.erase(i,1);
The above source only works when stripping one space, like from
"2003 " to "2003".
If i have "2003 ", it does not work. Can anyone tell me what i am doing wrong here?
You probably want a 'trim_back()' function. It must also work for 'unusual' cases like empty strings and strings that contain only white space. Also note that string::size_type is unsigned (cannot be less than 0).
#include <string>
#include <iostream>
std::string& trim_back (std::string& str)
{
using namespace std;
while (str.size()) {
if (isspace (str[str.size()-1])) {
str.erase(str.size()-1);
} else {
break;
}
}
return str;
}
int main()
{
using namespace std;
string test ("2003 "),
whitespaceOnly (" \n\t"),
empty;
cout << '|' << trim_back(test) << '|' << endl;
cout << '|' << trim_back(whitespaceOnly) << '|' << endl;
cout << '|' << trim_back(empty) << '|' << endl;
return 0;
}
|
|
|
|
|
I recommend you look at boost. I recently installed it and it is a fantastic library. It includes string trimming functions - e.g.:
#include <boost/algorithm/string.hpp>
...
std::string str = "Hello ";
boost::trim(str);
|
|
|
|
|
Try
inline string trim_right(const string& source, const string& t = " ")
{
string str = source;
return str.erase(source.find_last_not_of(t) + 1);
}
inline string trim_left(const string& source, const string& t = " ")
{
string str = source;
return str.erase(0, source.find_first_not_of(t));
}
inline string trim(const string& source, const string& t = " ")
{
return trim_left(trim_right(source, t), t);
}
Kevin
|
|
|
|
|
Kevin McFarlane wrote:
Try
Don't!
inline string trim_right(const string& source, const string& t = " "){
string str = source;
return str.erase(source.find_last_not_of(t) + 1);}
1. You search only for " ", not for white space (e.g. '\t')
2. find_last_not_of() returns npos when no match is found (which is not an appropriate input for erase)
3. You return by value thus duplicating the string unnecessarily.
In sum, your 'solution' is incorrect and inefficient, but fine otherwise.
|
|
|
|
|
I copied the code from somewhere. It seemed to work for me so I didn't check its details. Still, I think a trim function should have been part of basic_string (if only to prevent incorrect implementations like this! ). It's a common enough operation.
Kevin
|
|
|
|
|