|
|
Does anyone have a sample showing how to lookup the URL to use for exchange web services via the autodiscover service.
|
|
|
|
|
Hello,
I am Loading type library from C++/CLI with following lines of code.
[DllImportAttribute("oleaut32.dll", SetLastError = true, CharSet = CharSet::Unicode, PreserveSig=false)]
static void LoadTypeLibEx( String^ strTypeLibName, RegKind regkind,[MarshalAs(UnmanagedType::Interface)] interior_ptr<Object^> typeLib );
Object^ oTypeLib;
LoadTypeLibEx( strSubject,RegKind::RegKind_None, &oTypeLib);
It again and again giving me same exception, all I have registered type library with regsrv32, placed in current directory and given full qualified path but still its giving me same exception.
Regards
Usman
-- Modified Monday, June 7, 2010 12:52 PM
|
|
|
|
|
Hi,
Did you try to find out if if any dependencies are missing or are out-of-date? As you may know, your library may be in place while some of its dependencies not.
Should you consider to try that, you could use depends.exe from sysinternals
SkyWalker
|
|
|
|
|
Hi everybody. I'm tring to save image form webBrowser control. and i have the following code
mshtml::HTMLDocument^ document = dynamic_cast<mshtml::HTMLDocument^>(this->webBrowser1->Document->DomDocument);
mshtml::IHTMLElementCollection^ collImages = document->getElementsByTagName(L"img");
for(int i = 0; i < collImages->length; ++i)
{
mshtml::IHTMLImgElement^ img = safe_cast<mshtml::IHTMLImgElement^>(collImages->item(nullptr, i));
mshtml::IHTMLElementRender^ render = dynamic_cast<mshtml::IHTMLElementRender^>(img);
Bitmap^ bmp = gcnew Bitmap(img->width, img->height);
Graphics^ g = Graphics::FromImage(bmp);
IntPtr hdc = g->GetHdc();
render->DrawToDC(hdc);
g->ReleaseHdc(hdc);
delete g;
g = nullptr;
bmp->Save(L"C:\\Test\\SaveImage.Jpg", System::Drawing::Imaging::ImageFormat::Jpeg);
}
I get the following error message
Error C2664: 'mshtml::IHTMLElementRender::DrawToDC' : cannot convert parameter 1 from 'System::IntPtr' to 'mshtml::_RemotableHandle %'
is there any one who knows how to fix this?
|
|
|
|
|
Yes, find out what type parameter DrawToDC expects.
It should be in the docs for IHTMLElementRender::DrawToDC.
|
|
|
|
|
Hi,
Ik have a form containing a number of comboboxes, called cmb1, cmb2, etc.
I want to loop through these boxes to set their itemlist. I have tried the following code:
for each (Control^ box in this->Controls){
if (box->GetType() == ComboBox::typeid){
box->Items->Clear();
}
}
This works fine, except that I cannot access the combobox's Items property. I can for instance access the Text property, so I think it's strange that the Items property is missing.
Does anyone have an idea how to solve this?
Thanks!
|
|
|
|
|
The reason you can't access the Items property is because you have declared box as a Control and Control doesn't have an Items collection.
You would have to declare a new variable as ComboBox and cast box into it:
for each (Control^ box in this->Controls){
if (box->GetType() == ComboBox::typeid){
ComboBox^ combo = (ComboBox^)box;
combo->Items->Clear();
}
}
modified on Friday, June 4, 2010 11:46 AM
|
|
|
|
|
Have you tried this code
for each(ComboBox^ box in this->Controls)
{
if(box->GetType() == ComboBox::typeid)
{
box->Items->Clear();
}
}
|
|
|
|
|
voo doo12, I've tried this, but when I run the program I get an error that says: "Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.forms.ComboBox'.
So it seems that if the program encounters a control which is not a ComboBox it cannot deal with it in this way.
|
|
|
|
|
Richard, this makes sense. However, when I compile this code I get:
error C2440: 'type cast' : cannot convert from 'System::Windows::Forms::Control ^' to 'System::Windows::Forms::ComboBox'
Any idea how to solve this?
|
|
|
|
|
Solved!
I made a typo in Richard's code (forgot the ^ symbol in the cast part).
Now it works, thanks a lot for your help!
|
|
|
|
|
Glad to be helpful.
|
|
|
|
|
Hi everyone !
Please help me , because i have a big trouble !!!
I have login form , and i want to open form1 Form from login form.
I tryed use #include "Form1.h" in "login.h" login form where is.
Unfortunately i had problems and many mistakes such like :
Error 198 error LNK2005: "int SymulacjaObiektuSISO::i1" (?i1@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
Error 199 error LNK2005: "int SymulacjaObiektuSISO::i2" (?i2@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
Error 214 error LNK2005: "class std::deque<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > SymulacjaObiektuSISO::nazwyGeneratorow" (?nazwyGeneratorow@SymulacjaObiektuSISO@@3V?$deque@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
and i think this is because of #include files which are in form1.h
unfortunately i can't open form1 from login form : Form1^ test = gcnew Form1^();
i don't know what to do... please help me because i must do this !!!!
How can i resolve this problem ??
Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect.
Plese help me as fast as You can
|
|
|
|
|
the problem come from this -> "Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect."
the include file must be correct utilized cause they can lead to your problem.
in an ideal world you should include the .h files like in a tree:
super_main.h
/ \
main1.h main2.h
/ \
submain1_1.h submain1_2.h
where each .h have one .cpp with the operational code
-- or --
there are some workaround like
#ifndef
#define
....code....
#endif
to make life easier when implementing .h
|
|
|
|
|
Thanks for the reply !
Yes of course I usually write #ifndef ect. definition into header files, but it's not a problem with this... main issue of this is in the namespace... because my major project is in C++ CLI how's You know isn't the same what is pure C++ ( unmanaged probably ) so, i'm not able to declare object of pure class ( example : class Test; and in managed class : ref class { ... public : Test object; ) i understand how can i resolve this problem -> i should declare pointer of unmanaged class : Test *object into managed class. But unfortunately my supervisor ( he hasn't seen my project yet ) wants or requires use auto_ptr ( because of memory leak ) , so i use this "intelligent" pointer in namespace area :
namespace TestSpace
{
auto_ptr<test> object;
ref class ClassTest
{
object->...
};
}
and it works,
but main problem is when i compile this code , and i have main order with header files same to You , 'm receiving information about the same or two definitions ( already defined ). I noticed that i haven't this problem if i don't use or i don't declare all of objects , variables in namespace like above... i think it's because of declarations in namespace , Ideal solution would be place declarations into ref class and i think it won't be compile error , but how's i said unfortunately we can't declare auto_ptr in ref class because of unmanaged and managed code error , and this is infinite loop... if i hadn't seen on my supervisior i would have written this with usual pointers ... : Test *object in ref class and no problem for me... but i can't imagine what would be if my teacher see this solution...
Of course if you don't find any more precisely solution , i'll do this with convenient linker option : /FORCE and i don't see this error... but You know... it's just like an strong solution...
Thanks for help
|
|
|
|
|
Hi,
I am stuck on creating this batch file. I need it to delete the oldest file in a given directory.
I got it working except if the filename contains spaces, which is where I'm stuck.
Here's what I have so far
SET DIRTODELOLDESTFILE="C:\Documents and Settings\TEST001\Desktop\test\New Folder\"
FOR /F %%i IN ('DIR /A-D /B /O-D %DIRTODELOLDESTFILE%') DO SET DELETEME=%%i
DEL %DIRTODELOLDESTFILE%\%DELETEME%
When I try to use
DIR /A-D /B /O-D I see the complete filename, but it's not being saved properly..
If you try a directory with a filename "New Text Document.txt", the script would only pick up "New" but not the entire file name. However, DIR /A-D /B /O-D returns the full filename. I tried googling around, but just about every solution is to "use quotations"... this isn't the case if I don't know the filenames in my directory. If anyone ran into this, any help/clues would be nice
Thanks!
PS: I don't know if this is in the right section. If not, sorry in advance >.>
|
|
|
|
|
Hi,
of course this is not the right forum, it is not a language question.
try
FOR /F "delims=!" %%i IN ('DIR /A-D /B /O-D %DIRTODELOLDESTFILE%') DO SET DELETEME= %%i
it replaces the default delimiters (space and tab) by a character that won't appear in a file path.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks Luc!
That worked nicely. I needed to add some extra string manipulation at the end to handle quotes.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
How do I make a managed c++ struct that will be usable in c# as an array, while still being able to be passed to unmanaged c++ as an array?
I've inserted a series of ???? where I'm at a loss for what to do.
In unmanaged c++ i have something akin to
//c++ static lib
typedef struct
{
double position[3];
double time;
} TimedPosition;
class DataProducer
{
public:
DataProducer(){};
~DataProducer(){};
void GetData( TimedPosition * tp, unsigned int count );
};
In managed code i then have
// c++/cli managed dll
public ref class mgdDataProducer
{
public:
// Allocate the native object on the C++ Heap via a constructor
mgdDataProducer() : m_Impl( new DataProducer) {}
// Deallocate the native object on a destructor
~mgdDataProducer() { delete m_Impl; }
protected:
// Deallocate the native object on the finalizer just in case no destructor is called
!mgdDataProducer() { delete m_Impl; }
/*-----------------------------------------------------------------------------------------*/
public:
int GetData( ????, unsigned int count )
{
m_Impl->GetData( ????, count );
}
private:
DataProducer * m_Impl;
};
Thanks in advance
-Troy
|
|
|
|
|
You will need a "managed" equivalent of both (or at least the second one):
1. native TimePosition and
2. native array of TimePosition instances
If the mgdDataProducer sees struct TimedPosition while compiling in /clr mode, the 1st one is not necessary, I think. I am assuming here that void GetData( TimedPosition * tp, unsigned int count ) should fill an c-style array with "count" TimedPosition instances, right?
The signature of managed "GetData" would be then:
C++/CLI:
void mgdDataProducer::GetData(array<TimedPosition>^ Data, unsigned& Count);
C#:
void GetData(TimedPosition[] Data, ref uint Count);
In your implementation of mgdDataProducer::GetData , you need to transfer the content of native c++ array to a managed array (collection.. whatever). There exist several possibilities to accomplish this, I bet there are some built in interoperability helpers for transfering all native c-like or std:: sequences, although I cannot find a direct link right now.
The simplest way is to call the unmanaged DataProducer with a local c-style array, and shuffle the (there created) TimedPosition instances into the managed array. You can also write reusable wrappers for unmanaged arrays and much more, look at the keywords cli interop, marshalling or similar. I would also try to avoid PInvoke or unsafe stuff...
Cheers,
Paul
modified on Thursday, June 3, 2010 9:08 AM
|
|
|
|
|
I'm trying to binary serialize a 2D array using [Serializable] and ISerializable. In Special constructor for deserialization, I can't deserialize my array. I don't know what the type in info->GetValue("something", ??Type::typeid) . This is my code :
[Serializable]
private ref class SerializedArrayClass : public ISerializable
{
public:
array<array<float>^>^ jaggedArray;
array<float, 2>^ genericArray;
Matrix^ matrixArray;
int width;
int height;
int nElement;
SerializedArrayClass(int width, int height)
{
this->width = width;
this->height = height;
}
InitArray()
{
}
protected:
SerializedArrayClass(SerializationInfo^ info, StreamingContext context)
{
this->width = safe_cast<int>(info->GetValue("width", int::typeid));
this->height = safe_cast<int>(info->GetValue("height", int::typeid));
this->jaggedArray = safe_cast<array<array<float>^>^>>(info->GetValue("jaggedArray", ??::typeid));
this->genericArray = safe_cast<array<float, 2>^>>(info->GetValue("genericArray", ??::typeid));
this->matrixArray = safe_cast<Matrix^>(info->GetValue("matrixArray", ??::typeid));
}
public:
virtual void GetObjectData(SerializationInfo^ info, StreamingContext context)
{
info->AddValue("width", this->width);
info->AddValue("height", this->height);
info->AddValue("jaggedArray", this->jaggedArray);
info->AddValue("genericArray", this->genericArray);
info->AddValue("matrixArray", this->matrixArray);
}
}
What is the correct Type for 2D array and Matrix object?
Thanks,
|
|
|
|
|
hi guys
i use vc++2008.net and i created a form included a rich text box with a few words
and i made a (button + textfield) to help me find a word that exist in the rich text box,but i dont know what is the code to help me?
and thank u all ..
|
|
|
|
|
Hi,
the RichTextBox class has a Find() method, so I suggest you read up on it for starters.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|