|
Thanks a lot you people!
I'm very happy of always getting such good answers.
Respect, for me you are number #1 in the web!
On Topic:
I'll test your way to create bitmap tomorrow, it's late in europe right now
It looks good, but I remember some problems as I wanted to get it done like that.
The cam I use is a monochrome Leutron PicSight P52M-USB, and the only way I get monochrome
Bitmaps done is to assign the Format8bppIndexed - which further made some problems in resizing,
so that I have to work with a temp-Image. I'm not happy with that, but I didn't get a better way yet.
I'd be more happy with not having to work with marshaling between managed and unmanaged. But my company
has "old" native interfaces (one for graphic, one for cam), which must not be changed. So I had to delegate
all function (the way I got it done is also from codeproject) - but it seems to me as a not very stable solution,
to call a managed GUI in creating a thread from native and so on...
Maybe someone wonders about an odd comment, please let me know.
I may be on the wrong way somewhere...
Thanks again for your time, bye!
|
|
|
|
|
Hi,
I have a COM component developed in VC++ which provides hundreds of interfaces.
Many people use this component in their managed code using interop DLLs.
1. I just want to know if this is the right way of doing it?
2. Does it make sense providing a .NET assembly for them to do development in the .NET environment?
3. Is there any advantage if we use .NET assemblies instead of using COM via interop DLLs?
4. Is there any good article that explains how to convert unmanaged COM into managed assembly using managed C++?
Thanks in advance
cheers
Varghese Paul
|
|
|
|
|
I don't know that there is a definitive "right" way to do that. It likely depends on what services your COM components are providing and what the use model is etc. That said you should take a look at how Microsoft provides managed assemblies for using the Office Object Models. They are called Primary Interop Assemblies[^], and how they are different (better) than the standard Interop Generated .NET code.
|
|
|
|
|
Hi!
I have a windows forms control of the following type with 4 Labels in it:
*****************************
*label1......*label2........*
*****************************
*label3......*label4........*
*****************************
Each oft the labels has to fill exactly one quarter of the whole form, because the background color
of the labels is changed at runtime and it doesn't look good if the color fills just the back oft the text.
Labelproperty autosize seems like a simple solution, but if i set it, the label is always just as big as the text is.
Without autosize, it looks not bad, but I don't get it to split in the center.
It looks like that:
*******************************
*label1...............*label2 *
*label3...............*label4 *
*******************************
The rightern labels don't grow with the control, the remain on rightern side in their usual size.
Anyone an idea?
Thanks, cherry
|
|
|
|
|
I would set the Anchor property of labels 1 and 3 to Left, and set labels 2 and 4 to Right (this keeps the left/right edge of the label a fixed distance from the corresponding edge of the form. Then implement on OnResize event for your form, and set the Width of labels 1 and 3, and the Left of labels 2 and 4, like so:
void OnResize(Object^ sender, EventArgs^ e)
{
label1->Width = Width / 2;
label3->Width = Width / 2;
label2->Left = Width / 2;
label4->Left = Width / 2;
}
You may need to add a slight offset to one of these if the labels look like they overlap at all, but this should get you started. You can also do something similar to this for making your labels fill the form vertically.
Dybs
|
|
|
|
|
Thanks Dybs, that might help - I just thought it could be made more nicely.
Something like autosizing with setting the anchors to all sides...
Thanks and bye!
|
|
|
|
|
I've tried setting both the left and right anchors, and it didn't quite get me there. If labels 1 and 2 start out as:
|label 1|
|label 2|
and you set both the Left and Right anchors for both labels and then stretch the form, your labels will overlap like so:
|label 1|
|label 2|
Like I mentioned above, the anchor keeps the edge of your control a fixed distance from the edge of its container. This fixed distance is in pixels, not percentage or proportion, unfortunately. If you find a nicer way to do this though, let me know! This is something I run into all the time, and this is the best I've been able to do so far.
Dybs
|
|
|
|
|
Hi,
this is what I would do:
- add a TableLayoutPanel to your Form; by default it has two rows, two columns, resulting in four identical areas.
- dock or anchor it as appropriate.
- add a label in each cell of the TableLayoutPanel; dock-fill them and set TextAlign=ContentAlignment.MiddleCenter.
Now the labels are centered and their background exactly fills a quarter of the TLP.
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.
|
|
|
|
|
Don't know why I didn't think of that. I've spent a good part of this week working on resizing the cells in the TLP!
|
|
|
|
|
Hi All
I Hope this is the right forum to post this query.
I have created a test environment with a server and a client. On the server i have posted a small website with a zip file "abc.zip". When I try to download this file using Webclient with the below code it works fine
hWebClient->DownloadFile("http://170.10.10.80/mySite/abc.zip", "c:\\myFolder\\abc.zip");
When I try to use UriBuilder as shown below i always get the "invalid uri the hostname could not be parsed." exception.
UriBuilder ^hUriBuilder = gcnew UriBuilder();
hUriBuilder->Host = "http://170.10.10.80"
hUriBuilder->Path = "mySite/abc.zip";
hWebClient->DownloadFile(l_hUriBuilder->Uri, "c:\\myFolder\\abc.zip");(Exception)
I have tried to set other parameters as well like
hUriBuilder->Scheme = Uri::UriSchemeHttp;
hUriBuilder->Fragment = gcnew String("main"";
hUriBuilder->UserName = gcnew String("user");
hUriBuilder->Password = gcnew String("passwd");
Tried different combinations of Host like removing "http://" adding another "/" at the end and "http://170.10.10.80/mySite".
but same exception "invalid uri the hostname could not be parsed."
I even tried to use a generic host like "www.codeproject.com" just to check if its the IP address thats causing the problem but even then when i try to access
hUriBuilder->Uri same exception is reported.
Any ideas what wrong i am doing or if i am missing any step.
I am using vs2005, OS XP and server is windows 2003
Thanks
gurindersm
|
|
|
|
|
gurindersm wrote: Any ideas what wrong i am doing or if i am missing any step.
I've never used UriBuilder, however based on the documentation[^] you don't appear to using it correctly. It does not seem that including the protocol "http" in the .Host property is correct.
|
|
|
|
|
Hi,
I have a CLI audio recording program which uses WaveIn and WaveOut to record.
1. I need to prepare buffer and should be able to use for less time i.e., prepare the buffer for 30 mins but should be able to stop at 15 mins and save it to file. I am not able to do this now.
2. I need to get the path of the file. I need to record to a temp file and access it.
The audio's source is Microphone. It can record for custom # of seconds. I mean, when you run VoiceRec.exe and press enter, it would ask you for the # of seconds to record. After I give a number, it prepares the buffer for that time, starts recording and saves it to a file.
But what I want is, I would like to start recording and when the user presses any key, it should stop recording and save it to a WAV file.
http://rapidshare.com/files/240845783/Working_VoiceRecording_2_.rar.html
|
|
|
|
|
Do you really have to ask the user for the # of seconds up front?
Why not just record? Open a FileStream for writing, keep writing data until
the user stops the operation or the harddrive fills up, then close the FileStream.
If you need it buffered in memory as well, use a MemoryStream as well.
Streams....nice and consistent - they are your friends
I bet the FileStream class documentation[^] has all kinds of sample code...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I don't know much C++/CLI, but my previous experience with streams have resulted in poor performance. Specifically, using a generic stream library ignores issues such as asynchronous I/O for better performance, sizing of I/O to match the underlying I/O system (ie. block size considerations based on filesystem I/O size or disk block size), efficient use of a memory cache with a size matched to the application or expected hardware configurations, and the use of threads around a well sized buffer.
Of course, if this is a "toy" application then this is all superfluous. Or perhaps Microsoft has provided more optimization to their streams than they have in the past?
|
|
|
|
|
I was referring to System.IO.Stream and its derived classes here.
I also assumed that since the source is a microphone, there probably isn't
a large audio bandwidth issue here.
IME, FileStream is more than capable of storing audio as it's captured, at least
to modern drives. MemoryStream works fine as well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i want to use in my code CTime!!!
any one can help
|
|
|
|
|
how about
1) try some patience & manners
2) use :-
#include <ctime>
[edit] this is asuming you dont mean the MFC CTime class - if you mean that you'll have to add the MFC includes etc if you havnt build an MFC project [/edit]
'g'
|
|
|
|
|
|
#include <atltime.h>
COleDateTime has a better range
#include <ATLComTime.h>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i'm using window forms application and i'm facing a problem with a variable date_time that hold
a long value 1243930978
I need to convert this number to datetime
Note : when i declare the variable as "CTime sss" it give error undeclared identifier "sss"
any one can help?
|
|
|
|
|
|
Hi,
this forum is about C++/CLI, that's the managed C++ dialect, part of .NET
it has a very nice DateTime class with some constructors, and useful methods such as Parse() and TryParse().
AFAIK there is no CTime in its universe.
Are you in the right forum? for plain C/C++ and MFC use the appropriate forum!
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.
|
|
|
|
|
The value, 1243930978, is calculated from the number of seconds from 1/1/1970. To convert to a DateTime , you must account for this offset:
DateTime time_offset(1970, 1, 1);
DateTime time_converted = time_offset.AddSeconds(1243930978);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Wednesday, June 3, 2009 4:36 PM
|
|
|
|
|
Thank you very much, i want you to know that i spend 2 days on this.
and now you gave me the right answer Thankkkkkkkkk youuuuuuuuuuuuuuuuuu.
i tried it works it gave me 3 hours difference and i handle it by adding 10800 sec
to the number. but why it gave me difference 3 hours?
|
|
|
|
|
If the value was created on computer in local time EST, and it was converted on a computer in local time PST, you will have a 3 hour difference. You should use coordinated universal time (UTC) and adjust the time according to the local time of the computer. .NET has DateTime.UtcNow and DateTime.ToUniversalTime and C/C++ has gmtime .
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Thursday, June 4, 2009 8:02 AM
|
|
|
|