Click to See Complete Forum and Search --> : from Console to Visual


wish2hate
January 28th, 2009, 07:53 PM
I have my program working fine on console right now and I would like to learn how to display them on visuals. I've learned some GUI but now I just don't know how to put them together into one file.

If someone is willing to show me an example of how to solve the following problem, then I can get started to outputing to GUI.

Here is a simple program that I hope it can display a visual.

#ifdef __BORLANDC__
#pragma hdrstop // borland specific
#include <condefs.h>
#pragma argsused
USEUNIT("Tserial_event.cpp");
#endif


/**************** this is what troubles me*****************/
#include "conio.h"
#include "Tserial_event.h"
/******************troubles ends***********************/


#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
int _stdcall WinMain() {
Char h = 'h';
MessageBox::Show(h.ToString(), S"testing if this works");
return 0;
}


I know I don't really have to attach any of the ifdef and includes in order to make my main work, but the problem is I have to have those to read data from serial port. My problem right now is that I am able to read from serial port, and I know how to display visuals, but I am unable to combine them together. (I'm quiet new in programming in C++). Can someone please provide me some info if this is not the correct way to do it?

STLDude
January 28th, 2009, 08:32 PM
What you have here is a mix of C++ and Managed C++/CLI. Pick one you want to use it. Here (http://en.wikipedia.org/wiki/C%2B%2B/CLI) is more info about it.

wish2hate
January 29th, 2009, 07:48 PM
Would you please show me how to display a dialog on the information that I recieved from com? I only learned how to do gui with managed extension and only learned C++ to recieve data from serial port.

STLDude
January 29th, 2009, 09:40 PM
Rather then me typing what is avaliable on MSDN, here (http://msdn.microsoft.com/en-us/library/ms645505.aspx) is direct link to MessageBox function including example.

wish2hate
February 16th, 2009, 02:40 PM
The code you showed me on msdn does not help me open up a port and read from port with managed c++.

STLDude
February 16th, 2009, 05:07 PM
Really, but you asked for:
Would you please show me how to display a dialog...
which I provided you with link to documentation for MessageBox. If you want something else, it is helpful to be more precise.

wish2hate
February 16th, 2009, 07:21 PM
My question was:

Would you please show me how to display a dialog on the information that I recieved from com?

STLDude
February 16th, 2009, 07:33 PM
Ok, I'm still not totaly clear what exactly you need, but if you just want to use MessageBox:
MessageBox(NULL, _T("This where your textual representation of your data will go", _T("Serial Output"), MB_OK);


Now, if you are asking on how to convert your raw data that you get from serial port into text representation, then let's see what kind of data you get and we might be able to help.

wish2hate
February 17th, 2009, 02:23 AM
I don't know what exactly troubles you to not understand what I'm asking... Probably the way I explained was confusing...

I'm asking how to:
1. receive data from an USB port (which is com port) with managed C++
2. display the received data onto a visual with managed C++

Right now what troubles me is I can do part 1 with C++ and part 2 with managed C++

I'm not asking you to teach me how to process data.(I'm new but I'm not that new). I'm asking you to teach me how to receive data and display it with managed C++.