|
btw, not sure if this is the right place for this post.. if it isn't please let me know
|
|
|
|
|
Hoi there,
i need some help with an ActiveX Control under VC++ .Net
The Method is defined as:
UploadBuffer(VARIANT* VarPBuffer).
After using the Wizzard i got a Windows Form and a Wrapper Class for the control with the following signature:
public short UploadBuffer(ref object VarPBuffer)
and ILDasm shows UploadBuffer:int16(Object&)
Now here's the problem
I got an array of unsigned chars which need to be transfered to the activex controll buffer. In VC++ with MFC this was done this way:
COleVariant *m_Buffer;
CByteArray *m_Array;
...
...
m_Array = new CByteArray;
m_Array->SetSize (1024 * 768);
m_Buffer=new COleVariant (*m_Array);
How do i get this thingie working under .Net ;/ It's realy driving me crazy (And no i can't just recompile the ocx because its comercially sold and the source code is not available)
I hope someone is able to help me
Thx.
|
|
|
|
|
Hello,
The following code snippet invokes a function by its name.
It works fine but the function's name and its arguments must be used separately.
What I would like to do is to type in my function from an edit control as it is defined
E.g. MyFunc(arg1, arg2).
But before invoking it, I assume that I must parse it to get its name and arguments separately.
So I am wondering if Dot.Net framework provides either a parsing method that will easily split the function name and the arguments or better an invoke method where I can just pass my function in one shot with all its arguments?
Could you please help me to find a straightforward solution?
<br />
Object* CInvoker::InvokeMethod(String* method, Object* args[])<br />
{<br />
<br />
Module* module[] = Assembly::GetExecutingAssembly()->GetModules(false);<br />
<br />
CExternal* objexternal = new CExternal();
Type* typExternal = module[0]->GetType("CExternal");<br />
MethodInfo* methodinf = typExternal->GetMethod(method);<br />
Object* ret = methodinf->Invoke(objexternal, args);<br />
return ret;<br />
<br />
}<br />
|
|
|
|
|
Hello all,
Can someone point out the difference between these
two HelloWorld programs ? I don't get why one uses the
'using' statement and i don't get the '.h'
(i'm trying to move from C# if that helps)
*************** -- 1
<br />
#include <iostream.h><br />
#include <stdlib.h><br />
<br />
int main() {<br />
<br />
cout << "Hello, World!" << endl;<br />
system("pause");<br />
<br />
return 0;<br />
<br />
}<br />
*************** -- 2
<br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
cout << "Hello World!" << endl;<br />
system("pause");<br />
<br />
return 0;<br />
}<br />
Thanks
|
|
|
|
|
This is a C++/CLI forum, your question is off topic here.
As you didn't check "Ignore HTML tags in this message (good for code snippets)" I cannot read all your code, but I suspect that one includes iostream.h and the other includes iostream. iostream.h is not standard C++, the latest Microsoft compiler will reject attempts to use it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
In addition to Christian's reply...
Please post non-managed-c++ questions on the appropriate board.
The "using namespace std;" line...I'll quote from the docs:
"The using directive allows the names in a namespace to be used without the namespace-name as an
explicit qualifier. Of course, the complete, qualified name can still be used to improve
readability."
cout and endl are in the std namespace. Without the using directive you'd have to specify the
namespace:
std::cout << "Hello World!" << std::endl;
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark Salsbery wrote: std::cout << "Hello World!" << std::endl;
Yeah, that's how I guessed what his hidden code was )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Yeah, that's how I guessed what his hidden code was
Good reverse-source-engineering!
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Why is deque the only container where pointers and references to the data are not invalidated though iterators could be invalidated?
|
|
|
|
|
Perhaps someone in the Visual C++ forums will answer this ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I put many control on my form but in the field rate, amount what can I do so that it will be not possible to feed letters characters. With Visual c++ 6.0 MFC there was a class to do that but here, what to do ?
I learn my self
|
|
|
|
|
HAndle the keypress event and reject inappropriate keys.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
PLease Sir,
I am looking how to habdle event in this version, I don't see. CAn you show me how to do it. I see only properties but evetI don't see.
Thanks
I learn my self
|
|
|
|
|
Bring up the Properties editor. Click on the Event button at the top of the Properties editor window- the button with a lightning bolt as a symbol and the editor will show the events associated with the button
|
|
|
|
|
This Solution to my problem
// Boolean flag used to determine when a character other than a number is entered.
private:
bool nonNumberEntered;
// Handle the KeyDown event to determine the type of character entered into the control.
void textBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
{
// Initialize the flag to false.
nonNumberEntered = false;
// Determine whether the keystroke is a number from the top of the keyboard.
if ( e->KeyCode < Keys::D0 || e->KeyCode > Keys::D9 )
{
// Determine whether the keystroke is a number from the keypad.
if ( e->KeyCode < Keys::NumPad0 || e->KeyCode > Keys::NumPad9 )
{
// Determine whether the keystroke is a backspace.
if ( e->KeyCode != Keys::Back )
{
// A non-numerical keystroke was pressed.
// Set the flag to true and evaluate in KeyPress event.
nonNumberEntered = true;
}
}
}
}
// This event occurs after the KeyDown event and can be used to prevent
// characters from entering the control.
void textBox1_KeyPress( Object^ /*sender*/, System::Windows::Forms::KeyPressEventArgs^ e )
{
// Check for the flag being set in the KeyDown event.
if ( nonNumberEntered == true )
{ // Stop the character from being entered into the control since it is non-numerical.
e->Handled = true;
}
}
|
|
|
|
|
I tried the following code
StreamWriter^ f = gcnew StreamWriter(L"d:\\listfile.txt");<br />
f->Write(L"begin");
expecting a file containing the string "begin" to be created.
To my surprise, only an empty listfile.txt was created. "begin" was not written.
after a few trials, I realized I must explicitly call f->Close() to get "begin" to be written.
is it true that one of the advantages of C++/CLI over c# is that when an object goes out of scope, there is something called deterministic cleanup to close the object, or am I miseducated?
For std::fstream, I surely don't have to call close() explicitly.
|
|
|
|
|
You can use implicitly dereferenced variables. These variables use the Resource Acquistion Is Initialization (RAII) principle to do their clean up. Also, these variables have the same limiitations as automatic variables:
StreamWriter f(L"D:\\listfile.txt");
f.Write(L"begin");
...
In order to obtain a tracking handle to an implicitly dereferenced variable, you must prefix it with "%".
|
|
|
|
|
Whats wrong with my C++ code, it gets me an error.
How to use byte array in C++ by the way?
C# code:
int data_size = 146000;
int data_loop = 4096;
byte[] data_sent= new byte[data_size];
Random rnd = new Random();
rnd.NextBytes(data_sent);
for (int x = 0; x < data_size; x++)
if (data_sent[x] == 0x3f){
data_sent[x] = 0;
}
C++ code:
int data_size = 146000;
int data_loop = 4096;
Byte[] data_sent = gcnew Byte[data_size]; //Gets me error
Random^ myrandom = gcnew Random;
myrandom->NextBytes(data_sent);
for (int x = 0; x < data_size; x++)
if (data_sent[x] == 0x3f){
data_sent[x] = 0;
}
note: the c# is working and compiled but the c++ code stuck me from that error.
******************************
I just want to
know everything
|
|
|
|
|
I got it already. thanks
******************************
I just want to
know everything
|
|
|
|
|
Bros,
How to code the network speed detection?
What i mean is i want to detect the upload and download using clickbutton. When I press a button it will show to textbox1 the upload speed and textbox2 the download speed.
example:
TextBox1 = 42 kbps
TextBox = 54 kbps
Is anybody here how to do that? Much better if you can give me some links for basic.
Thanks in advance.
******************************
I just want to
know everything
|
|
|
|
|
Send some packets of data of certain size (you decide how much data you want to transfer), see how long it takes to go up and come back, then report the results in the textbox.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I am using Sql SErver 2000 Database and I begin to work with Visual c++ Net 2005;
How to to write SqlCommand::Connection to connect to SQl server 2000 in Visual c++ net 2005
I learn my self
|
|
|
|
|
I see you have lots of Database development questions. Lucky for you there are a massive number of Database Articles here on CodeProject. Use the Navigation mechanisms on the site to find the Database Articles and look through them. I am sure the information you seek is in there.
|
|
|
|
|
In addition to led mike's reply, I think it's important to consult the documentation for the
platforms/systems/etc. that you're wanting to develop for.
For example, to connect to SQL Server, you'll probably want to use the SQL Native Client.
Connection string info can be found here: Using Connection String Keywords with SQL Native Client[^]
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
String^ strConnection;
String^ strString;
SqlConnection^ cprl = gcnew SqlConnection();
cprl->ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=payroll05;server=SEM1;Trusted_Connection=Yes;" ;
cprl->Open();
|
|
|
|