|
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
|
|
|
|
|
Please can you give me exactly how to use this function in the code?
|
|
|
|
|
|
Thanks it works fine. with UtcNow
|
|
|
|
|
Hello,
I am experiencing some link errors and would like to ask your help please.
I have a managed C++ workspace, which contains the main app (.exe) and a DLL project that it links to called Editor.dll.
The DLL contains MFC classes for the doc/view classes (e.g. CEditorDoc, CEditorView, etc).
The DLL builds fine, but the main application .exe (managed C++) produces link errors when these DLL classes are used
within it, as demonstrated below:
Linking...
WindowsApplication.obj : error LNK2028: unresolved token "public: static struct CRuntimeClass
* __stdcall CEditorDoc::GetThisClass(void)" (?GetThisClass@CEditorDoc@@$$FSGPAUCRuntimeClass@@XZ) referenced
in function "int __thiscall CWindowsApplication::InitInstance(void)"
(Please note the header files are included in the main app file where they are used too).
The link errors all seem to be related to a "GetThisClass()" function which i think seems to have trouble being
exported out of the DLL (it is a member of base class MFC). All other functions seem fine. I also have tried
using a .def file but it doesnt seem to help.
Any help would be greatly appreciated. Thanks!
modified on Wednesday, June 3, 2009 8:34 AM
|
|
|
|
|
James1976 wrote: a DLL project that it links to called Editor.dll.
Links to how? Did you link to the impost library (Editor.lib)?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your reply.
I couldnt link the .lib (Editor.lib) as the .lib file is only generated if the DLL contains any exports, which it doesnt currently.
I cant export the function that has the link error (the GetThisClass() function) as its not in my code. Its in the MFC base-class and i cant override it in order to place a "declspec(export)" in front of it.
Also i cant export the entire class since it contains managed C++ code and so cannot be exported (only a class that does not contain managed code can be exported it seems).
Any further suggestions would be appreciated? Thanks.
|
|
|
|