|
Hi everyone, I am working on a project at least a year.
I have two major problems:
1.There is no way I can find out why my computer chrashes when running the program. It runs for a while then all of a sudden coputer restart itself. I am writing in Managed C++/cli using serialport class.
2. When the serial port communication is disconnected the program freez having problem detecting that as well.
FYI: I checked usb-serial converter latest driver, computer recognize it. I can see it through divice manager.( name of the usb-serial converter is Keyspan - USA 19HS).
Thanks in advance.
|
|
|
|
|
1 - Use logging and write the method entry and exits to the log file. By analyzing the log file, you can understand on which method it is failing.
2 - Is your application single threaded? If yes, use another thread to listen to the serial port. If serial port is not responding or disconnected, you should be able to abort the thread which listens to the port.
|
|
|
|
|
Hi Navaneeth, Sorry for delay, I am not sure how to do (1 - Use logging and write the method entry and exits to the log file. By analyzing the log file, you can understand on which method it is failing.) this.
If you be kind enough to tell me how I should do it. That will be very helpful. I am having this problem at least a year. I did everything I could do with my little knowledge nothing is helping. If I know what exacly coused computer to crash I may be able to find solution but I have no clue at all.
thanks;
|
|
|
|
|
Hi,
I haven't discovered a way yet to crash my computer using .NET code only.
One possibility for you is your USB-to-RS232C cable comes with a driver of doubtful quality, e.g. having a memory leak or a bug in its kernel code. So you may want and try it with another serial port, either a real one on a motherboard or expansion board, or a USB-to-RS232C cable from another manufacturer.
Another possibility could be something external to what you are doing, maybe a virus. You might try your USB-to-RS232C cable and your code on another system.
|
|
|
|
|
Hi Luc Pattyn, You probabily right because I am using a different usb-serial adapter altogether and now it did not chrash since then.
thank you.
|
|
|
|
|
Hello everyone, I am trying to get the folder name from openFileDialog box.
Here is what I need to do: when the Filedialog box is open I would select a file from a specific folder, get the folder name and assign to a variable as well, because I need to know from which folder the file came from.
I hope it is clear. if you can pls send me some code or some sort of solution I would greatly appriciate.
my code looks like this for now:
this->openFileDialog1->InitialDirectory = Environment::GetEnvironmentVariable("AppData") + "\\a\\b";
this->openFileDialog1->FileName = String::Empty;
this->openFileDialog1->Filter = "txt Files | *.txt";
this->openFileDialog1->ShowDialog();
Thanks in advance.
|
|
|
|
|
The System.IO.Path class has some handy methods for working
with paths.
Looks like Path.GetDirectoryName[^] could be what you need.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark Salsbery,
Can you Please be little more specific.
Thanks
|
|
|
|
|
Specific as in a code example? I thought the examples at the link I posted
were pretty specific...
String ^FolderString;
if (!String::IsNullOrEmpty(this->openFileDialog1->FileName))
{
FolderString = System::IO::Path::GetDirectoryName(this->openFileDialog1->FileName);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark Salsbery,
I just want to say Thank you very much for your help.
All I had to add is : folderName = FolderString->Split('\\')[6];
because I was interested for the folder name.
so final code looks like this.
if (!String::IsNullOrEmpty(this->openFileDialog1->FileName))
{
FolderString = System::IO::Path::GetDirectoryName(this->openFileDialog1->FileName);
folderName = FolderString->Split('\\')[6];
}
Thanks again;
|
|
|
|
|
How can I draw smooth text on a transparent bitmap using GDI functions?
What I do is:
1- Creating myBitmap
2- Creating Graphics object from myBitmap
3- Getting bitmap hDC
4- Setting background mode to TRANSPARENT
5- Drawing text using DrawText function
6- Releasing bitmap HDC
7- Saving Bitmap
The result is an ugly text! the text is not smoothed but when I set background mode to OPAQ using SetBkMode the result is smoothed.
How can I draw smooth text on a transparent bitmap using GDI functions?
any help will be appreciated.
My code is like this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb);<br />
Graphic g=Graphics.FromImage(myBitmap);<br />
IntPtr hDC=g.GetHDC();<br />
SetBkMode(hDC, TRANSPARENT);<br />
DrawText(hdc, "Test", -1, myrectangle,myflags);<br />
g.ReleaseHdc(hDC);<br />
myBitmap.Save("myBitmap.png",ImageFormat.Png);
modified on Thursday, August 20, 2009 6:54 AM
|
|
|
|
|
Hi,
Not 100% sure but I don't think you can get smooth text on transparent backgrounds. Font smoothing normally happens by blending foregroundColor and backgroundColor at the edges of the glyphs; nothing blends with transparent, whatever you add to it remains transparent.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you for your comment.
But using GDI+, when you draw a text on transparnet background and save the image you will see that the font smoothing is completely good. It seems here font smoothing take place by Mixing Font color with Transparent color, using Alpha value in ARGB.
Also Applications like Photoshop do the job well. So there should be a win32(GDI)approach to drawing smooth text on transparent bitmaps.
in GDI+ the code is like to this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb);<br />
Graphic g=Graphics.FromImage(myBitmap);<br />
g.DrawString("Test", Font, Brushes.Black, 0, 0);<br />
myBitmap.Save("myBitmap.png",ImageFormat.Png);
|
|
|
|
|
How can I convert Glyph Index to Unicode encoding?
The GetCharacterPlacement API function is useful for convert a sequence of unicode carachters to Glyph Indices, but is there a solution for convert a sequence of Glyph Indices to unicode carachters?
(I asked this question in c# forum but I received no reply)
any help will be appreciated.
|
|
|
|
|
Is there any way to draw high quality text glyph by glyph using GDI+?
When we draw a String using GraphicsPath.AddString, The SubPathes in the main path are glyph outlines. but it seems in small fonts the quality of Drawing string this way is not acceptable.
Is the result of GraphicsPath.AddString equal to GetGlyphOutline API function?
(I asked this question in c# forum but I received no reply)
any help will be appreciated
|
|
|
|
|
Hello, This is Vikash
I have a project written in VC++.net 2005.
I am writing the same project in VB.net 2005.
Now the problem is in VC++.net, when i am using an array of bytes and adding bytes values, and while debugging when i see the values filled in the array, along with the byte it also shows some character.
Now I want to ask whether this is being shown by VC++ itself by default or something else.
Actually i have checked this and found that the character shown is actually the Character that the Byte represents as ASCII value.
eg. it shows 65 'A' as the value in the array element where 65 is the inserted byte.
Could you please tell me where this character is coming from.
Any help is appreciated.
Thanks in Advance.
|
|
|
|
|
VikashGohil wrote: Actually i have checked this and found that the character shown is actually the Character that the Byte represents as ASCII value.
eg. it shows 65 'A' as the value in the array element where 65 is the inserted byte.
You seem to have answered your own question. A byte with the value 65 represents the character 'A' in the ASCII encoding.
|
|
|
|
|
Hi,
Below is the line of code(C++) for Reading the Textfile line by line.
CString = strFilePath; // text path file path
ifstream Textfile;
Textfile.open(strFilePath,ios::in);
std::string value;
while(!Textfile.eof())
{
getline(Textfile,value); // Read line by line...
}
Textfile.close();
Now the question is I am having 40MB text file size. I need to read 1000 Lines in a single shot (And upto read 1000 times to reach the whole 40 MB size) not line by line. How to do this?
reg,
Subbu
|
|
|
|
|
you're still in the wrong forum.
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
All,
I have a C++/CLI assembly that is compiled for x64 and x86. These files get installed in C:\Program Files and Program Files (x86) respectively on 64 bit machines via a Visual Studio .NET 2008 setup project. I also need these two assemblies to be installed into the GAC so that other managed apps compiled as "Any CPU" will correctly load the right .dll. I can manually install these two assemblies into the GAC using "gacutil /i" but I'm having trouble figuring out how to set this up in a setup project in VS.NET 2008.
The setup project property "TargetPlatform" is configured for "x64".
The setup project File System looks like this:
Global Assembly Cache Folder\Managed.dll /* (x64) */
Global Assembly Cache Folder\Managed.dll /* (x86) */
Program Files (64-bit) Folder\{AppName}\Managed.dll /* (x64) */
Program Files Folder\{AppName}\Managed.dll /* (x86) */
Upon building the project, I get 2 warnings:
WARNING: Two or more objects have the same target location ('[gac]Managed\2.0.0.0_487e2f56c7456732\Managed.dll')
WARNING: Two or more objects have the same target location ('[gac]Managed\2.0.0.0_487e2f56c7456732\Managed.dll')
I'm suspecting that VS.NET 2008 won't support what I'm trying to accomplish but I wanted to do a sanity check with you guys first. If it is ineeded the case, does anyone have alternative approaches or installers that I can look into.
Thanks so much!
Jason Newell
www.jasonnewell.net
|
|
|
|
|
Hi,
I want to read Text File line by line and code follows;(with out using the << operator and char buffer)
ifstream Textfile;
Textfile.open(strFilePath,ios::in);
string value;
while(!Textfile.eof())
{
getline(Textfile,value);
}
Textfile.close();
When i am compiling the above code it throws the error as
error C3861: 'getline': identifier not found, even with argument-dependent lookup
How to rectify this error..
reg,
Subbu
|
|
|
|
|
Hi,
aren't you confusing standard C/C++ (see C/C++/MFC forum) with managed C++/CLI (this forum), where string class and File.ReadAllLines() would be useful (and getline is unheard of)?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
If I'm not mistaken, geline() is a method - you need to call it on a
basic_istream object.
Maybe
Textfile.getline(Textfile,value);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I need the following Command need to be in a separate text file.
BYTE *Command;
long length;
// Assume Command holds some values after executing the Current Statement
OutEndpt->XferData(Command, length); //XferData used to transfer Data to USB
Now I need the Command to be write in a seaprate text file with the file length as length given above.
Anyhelp appreciated..
Thanks,
Subbu
|
|
|
|
|
Your question is unclear.
spalanivel wrote: I need the following Command need to be in a separate text file.
BYTE *Command;
long length;
How can this be in a text file?
spalanivel wrote: Now I need the Command to be write in a seaprate text file with the file length as length given above.
Are you using C++/CLI? If yes, classes under System::IO will help you to work with files. If you are using standard C++, you may need to check this[^] and this is not the right forum. Try C++/MFC forum instead.
|
|
|
|