|
OK!I still want to thank you for your kindness.
|
|
|
|
|
While using some of the DirectShow sample codes I run into an application using Menu to select, as an example, video devices. I have been using standard pull-down combo box for camera selection.
I am wondering, if a simple selection is the goal, is such Menu preferred by some of you gurus?
At this point I have not tried to incorporate it into MFC application, but seems like it would have to be dynamically build Menu instead of MFC static menu.
Forgive me if I am inventing my own terminology here.
What's your take on this “dynamic” Menu idea?
Cheers
Vaclav
|
|
|
|
|
The answer is "it depends". Some applications will only ever use fixed menus, while others will require different menu items, where dynamic menus would be preferable. It is really for you to decide based on what the application is required to do.
Use the best guess
|
|
|
|
|
Please consider that in most cases just "greying out" menuitems is a better option than hiding them because it makes it easier for the users to find items. You know, "XYZ submenu, 10th item...". Of course sometimes only generated menu works, but even in that case you can get away by making only one or a few submenus generated and keeping the generated menuitems and the static ones separated to make it easier to find the static ones for the user.
|
|
|
|
|
Hi people. I've been reading Programming with POSIX Threads (I've been learning pthreads by myself) and I always get some errors when I attempt to use flockfile and funlockfile and I don't know how to get rid of these errors. Can you help me? thanks.
#include <pthread.h>
#include "errors.h"
void *lock_routine (void *arg)
{
char *pointer;
flockfile (stdout);
for (pointer = arg; *pointer != '\0'; pointer++) {
putchar_unlocked (*pointer);
sleep (1);
}
funlockfile (stdout);
return NULL;
}
void *unlock_routine (void *arg)
{
char *pointer;
for (pointer = arg; *pointer != '\0'; pointer++) {
putchar (*pointer);
sleep (1);
}
return NULL;
}
int main (int argc, char *argv[])
{
pthread_t thread1, thread2, thread3;
int flock_flag = 1;
void *(*thread_func)(void *);
int status;
if (argc > 1)
flock_flag = atoi (argv[1]);
if (flock_flag)
thread_func = lock_routine;
else
thread_func = unlock_routine;
status = pthread_create (
&thread1, NULL, thread_func, "this is thread 1\n");
if (status != 0)
err_abort (status, "Create thread");
status = pthread_create (
&thread2, NULL, thread_func, "this is thread 2\n");
if (status != 0)
err_abort (status, "Create thread");
status = pthread_create (
&thread3, NULL, thread_func, "this is thread 3\n");
if (status != 0)
err_abort (status, "Create thread");
pthread_exit (NULL);
}
after running valgrind --tool=helgrind --tool=drd
=5790== Thread 3:
==5790== Conflicting load by thread 3 at 0x053fb7e8 size 8
==5790== at 0x4E4D063: flockfile (in /lib64/libpthread-2.15.so)
==5790== by 0x4009B6: lock_routine (putchar.c:20)
==5790== by 0x4C2D231: ??? (in /usr/lib64/valgrind/vgpreload_drd-amd64-linux.so)
==5790== by 0x4E45E0D: start_thread (pthread_create.c:305)
==5790== Allocation context: BSS section of /lib64/libc-2.15.so
==5790== Other segment start (thread 2)
==5790== at 0x513E291: clone (clone.S:84)
==5790== Other segment end (thread 2)
==5790== at 0x510FCAD: ??? (syscall-template.S:82)
==5790== by 0x510FB50: sleep (sleep.c:138)
==5790== by 0x4009DB: lock_routine (putchar.c:24)
==5790== by 0x4C2D231: ??? (in /usr/lib64/valgrind/vgpreload_drd-amd64-linux.so)
==5790== by 0x4E45E0D: start_thread (pthread_create.c:305)
==5790==
Create thread 3 "putchar.c": 64 Success
t==5790==
==5790== For counts of detected and suppressed errors, rerun with: -v
==5790== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 38 from 38)
|
|
|
|
|
so here it is, I really dont know how to program
here the problem :
I have a file .txt format, in which there are many number sequentially down.
for example :
+1
+2
+3
+4
+5
etc...
eg: my data have 100 number down, I have to divide them into 10 parts. later the file become 10 file .txt format, in which there are number 1 - 10 (part one), 11 - 20 (part two), 21 - 30, etc ...
and the program must be made from C++. Thanks for help
|
|
|
|
|
If this an excersise question you won't learn if you don't try and solve this yourself.
here's a link to file io
file io
but if you haven't a clue, you should start at the tutorial introduction and work through some things until you feel confident to tackle the file splitting puzzle. Orphaned files are a nightmare, if you don't catch errors and close the file before your program exits correctly.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
ok, I will try
thanks for qoute 
|
|
|
|
|
Hi moonstalker,
Here is the solution for your problem,
#include "stdafx.h"
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fHnd = fopen("C:\\sample.txt", "r+");
char *pBuffer = new char[5];
for (int nFileCnt = 0; nFileCnt < 10; nFileCnt++)
{
std::string strFileName = "";
sprintf((char *)strFileName.c_str(), "C:\\File%d.txt", nFileCnt);
FILE *fHndWrite = fopen(strFileName.c_str(), "a+");
for (int nCnt = 0; nCnt < 10; nCnt++)
{
fgets(pBuffer, 5, fHnd);
fwrite(pBuffer, 1, 3, fHndWrite);
}
fclose(fHndWrite);
}
fclose(fHnd);
return 0;
}
In this code assuming you keep your numbers in the file "Sample.txt" file and after you run the code you will get 10 files generated with the names such as File0, File1 etc. Each of these files consist of 10 numbers.
Bye.
|
|
|
|
|
I agree with dusty_dex, the poster should have attempted a solution first, instead of being provided a cut and dry answer to his homework. This is not a forum for quick homework answers, and should be kept clear of students who are too lazy to attempt solutions to their homework. If the poster had provided sample code and asked for bug hunting help, then it would have been a different matter entirely.
|
|
|
|
|
Hello People,
I am quite a newbie to C++ programming and I got stuck up with a simple program. The program requires me to print the value for 2 raised to the power 20. I actually had the idea creeping about this program since 1 megabyte is 2 raised to the power 20. I wanted to find the result of that via this piece of code:
#include<iostream.h>
#include<conio.h>
int main()
{
int a=2;
for (int i=2; i<=20; i++)
{
a=a*a;
}
cout<<a;
getch();
return 0;
}
and the output I get is: 0
The compiler/IDE I'm using is Borland C++ (latest version) but I know theres nothing wrong with the compiler though. There must be some logical mistake. Rectification would be appreciated folks. Hoping for help.
Thanks!
Rajdeep_
modified 23-Mar-13 3:55am.
|
|
|
|
|
You are not raising it to the 20th power, you are repeatedly squaring the value, The first time through the loop you get 4 (2*2), then 16 (4*4), then 256 (16*16), and so on.
Use the best guess
|
|
|
|
|
Thank you. I will work on that part.
|
|
|
|
|
a is a integer data type .you are printing the value by multiplying it 19 times and which in return it exceeds more than LONG data type .hence your output is always zero .
There is no compiler problem.
I think you got what I am explaining you. 
|
|
|
|
|
int x,total = 1 ;
for(x=0; x<20; x++){
total += 1<<x; //
}
|
|
|
|
|
total = 1<<20;
Use the best guess
|
|
|
|
|
You need to multiply a by 2 twenty times. Something like:
int a = 1;
for (int i = 0; i < 20; i++)
a = a * 2;
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I am not sure this question belongs here, but I am attempting to reach wide audience.
Just installed DirectX 8.1 and it will work for me.
Got distracted into installing DXSDK June2010 version because it was “advertized” especially for XP.
Had a heck of time uninstalling it, because it did not have much of DirechShow in it.
Now I found a tutorial for DirectX 9.0.
I certainly do not want to repeat the fiasco of DXSDK June2010 installation.
What really scares me is the “DirectX (9.0c) is a system's (resource) and cannot be uninstalled”.
So here it my question – what is current, usable, with DirectShow sample codes DirectX (SDK) still workable under XP?
And as I said - I am "happy" with DirectX 8.1.
It seems that MS is now supporting only Win7 and up with their DirectX SDK's.
Please – no more “XP is going unsupported by 2014”, heard that too many times, and that is not what I am asking for.
Thanks for reading.
Vaclav
Addendum
Just run dxdiag and it reported DirectX 9.0c installed! I am going to finsh my app using 8.1 before reinstalling anything. This is realy scarry beacause I did instaled 8.1 only!
-- modified 22-Mar-13 15:18pm.
|
|
|
|
|
I had trouble unistalling that version too. It left a trail of devastation in the registry. Never bothered with DX since.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Under normal circumstances,if the second parameter of the InternetOpen is INTERNET_OPEN_TYPE_PRECONFIG ,The function will automatically follow the registry select proxy. The important is automatically.
But in my program, I call InternetSetOption set proxy, and the problem is the internetopen can not automatically follow the registry select proxy any more.
I can change the proxy but .
How can i change it back ? to automatically.
please help , its realy pressing. Thanks.
the code :
InternetSetOption(NULL, INTERNET_OPTION_PROXY, (LPVOID)&oProxyInfo, sizeof(oProxyInfo));
hInternet = InternetOpen(_T("Thanks"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
|
|
|
|
See the note under INTERNET_OPTION_PROXY on this MSDN page[^].
Use the best guess
|
|
|
|
|
Q1. What would be the contents of queue Q after the following code is executed and the following data are entered?
Q = createQueue
Loop (not end of file)
Read number
If (number not 0)
Enqueue (Q, number)
Else
Queuerear (Q , x)
Enqueue( Q , x)
Endif
End loop
Data are – 5, 7, 12, 4, 0, 4, 6, 8, 67, 34, 23, 5, 0, 44, 33, 22, 6, 0
|
|
|
|
|
Q2. Have you read this[^]?
|
|
|
|
|
What do Queuerear() and Enqueue() do?
Think of a queue as a movie-ticket line (i.e., FIFO). The numbers represent people, with 0 being a special person. Do this on paper. What do you get?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Choosing which information that Windows Vista's folder contents displayer is to display for each folder. Please, how, from within a Visual C++ program, can I tell my Windows Vista's folder/directory contents displayer, to display for each file in folder/directory X this: Name, Size, Dimensions, Date modified, and nothing else? (I know how to search through a tree of folders from within a Visual C++ program.)
Or, please what is the web address of the online information page where I can read how to do this?
Earlier today (by British time) I called Windows Vista's folder/directory contents displayer's "search for a file", and in every folder that it looked at, it reset the information display pattern to Name, Folder, Tags, Size, Rating, Dimensions, Date modified. (I have no use for Rating; what are these Tags?; the Folder column is no use except in a search result.) To avoid this, ahould I resort to "the trail and the packhorse again" and write my own folder-tree-searcher?
|
|
|
|
|