|
I am currently working on a billing application and i need to be able to set a size limit on int's and fill the remaining slots with 0's ex. 0034567. I dont mind if it drops the 0's when i'm storing it but i need to know how to read it back with the 0's. I'm guessing that it might be possible when converting it to a string. Any ideas? Thanks
|
|
|
|
|
Expose the int through get and set methods. The set method strips extra numbers so you don't go past the maximum. The get method just returns it.
How you show the number is a rendering detail, your rendering layer should use an ostringstream, CString.Format or sprintf to format a string using the number to the format you're after.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Greetings,
I am new to the MC++ world, so I thought I would start with a simple unamanaged class, and wrap it in a managed class.
I was able to call and execute my managed .Net wrapper class from a C# form which appeared to work correctly. But I am not sure if my GetValue() function nees anything special such as a "__pin" call to make it safe for the managed code?
Here is my code:
// My unmanaged class.
// This implements a simple set and get method.
__nogc class CUnManaged
{
int nValue;
public:
CUnManaged()
{
nValue = 0;
}
void SetValue(int *val)
{
nValue = *val;
}
const int& Getvalue()
{
return nValue;
}
};
// My managed wrapper class
// Notice how "__pin" is used in the set.
public __gc class ManagedWrapper
{
CUnManaged2* pUnManaged;
public:
ManagedWrapper()
{
pUnManaged = new CUnManaged2();
}
~ManagedWrapper()
{
delete pUnManaged;
}
// The wrapper call to unmanaged set.
void SetValue(int val)
{
int someValue = val;
int __pin* pinnedInt = &someValue;
pUnManaged->SetValue(pinnedInt);
}
// Do I need to pin this value?
// Is this safe??????
int GetValue()
{
return pUnManaged->Getvalue();
}
};
|
|
|
|
|
Is it possible to create an array of an __gc class?
When I try, it says I cannot define a size of a __gc class or inside it.
Any answers to these newbie questions is highly appreichated.
|
|
|
|
|
There is:
public __gc class CTest<br />
{<br />
CTest(){}<br />
};<br />
<br />
CTest *test __gc[] = new CTest __gc *[4];
|
|
|
|
|
hi
Suppose I want an application which takes a source file and outputs its data members and functions.
Supposed to develop into a kind of class view explorer.
Regarding parsing the source file ....
should i go for using regular expressions rules for this parsing or
should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing
or is there any other possible ideas for source file parsing
awaiting advice
fordge
|
|
|
|
|
1.What does the 'S' mean before "Hello World"?
2.Also- if I wanted to find this out using the help menu-- which filter would be correct? I can't seem to find the correct indexed 'S'.
Thanks in advance...
include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");
return 0;
}
|
|
|
|
|
I think the S just stands for System::String * __gc or just System::String... typing S is not the same as typing the others of course... but I think it is pretty much like ending a float with f such as float myFloat = 10.4f; In other words just a reminder or pointer for the program to understand what its dealing with.
It might be wrong though...
|
|
|
|
|
Sounds good to me... thanks
Is there a System::String * __value?
|
|
|
|
|
hi
I got 2 small projects on C++ data strucures...
pls downld the here
http://thatzme.com/project.ppt
I'm a little lost as to how to do them...
Any help will be highly needed...
thx
Danny
|
|
|
|
|
you didn't even take the time to Copy/Paste the text here...
poor boy. and you think we'll help you ?
personnaly, it stinks homework too much for me, i won't !
find someone else to do the bad job for you
ps: you got my 1
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I changed the Form1 class name using the Property dialog box, because I thought this would properly rename the resources also as it is mention in the header file:
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
...but it didn't. This is the exception I get when I try to run it in the debugger:
An unhandled exception of type 'System.Resource.MissingManifestResource' occured in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the assembly. Make sure "FormName.resources" was correctly embedded or linked into assembly "MdiApp".
...so how do I make these changes?
|
|
|
|
|
Try using Find and replace with search range current project.
|
|
|
|
|
I want a code for fingerprint core point detection
CYMA
|
|
|
|
|
Is it possible to create for example a control like Label in a way that it can be indexed with dimensions?
Example:
Label *myLabel[9][9];
Obviously the tests I have made shows that the compiler doesn't like this at all and fails.
Is there a way to use the built in classes or can you make your own Label class somehow? If so, how?
The program I'm implenting this into will consist of 9x9 Labels, like a board but it shall only contain numbers from 1-9. It's actually a puzzle called Sudoku. It consists of 9 3x3 boxes.
Rules of Suduko:
1. Place numbers (1-9) in each blank cell.
2. Each row (nine lines from left to right), column (also nine lines from top to bottom) and 3x3 block bounded by bold line (nine blocks) contains number from 1 throught 9.
|
|
|
|
|
Also.. now I have thought about an other way to solve this puzzle layout. My new solution does however come into the same problem after awhile.
The new one is more like this:
A sub sub class called PuzzleCell (just every single cell, should be 81)
A sub class called PuzzleBox (groups 9 cells together as a 3x3 box and check)
A class called Puzzle (consists of those 9 3x3 boxes)
But same problem... when I try to create/initiate the PuzzleCell and try to make it 81 of them by doing as this: PuzzleCell *puzzleCell[81], or without being a pointer. It gives me error about __gc classes cant do such things(not specify a size)?
How to solve this?
|
|
|
|
|
Hi,
I'm building an that schedule/records up to 4 streams simultaneously using DirectShow and .NET.
To get the best control of DirectShow, I've programmed a basic prototype in pure C++ (command-line only) to demonstrate the application will meet performance requirements.
Now I have to extend/reprogram the prototype to include a GUI. Since the other programmers here only know C# so the GUI will be programmed in C# - which is a good idea anyway.
The recorder (the part that builds/runs DirectShow graphs) for our previous product was written as an C++ ActiveX component, which turned out to be difficult to debug, extend and maintain. So, my recording engine will be written in Managed C++ as a .NET DLL to interface with the GUI.
My first basic prototype used Smart Pointers for DirectShow objects, but I think I cannot use ATL CComPtr within Managed C++ classes because I get compiler errors like:
error C3633: cannot define 'pGraphBuilder' as a member of managed 'RecorderMCpp::Pvr150Graph'
because of the presence of default constructor 'ATL::CComPtr<t>::__ctor' on class 'ATL::CComPtr<t>'
The docs recommend I delete my CComPtr<igraphbuilder> pGraph line to resolve this error. Is there a safe way to resolve this error?
Is there a safe way I can use smart pointers inside a Managed C++ class?
Since DirectShow COM objects are unmanaged, is there another way I can reference DirectShow objects from within a Managed C++ class?
As a last resort, I can write generic C++ class and create Managed wrappers, but I want to avoid that because it's more work.
Any help would be greatly appreciated with gold or subway tokens.
-CV
|
|
|
|
|
This is a REALLY interesting question.
I would think that Interopping the graphics data streams from your C++ basic prototype to the C# .NET GUI would reduce the performance of the resultant application to an unacceptable rate, especially processing up to 4 streams simultaneously. In reading the DirectShow FAQ, Microsoft recommends NOT doing this.
I suppose it could be done, however. I wish I had some good advice. You could easily create the GUI in unmanaged C++, using the standard Win32 APIs.
|
|
|
|
|
I've written the capturing code, but I've been unsuccessful at building a graph that captures and previews simultaneously with independant control. I don't think it's related to MC++.
Keeping DirectShow unmanaged pointers as member variables of a managed class, then safe releasing in the overrided IDisposable.Dispose() seems to work fine. ATL smart pointers are most useful inside functions where an error can occur at any point (like inside multiple loops), because clean-up when an occurs can be troublesome with so many COM objects to release.
Each graph will be running in seperate threads, so there shouldn't be any interference and did I forget to mention that most of the time encoding/multiplexing will be done on the capture cards? So, the only thing it has to do is really dump the MPEG2 program streams into a file. This is enough to for my demonstration in a few weeks.
-CV
|
|
|
|
|
I've been trying to convince myself to attempt something like this just to get inside the workings of DirectShow, but, honestly, your project is WAY beyond my current level of understanding.
I read the post you made above, and actually downloaded your code. Interesting stuff. I wish I could offer some intelligent suggestions, but, as you probably realized with my above response, my comprehension of DirectShow is primitive.
Thanks for the code, I haven't seen anything like it EVER at this site. You should do a tutorial.
|
|
|
|
|
LOL. I just re-read my post and some of it did not make sense. I should stop writing when I haven't had my morning cup o' awakeness.
Anywho, declaring managed classes with unmanaged code has worked reasonably well. I think it'll be great for this application. Not sure anymore what I was worried about.
"I've been trying to convince myself to attempt something like this just to get inside the workings of DirectShow, but, honestly, your project is WAY beyond my current level of understanding."
It's taken me about two months to understand DirectShow to the point that I can build reliable applications with it. That is while juggling another C# project and a Linux app. My work had a copy of "Programming Microsoft® DirectShow® for Digital Video and Television" and MSDN docs which have been my main source of DirectShow information. Plus, I'm not a very fast learner.
"I read the post you made above, and actually downloaded your code. Interesting stuff. I wish I could offer some intelligent suggestions, but, as you probably realized with my above response, my comprehension of DirectShow is primitive. "
I appreciate you responding in any case, because explaining my approach helps my own understanding. I was pretty much thrown into this situation because it's what the company needed.
"Thanks for the code, I haven't seen anything like it EVER at this site. You should do a tutorial."
I don't think what I've done is very good or difficult. If it turns out to be a reliable product then I might write a codeproject article. I didn't find the DirectShow .NET library to be very reliable for the DVD player and capture apps I've developed, but you should give that a try if you're interested in building DirectShow apps from C#.
-CV
|
|
|
|
|
I am using a ActiveX component that requires a "ref" to a Object like this:
Encrypt(ref object vaSource, bool bEndOfData);
To use this function in C# you do this:
object vaSource = "This is text";
object encryptedData = encrypt.Encrypt( ref vaSource, true );
What is the equivalent to "ref" in MC++?
|
|
|
|
|
In C++, a & gives you a reference to an object. Is MC++ different ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yea your correct!... I must have define my variable wrong, because when I tried it that way before I keep getting an compiler error. Now it is working.
Thanks!...
|
|
|
|
|
I have noticed that in some projects are using directive:
#using <mscorelib.dll>
But if i don't include in the project, the app is fine.
What are advantage and disadvantage of using it.
|
|
|
|