|
You cannot call managed code from unmanaged code (it violates the basic protection principles), but you could compile your c++ project to .NET.
Matt
Visual C++ FE
|
|
|
|
|
Thank you for replying, I thought that was the case, and in fact in the end i did what you suggested.
|
|
|
|
|
I have a small program that connects the computer to a printer, using WNetAddConnection2. We are running Win XP Pro with Novell Netware client. This has been working ok, but now we have a new ghost with the latest versions and service packs of some programs, including the Netware client and this is where the problem started: when the program is run the computer totally dies when calling WNetAddConnection2 -not even Ctrl + Alt + Del helps.
We have figured out that it has some problem connecting to the printer server, because if we establish a connection to the printerserver first, and then run the program it works. And it is not just WNetAddConnection2 that has problem, if we for example set current directory to the printer server or treis reading the creationdate of a folder on the printer server, the computer also 'dies'. Now what makes this really strange is that I made a small test program in C# -and that program does not have the same problem! Am I wrong to think that managed C++ and C# compiles down to essentially the same???
Any clues as to what is going wrong here are most welcome!
Thanks
/EnkelIk
|
|
|
|
|
I've noticed that Outlook Express has a very nice compose message window. Wow, It supports
writting you're messages and inserting images and all that great stuff. Nah, its not hard to
write you're own compose mail window supporting the user dragging and dropping images in and
changing font exactly like Microsoft Word and a million other applications...
I am still trying to write my own content view that can support displaying HTML and at the same time allowing it to be activly editable. I tried using the WebBrowser control.. I figured i could
draw a blinking cursor on top of it when it is being editted and then just insert HTML code
relative to what the user is typing.. (ugly code), and as i stated above i tried doing it the bare skeleton code way designing my own HTML display and edit engine from scratch. WOW, AM I CRAZY?
Alright. The question i have is how to accomplish my feat - or am i already or have tried doing it the right way?
[btw] If no replys i'll spend many weeks writting an entire HTML display/edit engine..
------------------------------ editted -----------------------------------
I'm adding a link to a zip file that contains my solution for building a engine that is
able to display text and picture content and other stuff so that anyone wanting to figure
out what i am doing or mabye they could use the content engine.
http://www.freewebs.com/joshmcguire/TMLE.zip
Thats the method i am currently working on to create a mail edit view capable of converting
HTML into it's .NET object format that can be editable. (The edit part is just now being coded).
I hope someone has a easier, quicker, and better way soon.
|
|
|
|
|
Dear forum members,
An object of a managed class (written in C#) is passed to the
clipboard during drag&drop operation. The object has to be
dropped on to a MFC view (written in VC++ .Net).
How do I create/access my object from the COleDataObject
which I get while 'Droping' into a view ?
Is there any other way to do this ?
[Hope I have explained my problem well ...]
Thanks in advance.
svkr.
|
|
|
|
|
i want to implement a firewall in a simplest way
with ability off packet filtering and blocking port
i am a c# programmer and i couldnt do this in c#
if there is a any api for processing a packets in windows please help me
if i want to this with combining manged and unmanaged c++ code what can i do?
koosha
|
|
|
|
|
http://winpcap.polito.it/ - Go there and find the development documentation.
I have used it to capture packets before using C++. However, i do not know if they yet support capturing packets from a modem. I am also unsure if it can allow you to block packets from coming in. Its the best help i can offer.
if i want to this with combining manged and unmanaged c++ code what can i do?
This will require most likely using unmanaged and managed code, however, it is not too hard?
Just, implement as little as possible in unmanaged to talk with the dll for the packet driver.
|
|
|
|
|
Hello, and thanks for reading my post hopefully you can help me.
My problem is i need code or a control that is native with low-overhead using Microsoft Visual C++ .NET that allows a user to add images and text. Exactly like a wordpad, however, it needs to also be able to display (and edit). It seems quite simple but i need to display HTML code. I took a look at the
RichTextBox control and choked, it seemed to have a complicated format for storeing the images and text formatting.. I was hopeing to be able to write
a function that takes a argument of HTML code and convert this into some
cordinates for the text and images (supporting only basic HTML) and use the
System::Drawing2D to draw the text but i run into a problem.
I can not figure out a way to tell how long in pixels or whatever how
long the string will be when it is written out onto the picturebox or form.
Graphics * g = this->CreateGraphics();
g->DrawString( ... blah .. blah , 10, 10 );
No, way i can know where to start drawing my image if for instance i had something like.
"blah blah blah [img src=...]"
btw: This is for the compose form of my mail application. So user can write their email, insert images, and view emails.
|
|
|
|
|
nm; I figured out how to do it.
Using label and picture box controls.
I convert HTML into my own structored format of
text, image, and tag classes linked together then
the main class displays these onto a surface and using
autoscrolling - *magic* it looks just like a webpage..
Well, almost. With a little work it would.
----------------------------------------------------------------------------
<br />
#pragma once<br />
<br />
using namespace System;<br />
using namespace System::Drawing;<br />
using namespace System::Drawing::Drawing2D;<br />
using namespace System::Windows::Forms;<br />
<br />
__gc class mlr_lb {<br />
public:<br />
mlr_lb();<br />
~mlr_lb();<br />
};<br />
__gc class mlr_txt {<br />
public:<br />
mlr_txt();<br />
~mlr_txt();<br />
<br />
Drawing::Color color;<br />
Drawing::Font * font;<br />
String * txt;<br />
};<br />
__gc class mlr_img {<br />
public:<br />
mlr_img();<br />
~mlr_img();<br />
<br />
PictureBoxSizeMode sizemode;<br />
String * path;<br />
Int32 width;<br />
Int32 height;<br />
};<br />
__gc struct mlr_lnk {<br />
Object * obj;<br />
mlr_lnk * next;<br />
};<br />
__gc class mlr {<br />
public:<br />
mlr(void);<br />
~mlr(void);<br />
Int32 x;<br />
Int32 y;<br />
mlr_lnk * lnk;<br />
Boolean RemovePrevCtrls( Form * f );<br />
Boolean Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h );<br />
};<br />
<br />
#include "StdAfx.h"<br />
#include ".\mlr.h"<br />
#using <mscorlib.dll><br />
<br />
String * JoinStrAr( String * s[], Int32 x, Int32 l, String * d )<br />
{<br />
String * str = S"";<br />
for( Int32 index = x; index < x+l; index++ )<br />
{<br />
str = S""->Concat( str->Trim(), d, s[index]->Trim(), d);<br />
}<br />
if(str->Length < 1)<br />
return str;<br />
return str->Substring( 0, str->Length - d->Length );<br />
}<br />
String * MakeWidthFit( String * s, System::Windows::Forms::Label * l, Int32 w )<br />
{<br />
l->Text = s;<br />
if( l->Width > w )<br />
{<br />
String * ls[] = s->Trim()->Split( S" "->ToCharArray() );<br />
for( Int32 index = ls->Length; index > -1; index-- )<br />
{<br />
l->Text = JoinStrAr( ls, 0, index, " " )->Trim();<br />
if( l->Width <= w )<br />
{<br />
return JoinStrAr( ls, index, ls->Count - index, " " );<br />
}<br />
}<br />
return s; <br />
}<br />
return NULL;<br />
}<br />
mlr::mlr(void) { }<br />
mlr::~mlr(void) { }<br />
Boolean mlr::RemovePrevCtrls( Form * f )<br />
{<br />
Int32 cnt;<br />
start:;<br />
cnt = f->Controls->Count;<br />
for( Int32 index = 1; index < cnt; index++ )<br />
if( f->Controls->get_Item( index )->Tag->ToString()->CompareTo( S"MLR_CTRL" ) == 0 )<br />
{<br />
f->Controls->RemoveAt( index );<br />
goto start;<br />
}<br />
return true;<br />
}<br />
Boolean mlr::Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h )<br />
{<br />
String * str;<br />
Int32 cx = x;<br />
Int32 cy = y;<br />
Int32 clh = 0;<br />
mlr_lnk * l = lnk;<br />
<br />
RemovePrevCtrls( f );<br />
f->Update();<br />
<br />
while( lnk != NULL )<br />
{<br />
if( lnk->obj->GetType()->FullName->CompareTo( "mlr_txt" ) == 0 )<br />
{<br />
mlr_txt * txt = static_cast<mlr_txt*>( lnk->obj );<br />
str = static_cast<mlr_txt*>( lnk->obj )->txt;<br />
while( str != NULL )<br />
{<br />
<br />
System::Windows::Forms::Label * newl = new System::Windows::Forms::Label();<br />
newl->Tag = S"MLR_CTRL"; <br />
newl->AutoSize = true;<br />
newl->Location = Point( cx, cy );<br />
newl->Font = txt->font;<br />
str = MakeWidthFit( str, newl, w - (cx - x) );<br />
if( str != NULL )<br />
{<br />
<br />
cx = x;<br />
if( newl->Height > clh )<br />
clh = newl->Height;<br />
cy = cy + clh;<br />
clh = 0;<br />
}else {<br />
clh = newl->Height;<br />
cx += newl->Width;<br />
}<br />
f->Controls->Add( newl );<br />
}<br />
<br />
}<br />
if( lnk->obj->GetType()->FullName->CompareTo( "mlr_lb" ) == 0 )<br />
{<br />
cx = x;<br />
cy = cy + clh;<br />
clh = 0;<br />
}<br />
if( lnk->obj->GetType()->FullName->CompareTo( "mlr_img" ) == 0 )<br />
{<br />
mlr_img * img = static_cast<mlr_img*>( lnk->obj );<br />
System::Windows::Forms::PictureBox * newpb = new System::Windows::Forms::PictureBox();<br />
newpb->Tag = S"MLR_CTRL";<br />
newpb->Width = img->width;<br />
newpb->Height = img->height;<br />
newpb->BackColor = Color::AliceBlue;<br />
newpb->Image = Image::FromFile( img->path );<br />
newpb->SizeMode = img->sizemode;<br />
<br />
if( cx == x ) <br />
{<br />
imgnochoice:;<br />
newpb->Location = Point( cx, cy );<br />
} else {<br />
if( w - (cx - x) >= img->height ) <br />
{<br />
newpb->Location = Point( cx, cy );<br />
cx += img->width;<br />
if( img->height > clh )<br />
clh = img->height;<br />
}else{<br />
<br />
cx = x;<br />
cy = cy + clh;<br />
goto imgnochoice;<br />
}<br />
}<br />
f->Controls->Add( newpb );<br />
}<br />
lnk = lnk->next;<br />
}<br />
return true;<br />
}<br />
mlr_txt::mlr_txt(void) { }<br />
mlr_txt::~mlr_txt(void) { }<br />
mlr_img::mlr_img(void) { }<br />
mlr_img::~mlr_img(void) { }<br />
mlr_lb::mlr_lb(void) { }<br />
mlr_lb::~mlr_lb(void) { }<br />
<br />
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)<br />
{<br />
mlr * m = new mlr();<br />
mlr_txt * txt1 = new mlr_txt();<br />
mlr_txt * txt2 = new mlr_txt();<br />
mlr_img * img1 = new mlr_img();<br />
mlr_lb * lb1 = new mlr_lb();<br />
txt1->font = new Drawing::Font( "Arial", 15 );<br />
txt1->color = Color::Red;<br />
txt1->txt = S"Hello, my name is kevin. I am writting this long lone for a reason can you guess what the reason is?";<br />
m->lnk = new mlr_lnk;<br />
m->lnk->obj = txt1;<br />
m->lnk->next = new mlr_lnk;<br />
img1->width = 250;<br />
img1->height = 250;<br />
img1->path = "c:\\b.jpg";<br />
img1->sizemode = PictureBoxSizeMode::StretchImage;<br />
m->lnk->next->obj = img1;<br />
m->lnk->next->next = new mlr_lnk;<br />
m->lnk->next->next->obj = lb1;<br />
m->lnk->next->next->next = new mlr_lnk;<br />
txt2->font = new Drawing::Font( "Arial", 10 );<br />
txt2->color = Color::Red;<br />
txt2->txt = S"Alright, im just going to start talking about some apples that fell off a tree and landed into a truck then got driven towards the town and a bird pecked one off and fly over the river back to it's next and feed its babys while it watch a hunter track a deer!";<br />
m->lnk->next->next->next->obj = txt2;<br />
m->lnk->next->next->next->next = NULL;<br />
m->Render( this, this->CreateGraphics(), 10, 10, this->Width - 10, this->Height - 10 );<br />
}<br />
|
|
|
|
|
Hi,
I incorporated a PLK for my VSPackage. I followed the exact instructions for the PLK implementation as mentioned in the VSIP help (including registering it in the registry). I also verified the PLK info.
When I attempt to run the package (by running project in debug mode – F5, using /noVSIP switch), it gives me an error message “Package XX has failed to load properly…”. Half the time the spawned app just goes blank and hangs and does not even give the pakage load failure message.
However, it does not give any clue as to why the package load failed or what the problem is. Is there any way (any log or anything else) in which I can find out why the package is not loading properly? It does not even produce any trace messages to indicate till what point the load went through.
When I run the app in debug mode (using F5) but without the /noVSIP switch, it runs fine and I can trace through it.
Any help will be greatly appreciated.
Thanks.
ManSus.
|
|
|
|
|
I need a method to find out All paths from a node( such as I) to another node (Such as J) in a digraph. the digraph is represented by adjacency matrix!
|
|
|
|
|
First off, you need to reduce the problem. You cannot necessarily determine all paths from I to J if there is a cycle in the graph, because there are (potentially) infinite paths.
Detecting graph cycles is fairly simple. Search on Google for how.
Now, if you are willing to reduce the problem to only Directed Acyclic Graphs, you simply start at I and traverse every possible path. The simplest implementation is to store a representation of the path (possibly just a list of vertex pointers). Every time you come to a point where you could traverse down two different edges, copy the list and traverse down both. (Of course, if there are more than two possible edges, make additional copies and traverse for each.) Since the graph is acyclic, the paths will either run into J (at which point they record/print themselves somewhere) or they will end unsuccessfully (at which point they do nothing else).
This same logic (with minor modifications) will also work on cyclic graphs, but checking for cycles becomes necessary. e.g. Is vertex Q already in the path? If so, don't bother going there again, because it's a cycle. And of course, if there is actually a cycle in valid path (e.g. I->Q->Z->Q->J), it's impossible to return all the paths, because there really will be an infinite number of them. (e.g. I->Q->Z->Q->Z->Q->Z->...Q->J)
|
|
|
|
|
how to set send & recv timeout for TCP?
|
|
|
|
|
|
Try changing the Socket.Blocking Property to false. That way when you call the connect method you can go into you're own loop counting the amount of time you want to wait, but, make sure the socket is on a seperate thread if it has to be or something to keep it working while you loop is working.
You could also try putting you're loop to sleep a number of milli-seconds or seconds to allow the socket to make its connection or not.
while( [it hasnt been 10 seconds] )
{
/* time code */
Threading::Thread::CurrentThread->Sleep( 1000 );
}
|
|
|
|
|
Use the appropriate WSAxxxxxx functions... FD_SETs and so on. Using threads and while loops is non-efficient in my opinion. And what do you exactly want to do ?? Is it a serving socket or a client one ? Why 10 seconds ? I can help more if you clarify your question.
|
|
|
|
|
Hi,
i need a high resolution timer for catching some packages on about every 20 msec.I already have working class which start multimedia timer with 1 msec. precision.And now,the problem: how to sen quit message to my Timer class,or is there any other way to stop the timer from main program in which Timer is started?
Generally, i would like to see some messaging issues in console app's, but with class approach and not classical c++.
many thanks
|
|
|
|
|
Has any body goten the new .net compiler in the toolkit to work with the VC++6 IDE??
How did you do it??
Thanks
|
|
|
|
|
I have a Windows Form Application (.NET), I am having trouble calling a procedure within the namespace from outside the namespace. I have the procedure displaychar outside the namespace which is a wrapper to be called from another programming language. The procedure showchar is within the namespace.
The code:
void displaychar(int mychar) //outside the namespace
{
//showchar(mychar);
formoutput::Form1::showchar(mychar);
}
--results in:
error C2653: 'formoutput' : is not a class or namespace name
Anyone have any ideas??
-Don
|
|
|
|
|
Mabye, formoutput really is not a namespace. I am figuring it may well be.
<br />
void displaychar(int mychar)
{<br />
Form1::showchar(mychar);<br />
}<br />
OR, You may not be including the header file ".\form1.h" witch should define the namespace <quote>formoutput. Use #include ".\form1.h" at the top of the source.
Then call it, however i bet you might get the error.
c:\Documents and Settings\default user.JOSH\My Documents\Visual Studio Projects\Tmle\mlr.cpp(105): error C2352: 'System::Windows::Forms::Form::showchar' : illegal call of non-static member function or something. If so, it means you must first create the class Form1 or gain a pointer to it when it is created from
<br />
Application::Run(new Form1());<br />
|
|
|
|
|
The subject basically says the gist of it.
I'm trying to write a program in C++ where it waits for input for up to 2 seconds but if nothing happens in 2 seconds, it stops looking for input and goes off to do something else.
I know this may touch on stuff that you need multi-threading for but I think I remember reading somewhere that there's a simpler way for something as simple as I'm looking to do.
Does anyone have any code snippets or any ideas?
Thanks in advance for your help.
MaKuTu t3h n00b
|
|
|
|
|
Probably more elegant to do this in a multithreaded fashion, but yes, it's possible to do what you want without multithreading.
First, you're going to need non-blocking input. If you don't have that, I think you're pretty much SOL.
Assuming you have non-blocking input, the basic logic is:
int granularity = 100;
int attempt = 2000;
int attempted = 0;
while (attempted < attempt)
{
if (inputIsAvailable())
{
doSomething();
}
else
{
Sleep(granularity);
attempted += granularity;
}
}
doSomethingElse();
|
|
|
|
|
I guess I don't know whether or not I have non-blocking input.
Do you know any examples of what a function like that might be called/what header file you need?
Thx
|
|
|
|
|
Not really. That would be entirely dependent on what libraries you ae using for input. Perhaps whatever library you are using provides a function (with a name such as bytes_available()) which returns the number of bytes currently available for access. I've used libraries (e.g. JNetLib) which has this type of functionality, but many libraries do not. It is possible to wrap an asynchronous APi and achieve this kind of functionality (which is what JNetLib does), but this wrapping will require threading.
It really depends on what you are trying to do, where this input is coming from, and what libraries you are using.
|
|
|
|
|
hi
i am kind of new in programming and am still learning c++ , and so far i know about functions arrays pointers and a little about file processing but no knowledge of object and classes...
anyway , i've been encountering some annoying problems , and i found out that they're all about the difference between the .h header files and the new ones with the 'using' and namespaces.
and here's some of the problems i found :
- when i use <iostream.h> and for example i store 025 in an integer with cin and then output it with cout i'll get a different value but with <iostream> and using namespace std; i dont have this problem
- while outouting and inputing to a file with <fstream> and using namespace std; and then passing this file to a recursive function as follows :
void func ( ifstream dd )
{ ..bla bla func(dd) bla bla.. }
...
ifstream file ("ff.txt");
func (file);
...
I get errors but with <fstream.h> i dont get these kind of errors
So if anybody would explain to me (in a simplified way) why i get these errors and if there's a way to do the same job with the new header files cause as you know in early courses they dont explain such things
And thanks
==<< ormax3 >>==
|
|
|
|
|