#include using namespace std; // cout << [wide range of types] << [wide range of types] << endl; char a = 'a'; int b = 38273; double c = 9382; char * d = "hello"; cout << a << " " << b << " " << c << d << endl;
--------------------------------------------------------------------------- #include "stdafx.h" #include #include using namespace std; int main(int argc, _TCHAR* argv[]) { char * OurBuffer = new char[2048]; FILE * FileHandle; ///////////////////////////////////////////////////////////// cout << "Reading from C:\\BOOT.INI, using a " << ( sizeof(char) * 2048 ) << " byte buffer." << endl; ///////////////////////////////////////////////////////////// cout << "Now displaying the file as it is read line by line." << endl; ///////////////////////////////////////////////////////////// ///// EXAMPLE: FileHandle = fopen( "C:\\mydir\\myfile.txt", "r" ) FileHandle = fopen( "c:\\boot.ini", "r" ); while( OurBuffer[0] != 0 ) { ///////////////////////////////////////////////////////////// OurBuffer[0] = 0; fgets( OurBuffer, 2048 * sizeof(char), FileHandle ); cout << OurBuffer; ///////////////////////////////////////////////////////////// } ///////////////////////////////////////////////////////////// return 0; }
--------------------------------------------------------------------------- Get a string from a stream. char *fgets( char *string, int n, FILE *stream ); wchar_t *fgetws( wchar_t *string, int n, FILE *stream ); Parameters string Storage location for data. n Maximum number of characters to read. stream Pointer to FILE structure. Return Value Each of these functions returns string. NULL is returned to indicate an error or an end-of-file condition. Use feof or ferror to determine whether an error occurred.
--------------------------------------------------------------------------- Open a file. FILE *fopen( const char *filename, const char *mode ); FILE *_wfopen( const wchar_t *filename, const wchar_t *mode ); Parameters filename Filename. mode Type of access permitted. Return Value Each of these functions returns a pointer to the open file. A null pointer value indicates an error. ----------------------------------------------------------------------------------------
kmcguire
Posts
-
need help !! -
Outlook Express [Mail Compose]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. :((
-
firewallhttp://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? :confused: Just, implement as little as possible in unmanaged to talk with the dll for the packet driver. -
Call proc inside namespace from outside the namespaceMabye, formoutput really is not a namespace. I am figuring it may well be.
void displaychar(int mychar) //outside the namespace { //showchar(mychar); Form1::showchar(mychar); }
OR, You may not be including the header file ".\form1.h" witch should define the namespace 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 fromApplication::Run(new Form1());
-
socketTry 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 ); }
-
HTML edit and view control.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. ----------------------------------------------------------------------------
// The header #pragma once using namespace System; using namespace System::Drawing; using namespace System::Drawing::Drawing2D; using namespace System::Windows::Forms; __gc class mlr_lb { public: mlr_lb(); ~mlr_lb(); }; __gc class mlr_txt { public: mlr_txt(); ~mlr_txt(); Drawing::Color color; Drawing::Font * font; String * txt; }; __gc class mlr_img { public: mlr_img(); ~mlr_img(); PictureBoxSizeMode sizemode; String * path; Int32 width; Int32 height; }; __gc struct mlr_lnk { Object * obj; mlr_lnk * next; }; __gc class mlr { public: mlr(void); ~mlr(void); Int32 x; Int32 y; mlr_lnk * lnk; Boolean RemovePrevCtrls( Form * f ); Boolean Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h ); };
// The source. #include "StdAfx.h" #include ".\mlr.h" #using String * JoinStrAr( String * s[], Int32 x, Int32 l, String * d ) { String * str = S""; for( Int32 index = x; index < x+l; index++ ) { str = S""->Concat( str->Trim(), d, s[index]->Trim(), d); } if(str->Length < 1) return str; return str->Substring( 0, str->Length - d->Length ); } String * MakeWidthFit( String * s, System::Windows::Forms::Label * l, Int32 w ) { l->Text = s; if( l->Width > w ) { String * ls[] = s->Trim()->Split( S" "->ToCharArray() ); for( Int32 index = ls->Length; index > -1; index-- ) { l->Text = JoinStrAr( ls, 0, index, " " )->Trim(); if( l->Width <= w ) { return JoinStrAr( ls, index, ls->Count - index, " " ); } } return s; /* it's just a long long line. :-) */ } return NULL; } // mlr::mlr(void) { } mlr::~mlr(void) { } Boolean mlr::RemovePrevCtrls( Form * f ) { Int32 cnt; start:; cnt = f->Controls->Count; for( Int32 index = 1; index < cnt; index++ ) if( f->Controls->get_Item( index )->Tag->ToString()->CompareTo( S"MLR_CTRL" ) == 0 ) { f->Controls->RemoveAt( index ); goto start; } return true; } Boolean mlr::Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h ) { String * str; Int32 cx = x; Int32 cy
-
HTML edit and view control.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.