|
i am trying to send a text message from one application to yahoo instance messanger window but failing.
what i want is my application should send some text and that text should appear in the yahoo messangers instant message window.
please help me
|
|
|
|
|
This isn't really managed code,
This may not be possible, but the following could probably be done to insert messages into the "input text," but probably not the running chat:
- Use the Spy++ tool while an instance of YIM is running to find the YIM window class name and noting it, and finding the chat input child text box's id.
- In code, do a top level enumerations of windows to find the active YIM window, or alternatively, enumerate the user processes and find the process/main window.
- Get the handle of that "input text box" window
- Use that handle to set the window text.
If you're looking to add stuff to the running chat window, you may not be able to do so because it probably has text added by a method call somewhere internal to YIM.
|
|
|
|
|
Can anyone please direct me in the right direction. I am trying to find a prewritten program that will 'listen' for inputs from a serial port, and then launch an application. I'd appreciate any help.
kswisslk
|
|
|
|
|
Look for the article: "Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications" in the MSDN.
|
|
|
|
|
check out this:
http://www.codeproject.com/managedcpp/howtocomport.asp
...the mind is not a vessel to be filled but a fire to ignited
|
|
|
|
|
This one is good:
http://www.wcscnet.com
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
How can I change the text (caption) color on CButton? I'm using a MFC dialog box.
|
|
|
|
|
Your object.SetWindowText("Caption"); ????
The returned pointer may be temporary and should not be stored for later use.
|
|
|
|
|
Hi,
I'm a bit vague on differences between managed C++ and unmanaged C++. Here's my problem:
#include "stdafx.h"
#using <mscorlib.dll>
#using<system.dll>
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace std;
//using namespace System::IO::FileStream;
int _tmain(int argc, _TCHAR* argv[])
{
// TODO: Please replace the sample code below with your own.
string * fileName = &string(argv[1]);
FileStream *fs = new FileStream(fileName,FileMode::OpenOrCreate);
BinaryReader * w = new BinaryReader(File::Open(fileName, FileMode::Open));
return 0;
}
I get:
byteme.cpp(19) : error C2664: 'System::IO::FileStream::FileStream(System::String __gc *,System::IO::FileMode)' : cannot convert parameter 2 from 'System::IO::FileMode' to 'System::String __gc *'
Cannot convert an unmanaged type to a managed type
byteme.cpp(22) : error C2665: 'System::IO::File::Open' : none of the 3 overloads can convert parameter 1 from type 'std::string *'
stdafx.cpp(0): could be 'System::IO::FileStream __gc *System::IO::File::Open(System::String __gc *,System::IO::FileMode)'
while trying to match the argument list '(std::string *, System::IO::FileMode)'
And I was getting an issue with teh string * fileName declaration until I mangled some stuff...question is, what do these errors mean? And with MC++ do you use something other than argv/argc?
Charlene
|
|
|
|
|
try changing to....
String* fileName = new String(argv[1]);
|
|
|
|
|
ive been working on some simulation code, what i have written basically what it does it creates a Vector and fills it with random DOUBLE numbers from two different sources untill maz_size reached.. what im stuck is i want to go thorugh each element in the vector..prob using an iterator such as input_iterator i think?
so the vector is such..
[number_from_first_source, number_from_secondSource, number from_first source...etc etc]
so every odd element is form source1 and every even element is from source 2..
now i want to go thorugh each element with specific iterator value..example lets say 20ms i.e. 0.002..quite small value. the random numbers are all seeded values. so how owul di go through the vector with this small iterator value.
]#include <iostream><br />
#include <vector><br />
#include <stdlib><br />
#include <time><br />
#include <numeric><br />
#include <algorithm><br />
#include "exponentialgenerator.h"<br />
<br />
using namespace std;<br />
<br />
ExponentialGenerator one = 1.41;<br />
ExponentialGenerator two = 1.71;<br />
<br />
double nextNumber = reinterpret_cast<double>one.generate());<br />
double nextNumber2 = reinterpret_cast<double>two.generate());<br />
int counter = 0;<br />
<br />
void fillVectorToSum(vector<double>& v, double sum)<br />
{<br />
<br />
int total = 0;<br />
do {<br />
if (counter++ % 2){<br />
v.push_back(nextNumber);<br />
total += nextNumber;<br />
nextNumber = one.generate();<br />
}<br />
else {<br />
v.push_back(nextNumber2);<br />
total += nextNumber2;<br />
nextNumber2 = two.generate();<br />
}<br />
<br />
} while(total+nextNumber+nextNumber2 <= sum);<br />
if(total < sum)<br />
v.push_back(sum-total);<br />
}<br />
<br />
int main()<br />
{<br />
<br />
srand((unsigned) time(NULL));<br />
vector<double> v;<br />
fillVectorToSum(v, 30);<br />
<br />
cout << "Number of elements: " << v.size() << "\nTotal: "<br />
<< accumulate(v.begin(), v.end(), 0) << endl;<br />
copy(v.begin(), v.end(), ostream_iterator<double> (cout," "));<br />
<br />
}
the exponentialGenerator.h file i use jus to generate numbers if your wondering....
anyway any input to this problem would be appreciated.
|
|
|
|
|
i'm trying to accomplish something like this...
class ManagedClass;
class UnmanagedClass
{
protected:
void SetValue( std::string val );
friend void ManagedClass::SetValue( String* val );
};
namespace MyNamespace {
class __gc ManagedClass
{
protected:
void SetValue( String* val );
};
}
i can't get it to compile. i have tried just about every combination of the namespace and class name in the forward declaration and friend function definition. anyone have any ideas??
thanks.
|
|
|
|
|
I don't think you really need that friend directive. Most probably, you could simply make your classes public and avoid inline methods.
It seems that you want to call a managed method from an unmanaged class. However, this can't be done by a direct call, because managed objects are subject to garbage collection. To get a safe entry point into the managed heap, you have to use a GCHandle, which in turn is wrapped by the gcroot template. Try this:
#include <vcclr.h>
class ManagedClass;
class UnmanagedClass
{
public:
UnmanagedClass( ManagedClass* p );
private:
gcroot< ManagedClass* > m_pManaged;
}
You can then make your calls into the managed class with the m_pManaged pointer.
There might be another problem: Since you have both managed and unmanaged code in one project, this project needs to be linked in mixed mode. This is because for the unmanaged code, you need the C runtime, which requires an entry point as well as statics. For an instruction of how to convert your project to mixed mode, see the article: "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the MSDN.
|
|
|
|
|
Is there a way to declare a function (SHOWME in this case) in C++ to prevent the name mangling so it can be referenced by C code.
I currently have this (form1.h):
public:
void showme(int thenum)
{
MessageBox::Show(S"abc", S"Result...");
}
|
|
|
|
|
Use extern "C" :
extern "C" void showme(int thenum)
{...}
|
|
|
|
|
Still get the same error.
|
|
|
|
|
The function called by the "C" module can not be a member of the class. One common way to export methods of a class for use by C code is to write functions (called wrappers) that take an object of the class as an argument. Here is a small sample :
<br />
<br />
extern "C"<br />
{<br />
<br />
int ShowMe( void *pobject, int argument )<br />
{<br />
CYourClass *pc = (CYourClass *)pobject;<br />
return pc->ShowMe( argument );<br />
}<br />
<br />
}<br />
<br />
I have done this on a fairly large scale and it worked rather well.
a two cent stamp short of going postal.
|
|
|
|
|
Well, progress is made. Any advice on appending text to a textbox in TOoutbox function. Here is the code:
#pragma once
extern "C" int magiccalc(void);
namespace myapp1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
magiccalc();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private:
System::Windows::Forms::TextBox * outBox;
private:
System::ComponentModel::Container * components;
void InitializeComponent(void)
{
...yada yada
}
public:
static void TOoutbox(int outnum)
{
outBox->AppendText("x"); //add text to textbox
}
};
}
extern "C"
{
void showme(int wrapnum) // My wrapper for C
{
myapp1::Form1::TOoutbox(3);
}
}
Thanks to all
|
|
|
|
|
myapp1::Form1::ioBOX.Appendtext("x");
Gives this error:
error C2228: left of '.Appendtext' must have class/struct/union type
type is ''
----------------------------------------------------------------------
Any ideas?
----------------------------------------------------------------------
#pragma once
extern "C" int magiccalc(void);
namespace myapp1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
magiccalc();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::TextBox * ioBOX;
private:
void InitializeComponent(void)
{
this->ioBOX = new System::Windows::Forms::TextBox();
... ...yadda yadda
}
public:
static void TOioBox(int outnum)
{
ERROR----> myapp1::Form1::ioBOX.Appendtext("x");
}
};
}
extern "C"
{
void showme(int wrapnum) // My wrapper for C
{
myapp1::Form1::TOioBox(3);
}
}
|
|
|
|
|
Name mangling is a technique used by the compiler.
Each compiler can have different algorithm for name mangling.
I don't think its possible to prevent name mangling.
Rahul
|
|
|
|
|
Hi all!
I'm want to use my library in another project. I have compiled my lib (tmf.lib) succesfully. But when i I whant to use there a Linking error:
error LNK2001: unresolved external symbol "void __cdecl tmf_close(struct TmfClass *)" (?tmf_close@@YAXPAUTmfClass@@@Z)
error LNK2001: unresolved external symbol "struct TmfClass * __cdecl tmf_init(char const *)" (?tmf_init@@YAPAUTmfClass@@PBD@Z)
The problem is that I've added tmf.lib to project settings library modules and copied tmf.lib and some header files to project dir.
Does anyone know how to solve this problem?
PS I also tryed to this similar stuff but with a very small lib containg only a few functions a every thing was ok.
Pain is a weakness living the body
|
|
|
|
|
Add the project dir to the list of directories searched for libraries/headers in the IDE (Tools | Options -- find the VC++ settings)
|
|
|
|
|
hmm! not working any other ideas. I think its something with precompiled headers. .
Pain is a weakness living the body
|
|
|
|
|
And its not working after I added all header and source files to project. All the time the same error!!!
Pain is a weakness living the body
|
|
|
|
|
Its working. The problem was with compiler params lib was compiled as ansi C and my projekt is in VC++ . After compiling lib in c++ compiler everything is OK
Pain is a weakness living the body
|
|
|
|