|
dispose is of no help. consider resizing a window it is about dozen resize messages and you end up with no free mem. it does not delete the Bitmap object immediatly once executed!?
Thats the great disadvantage of .NET objects you can not resize them once allocated nor delete them
Simple Borland Builder posses all these features, the only disadvantage is its debugging process, VC provides more useful quickwatch.
9ine
|
|
|
|
|
9ine wrote: consider resizing a window it is about dozen resize messages and you end up with no free mem. it does not delete the Bitmap object immediatly once executed!?
Like I said, you can delete the bitmap every time, Dispose does this.
9ine wrote: Thats the great disadvantage of .NET objects you can not resize them once allocated nor delete them
NOR DOES BORLAND BUILDER !!!
9ine wrote: Simple Borland Builder posses all these features
You're just plain wrong. Borland cannot change the nature of Windows, it cannot create a world where you can resize a bitmap without deallocating and reallocating it. All it can do is hide the facts from you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
then the builder is more succesfull in hiding windows facts from me than the native VC does.
dispose results in delayed memory deallocation
9ine
|
|
|
|
|
Yes, that is precisely what a wrapper does. MFC doesn't wrap bitmaps in a way to hide these facts. It's no different to std::vector or CArray. Using those, you'd never guess that you can't create an array and then just keep adding stuff to it without it having to reallocate memory. The class hides this task from you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I wonder if builder is using a DIB Section below the surface.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
What is it. and is it useful?
The problem is to render promptly floating array of data to a window.
Once you created bitmap in Builder you can alter its size without deleting it. So without a flick you can plot the data you want.
.NET graphics is good for ploting image files not some floating array to fit a window.
Probably the only solution to a lame .NET graphics is opengl one?
9ine
|
|
|
|
|
http://www.3dsoftware.com/Programming/WindowsAPI/DIB_Section/[^]
Realize that builder isn't just alerting the size; it is recreating bitmaps below the surface and copying the old data to the new one. Using DIB Sections you could do this copy fairly quickly.
One solution is to write the code you want at the Win32 layer with C++/CLI. Another is to look around and see if any company is selling a toolkit that does what you want. I'd also suggest working with .NET some more and thoroughly understanding the graphics layer to make sure there isn't a great third solution I haven't thought of. (Oh, and you may need to rethink how you are doing your application. Perhaps a different algorithm on your part would make a purely .NET solution viable.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi All,
I am New user for vc.net,
My code is
String ^str1=L"1",^str2=L"2",^str3=L"3";
String ^str=String::Format("{0}{1}{2}",str1,str2,str3);
MessageBox::Show(str);
But I want Increase the String length like
in VC++;
CString str;
str.Format("%25s%15s%15s",str1,str2,str3);
I want modify above code like that
Plz suggest me
Nagaraju
|
|
|
|
|
You need to look into formatting support in .NET. String.Format does not do formatting just template placement. ToString() supports formatting. Also see IFormatProvider and NumberFormatInfo etc.
String ^str=String::Format("{0}{1}{2}",str1->ToString(IFormatProvider),str2,str3);
led mike
|
|
|
|
|
What! no printf style formatting support? What kind of C based language does not somehow provide printf style formatting.
Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class.
-- modified at 12:46 Tuesday 8th August, 2006
|
|
|
|
|
bob16972 wrote: What kind of C based language
If you are doing mixed mode you can still use the C++ formatting libraries.
bob16972 wrote: Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class.
Have not done any Java in the past couple of years, don't know if I ever will again.
led mike
|
|
|
|
|
just a disclaimer... That wasn't meant toward you. I was gasping aloud so my apologies if that came off as somehow blaming you. When I reread it, it just doesn't sound right so again, my apologies.
|
|
|
|
|
I knew that but thanks for the concern, Also see George Jacksons reply which shows how String.Format uses format specifiers. He picked up my slack.
led mike
|
|
|
|
|
You can do this:
String ^str = String::Format("{0,25}{1,15}{2,15}", str1, str2, str3);
for with the values right-aligned and this:
String ^str = String::Format("{0,-25}{1,-15}{2,-15}", str1, str2, str3);
for values left-aligned.
-- modified at 15:35 Tuesday 8th August, 2006
|
|
|
|
|
Thank U very Much George,
I wish u all the best
Nagaraju
|
|
|
|
|
Hi..
Has anyone wrapped the ODBC Native API into a managed C++ class. From what I have researched natiive ODBC API is still the fastest way to fecth records.
Sk8tz
.NET Rules
|
|
|
|
|
Code Project Articles[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Is theer any api or code to play a continuous stream of PCM (wave)data...
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
Hello
I have to use a Win32 API in a C# project (VS 2K5). I want to create a API wrapper class in C++. And then use it from my C# code.
I tried to use P/Invoke in C# to create a wrapper class, some of the methods didn’t work because Pointers to memory were not working..
QUESTION 1
Now how do I create a wrapper class, save it as dll and use it in C#. Please tell me whole procedure.
Because when I try to create a C++ project The VS2005 gives me a list of templates to choose from like “CLR Console Application” “Windows Forms Application”, etc etc
Question 2
My project has a method that continuously reads a block of PCM data from an external radio receiver connected to the computer through USB.
Is there and way to listen to that signal through C#. IS PCM just like audio signal … if not how do I convert it into audio.
------------------------------------------------------------------------------------------------
I am writing an example of the function I have to write and tell me what type of project I have to make and what procedure I have to follow.
#include "stdafx.h"<br />
#include <stdio.h><br />
#include <windows.h><br />
<br />
typedef int (__stdcall *FNCOpenRadioDevice)(int iDeviceNum);<br />
typedef BOOL (__stdcall *FNCCloseRadioDevice)(int hRadio);<br />
typedef BOOL (__stdcall *FNCSetAtten)(int hRadio, BOOL fAtten);<br />
typedef BOOL (__stdcall *FNCSetPower)(int hRadio, BOOL fPower);<br />
typedef BOOL (__stdcall *FNCSetAGC)(int hRadio, int iAGC);<br />
typedef BOOL (__stdcall *FNCCodecStart)(int hRadio,void (__stdcall *CallbackFunc)(void *),<br />
void *CallbackTarget);<br />
typedef BOOL (__stdcall *FNCCodecStop)(int hRadio);<br />
typedef unsigned int (__stdcall *FNCCodecRead)(int hRadio,void *Buf,unsigned int Size);<br />
<br />
typedef struct {<br />
int hRadio;<br />
FILE *IFFile;<br />
FNCCodecRead CodecRead;<br />
} CallbackContext;<br />
<br />
void __stdcall CodecCallback(void *Target)<br />
{<br />
unsigned int i;<br />
char Buf[4096];<br />
CallbackContext *Ctx=(CallbackContext *)Target;<br />
<br />
while ((i=Ctx->CodecRead(Ctx->hRadio,Buf,sizeof(Buf)))!=0) <br />
fwrite(Buf,i,1,Ctx->IFFile);<br />
}<br />
int main(int argc, char* argv[])<br />
{<br />
HMODULE dll=LoadLibraryA("wrg303api.dll");<br />
if (!dll) {puts("WRG303API.DLL not found !"); return 0;}<br />
<br />
FNCOpenRadioDevice OpenRadioDevice=(FNCOpenRadioDevice)GetProcAddress(dll,"OpenRadioDevice");<br />
FNCCloseRadioDevice CloseRadioDevice=(FNCCloseRadioDevice)GetProcAddress(dll,"CloseRadioDevice");<br />
FNCSetAtten SetAtten=(FNCSetAtten)GetProcAddress(dll,"SetAtten");<br />
FNCSetPower SetPower=(FNCSetPower)GetProcAddress(dll,"SetPower");<br />
FNCSetAGC SetAGC=(FNCSetAGC)GetProcAddress(dll,"SetAGC");<br />
FNCCodecStart CodecStart=(FNCCodecStart)GetProcAddress(dll,"CodecStart");<br />
FNCCodecStop CodecStop=(FNCCodecStop)GetProcAddress(dll,"CodecStop");<br />
FNCCodecRead CodecRead=(FNCCodecRead)GetProcAddress(dll,"CodecRead");<br />
<br />
int hRadio=OpenRadioDevice(0);<br />
if (!hRadio) {puts("No WR-G303 device could be opened !");FreeLibrary(dll); return 0;}<br />
<br />
if (SetPower(hRadio,TRUE)) puts("The device is turned ON"); else puts("The device failed to turn ON");<br />
if (SetAtten(hRadio,FALSE)) puts("The attenuator is OFF"); else puts("The attenuator failed to turn OFF");<br />
if (SetAGC(hRadio,3)) puts("The AGC is FAST"); else puts("The AGC failed to switch");<br />
<br />
FILE *f=fopen("IF2.pcm","wb");<br />
<br />
CallbackContext Ctx;<br />
<br />
Ctx.hRadio=hRadio;<br />
Ctx.IFFile=f;<br />
Ctx.CodecRead=CodecRead;<br />
if (!CodecStart(hRadio,CodecCallback,&Ctx)) puts("Codec streaming couldn't be started!");<br />
else {<br />
puts("Codec streaming properly started!");<br />
while (!ftell(f) ) <br />
{<br />
}<br />
CodecStop(hRadio);<br />
fclose(f);<br />
}<br />
<br />
if (CloseRadioDevice(hRadio)) puts("The device is closed properly"); else puts("The device failed to close");<br />
<br />
FreeLibrary(dll);<br />
<br />
return 0;<br />
}<br />
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
t4urean wrote: Now how do I create a wrapper class, save it as dll and use it in C#
Create a "Class Library" project using Visual C++.
t4urean wrote: Please tell me whole procedure.
That is not what the forums are for "whole procudure". There are articles here on Code Project and also on msdn.microsoft.com that show the "whole procedure".
|
|
|
|
|
I have a strange problem that has been driving me up the wall. I created a SSCCE that shows my problem. Compile this with cl /EHsc /clr <filename> :
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#include <iostream>
int main()
{
using System::Windows::Forms::DialogResult;
using System::Windows::Forms::FolderBrowserDialog;
using System::Windows::Forms::MessageBox;
double d;
std::cin >> d;
FolderBrowserDialog* fb = new FolderBrowserDialog;
if (fb->ShowDialog() == DialogResult::OK) {
MessageBox::Show(fb->SelectedPath);
}
}
When I run this program as is, after entering a number on the command line, the FolderBrowserDialog comes up blank. However, if I comment out the std::cin >> d; line, then the FolderBrowserDialog works fine. Does this happen for anybody else? Or am I misusing the mixture of managed and unmanaged code? I am using VS .NET 2003 on Windows XP SP2, with the .NET 1.1 Framework.
--
Marcus Kwok
|
|
|
|
|
OK, I found a solution that seems to work. In the article Mix and Match: Integrate Windows Forms Into Your MFC Applications Through C++ Interop (http://msdn.microsoft.com/msdnmag/issues/06/05/MixAndMatch/[^]), I found this piece of advice:If you compile with the /clr option, your code implicitly depends on the multithreaded DLL version of the C runtime libraries (CRT). This means that all files in your project—even those compiled without /clr—must use the multithreaded DLL version of the CRT. Adding /MD to the compile command seems to fix it. Incidentally, this also seems to fix my earlier problems (here and here).
--
Marcus Kwok
|
|
|
|
|
Hi,
I've got a problem with my wrapper class and my wrapped native object:
How can the wrapper be notified if the native object inside is modified?
Background: I want to wrap a library where an observer pattern is implemented. There the native observer observes a native subject where it was registered. If the subject notifies the registered observers about a change my observer-wrapper was not notified.
What should I do to make this work? I thought about something like function pointers and delegates but I think I'm on the wrong track.
Or is it possible to pass a managed object as a parameter to a native object's function?
Example:
class AbstractSubject
{
public:
virtual ~AbstractSubject() {};
virtual void Attach(IObserver*);
virtual void Detach(IObserver*);
virtual void Notify();
protected:
AbstractSubject() {};
private:
std::vector<IObserver*> observers;
};
class IObserver
{
public:
virtual ~IObserver() {};
virtual void Update(AbstractSubject* theChangedSubject) = 0;
protected:
IObserver() {};
};
As you can see the IObserver is a interface class. This interface class is wrapped by a managed c++ interface-class. The native observer object registeres itself on the Attach(IObserver*) -method and is added to the observers -vector.
If the Nofify() -method of the subject is called the subject iterates over the observers-vector and calls Update(this) (observerobject->Update(this)) on the observer object to notify the observer that something changed.
But how can I add now my managed class or my managed object to the subject to be notified? Please correct me when I'm wrong but I think I cannot pass the managed-observer-handle to the native method to notify the managed observer.
BTW: I don't have to source code for the native classes. I only have got a DLL-file, a LIB-file and some header-files to access the classes in the native lib.
Any help would be appreciated.
Thanks a lot for you help!
Best regards,
Ralf
|
|
|
|
|
I am a new C++ video game design student. I'm really not loving this C++ class cause my teacher is from tiawan and only knows like 100 words of english and when he puts them together in a sentence they are in the wrong order anyways. So i'm NOT understanding what it is he is telling us or asking of us. But i need help, or i need the code written for me or something. but we are on vectors and he wants us to make a list using 'iterators' that we can input our favorite video games. list them, and erase them. then he wants a quit fucntion to end the program.
can someone please help me.
|
|
|
|
|
You should also learn to read sticky notes in forums. This forum is for C++/CLI questions only, your question is off topic here. It's generally rude to crosspost, in any case.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|