Jump to content
Xtreme .Net Talk

bwells

Avatar/Signature
  • Posts

    85
  • Joined

  • Last visited

Everything posted by bwells

  1. I see your point. The idea was that I want the main form to be up but blank until the user finishes dealing with the modal dialog. Then I want to populate the application form with controls based on what they selected from the "select project" dialog. So the idea is that I want the main app to be fully built and displayed, and then I want to pop up a modal dialog that they have to deal with. The main app being in the background is to look good, and actually has no added value. But I dont want this modal dialog to be made visible in response to anything the user does. Instread I want it to be visible AFTER the main form is fully done and visible. But if I start the modal dialog from the OnLoad event, then it blocks the main app form from showing. Then, the thread issue with the timer is because of what happened. If I start the timer from the thread I run the modal dialog from, then the timer does not run. It ends when the modal dialog thread ends. So after the user is done with the modal dialog, I want to populate the main app with controls and then I want to start the timer. So perhaps I can start the timer when the child form of the main app is visible. But I still do not know how to show the modal dialog on top of the main app form before the user does anything.
  2. I have a form which is my main application. I want my app form to be up on the screen, and then I want a modal form to be on the screen and the user must select an option from this modal form before they can work in the main app. In order to do this, I ran the modal form on its own thread because if I do not, then the modal form blocks the main form and I do not see the main form until after the user has selected their option from the modal form. As a result of my modal form being in its own thread, I am unable to start a timer in response to the user's selection on the modal form because the thread the modal form is running in ends after the user makes their selection. Fruthermore, after the user selects something from the modal form, I want to add a component to the collection of controls owned by the main form. But if I try and add to this collection from the modal form thread, I get an exception saying that I cannot add to the collection from a separate thread. So my questions are: 1) How can I show the user a modal form on top of the main app and now block the main app? Is there a way to do this without putting my modal form on a separate thread? 2) If my modal form must be on a separate thread, then how can I start a timer from the main thread with an even that happens on a separate, temporary thread? Is there a way I can cause an event to happen on the main thread from a separate temporary thread? 3) Is there a way I can add controls to my main app form from a temporary thread? The basic deal seems to be if I can find a way that my temporary thread can tell my main form to do things on the main thread, that would fix things. The other option would be to find a way to get my main form up on tthe screen and have a modal form show on top of that, withouth running my modal form in a spearate thread to prevent it from blocking the loading of the main form. But the problem with this is I still have to add to the main form's collection of conrols which must be done on the main thread. thanks Bryan
  3. I have written a C++ class which implements an interface. The problem is I do not know how to find out what methods on the interface are not implemented until runtime. And even then, I get a generic error message saying the class is abstract and cannot be instatiated. Is there a way to get the compiler to show me methods in the interface which I forgot to implement? thanks Bryan
  4. I have a UserControl which I want to change to a Panel. In my UserControl, I used the Load event to initlialize the children of the UserControl. How can I do this for the Panel class? It does not have the Load event. thanks Bryan
  5. Bitmap* Managed_COSP_9054::COSP_9054_VA::getVideoImage( ) { unsigned char __nogc *buffer = new unsigned char[ sizeOfUL * imageNumPixels ]; // read 3 bytes per pixel for RGB value if( !this->m_cosp_va->getVideoBuffer( imageNumPixels, buffer )) return 0; array24bit = new unsigned char[ sizeOfUL * 3 * imageNumPixels ]; for ( int i = 0; i < sizeOfUL * imageNumPixels; i++ ) { Byte item = buffer; array24bit[3*i] = item; // B array24bit[3*i + 1] = item; // G array24bit[3*i + 2] = item; // R } delete[] buffer; Bitmap *bmp = new Bitmap( imageWidth, imageHeight, imageStride, PixelFormat::Format24bppRgb, array24bit ); return bmp }
  6. one option this is the code to convert the other way. fname is a managed type String. ufname is an unmnaged char*. void* pfname = Marshal::StringToHGlobalAnsi(fname).ToPointer( ); char* ufname = (char*)pfname; Marshal::FreeHGlobal((int)ufname); I see in the Marshal class, there is a method Marshal.PtrToStringUni Method which copies an unmanaged Unicode string to a managed String object. and Marshal.PtrToStringAnsi Method Perhaps you can figure out what to do from there. Bryan
  7. Thanks for the idea of using this bitmap constructor. I tried this and it seems to be the fastest way to transfer the memory data to a bitmap.
  8. I see I can use the BitmapData associated with a Bitmap to modify the data of a bitmap. I have constructed a Bitmap of the correct size, and I have an array of byte data which is organized correctly for the Bitmap I want to create. Since I am working in C++, if I use the scan0 returned from the BitmapData, can I use memcpy to transfer my image data into the bitmap? The scan0 field of the BitmapData returns an IntPtr. Can I use memcpy with an IntPtr to copy my unmanaged data into the bitmap? thanks Bryan
  9. The data is an image of some audio sampled by custom audio hardware. So in effect, the image is a "raw" image. So I already have some code that write a RAW file from the memory, and then I have a routine that reads the raw file into a Bitmap. But I want to remove the intermediate step of the RAW file and go directly from memory into a Bitmap object for display. I want to show this as an animation that is running through 9FPS, so I want the translation from memory to Bitmap to be as fast as possible.
  10. I have a project which uses a UserControl I wrote. I can write the code directly and it all works fine where I have added references to the DLLs of the associated projects containing the controls I wrote. The program runs as expected. But if I try and use the designer, and I drag a my UserControl onto a Form, I get an error saying that a file or assembly or one of its dependicies was not found. But the associated DLLs are in the Debug folder on my system, and the program runs fine if I code it manually. So I wonder if anyone can suggest where the Designer looks for files to resolve dependendencies. It seems to be different than when it resolves dependendencies at run time. How do I tell the Designer where to find the DLLs it will need when it uses a UserControl that I wrote? One of the dependencies that the Form will need is NOT an assembly, but an unmanaged DLL which I wrote. But I cannot add a reference to a unmanaged DLL, so I simply copied the unmanaged DLL into the Debug folder where the program and other assembly dependencies are found. thanks Bryan
  11. But in my case, I created the MemoryStream and used the MemoryStream Write method to write an array of data to the Stream. So I did not specify the dimensions of the Bitmap. I am worried that I SHOULD specify these dimensions when I create the MemoryStream. Do I need to write more than the array of data to the stream in order for the header to be correct? The array of data is simply 1024x512 bytes of data in a one dimensional array. I want this to end up in a Bitmap so the Bitmap is 512 wide, and 1024 tall. thanks Bryan
  12. I understand that I "can" make a new bitmap using the constructor that takes a width and height. But what I am asking is if I construct a bitmap using a MemoryStream (not a FileStream), where does the bitmap get its width and height?
  13. Here is my confusion. I have a one dimensional array of byte data I loaded from some audio hardware. I want to transfer that data into a Bitmap object so the data can be represented as an image which is 512x1024. 1) I create a MemoryStream object and call the Write method to transfer my pointer to my byte array into the MemoryStream. So at this point, the MemoryStream is just a stream of bytes and has no dimension, only a length. 2) I call the Bitmap constructor passing in the MemoryStream. Now a Bitmap object has been created, and it still does not have a width or height. So at what point in this flow does the Bitmap get a width and height? Another way of doing this would be: 1) construct an Image object using the FromStream method. 2) Construct a bitmap using the Image, and a width and height. Now I understand how the Bitmap has a width and height, but in the first case, there is not any time that I speicify a width and height, yet I still have constructed a Bitmap object.
  14. If I construct a Bitmap object from a Stream object, how do I specify the dimensions of the bitmap? I see one option would be to construct a Bitmap at the desired size, and then use the FromStream method to load the Bitmap object. Can someone help me to understand how a Bitmap which is constructed from a Stream gets its width and height? Thanks Bryan
  15. I have a program which reads raw image data from audio hardware. I am reading the data in unmanaged C++ code. In a managed C++ routine, I have a pointer to an unmanaged unsigned char array. I would like to load a bitmap object with this data so I can display the data by calling the DrawImage method on a Graphics object. How can I transfer an unmnaged 512x1024 unsigned char array into a managed Bitmap object for display? If I dump this memory into a "raw" binary file, I can load the file into Photoshop as an interleaved raw format file, so untimately, I want to see the same image on my form. thanks Bryan
  16. bool setSRAM( String* fname ) { void* pfname = Marshal::StringToHGlobalAnsi(fname).ToPointer( ); char* ufname = (char*)pfname; // do your stuff with ufname here Marshal::FreeHGlobal((int)ufname); }
  17. How can I convert from a managed string (String*) to an unmanaged const char* to pass from a managed C++ class to a unmanaged C++ routine?
  18. I have a splash screen which is a basic Form that contains a label. When the main application constructor is called, I instantiate the splash screen and show the splash screen on top of the parent application. In the splash screen class, I start a timer which waits for 3 seconds and then hides itself. The problem I have is when the splash screen is first shown (using the form.Show() method ), the area on the Form where the label is located shows through to what was on the desktop before the parent application window was shown. Then, after about 2 seconds, the label fills in with the text it is supposed to show. The label has a transparent background which seems to be picking up the desktop at the very begining when it is first shown. All of this code is very basic. Can anyone suggest what I could do to get the splash screen label to be displayed correctly at the start of the splash screen display? Is there a way to show the splash screen in a separate thread that would help? When I tried this, the thread ends imediately so the splash screen only up for a few milliseconds. thanks Bryan
  19. Actually what I needed is a slider that support a discrete set of values with an increment other than 1. Originally, my post was to see if I could get a log scale where the values on the slider would be the log of log of a computed value. Overriding the Value property, I was able to take care of this, but I still cannot get a good scale with numbers that match the values. So instead I display the values in a text area beside the slider. What I still need to do is to draw the tick marks and numbers that match the the computed value in a way that they are not evenly spaced. 0.1 1.3 1.699 2.0 3.0 5.0 10.0
  20. Yes, I was asking how to do it in Managed code. I have a way that I got to work, but I am not sure its the prefered way. I am using a FileStream and the BinaryWriter.Write method. But the binary writer write method does not take a unsigned long so I cast it to be _int32. Do you think this works? What would you recommend? I have an array of unsigned longs to write, but when I did an array write, it was writing bytes insead of longs. Is there a way to write an array of unsigned longs from Managed C++, or should I iterate over the array and write each element? thanks Bryan
  21. I have an array of long integers and I want to save them to a binary file. I can do this in managed or unmanage c++. What is the easiest way to do this? thanks Bryan
  22. I have defined an C# interface with a method that returns an object. How do I define the implementation for this method in C++? public interface ICOSP_9054_Connection { object getConnection( ); } Or how can I declare an interface method in C# which returns a void* so I can implement the method in C++?
  23. works great!
  24. I have written an interface and a class that implements the interface. If I instantiate the class that implements the interface and then try and cast the class to be the type of the interface, I get a class cast exception. I am using __interface which I though is what the documentation suggested. Perhaps this is wrong? What is the difference between _interface, interface and __interface? When I use Intellisense in the debgger from the constructor of a class that implements the interface, it shows the interface as a struct. Is this correct? Here is my interface: #pragma once using namespace System; namespace COSP_9054_Interfaces { public __gc __interface ICOSP_9054_Connection { bool loadBoard( ); String* lastError( ); void* getConnection( ); }; } I stepped into the constructor and observed in the debugger that the class being constructed does indeed implement the interface. Yet if I do an explicit cast to the Interface type: ICOSP_9054_Connection* obj = (ICOSP_9054_Connection*) derivedClass; I get a class cast exception. I tried doing: dynamic_cast<ICOSP_9054_Connection*>(derivedClass) as well, but this just returns null. How come I cannot cast a derived class to be the type of the interface it implements? thanks Bryan
  25. When I try writing a C++ function my unmanaged C++ class which returns a char[], I get a compiler error C3409 empty attribute block is not allowed. Am I doing something wrong? thanks Bryan
×
×
  • Create New...