|
Thanks Ash and Cool caw for the replies.
|
|
|
|
|
Aescleal wrote: Pointer and array questions are on my list of danger sign questions
Well, they'd both be high on my list of questions to ask.
Can you grok pointers? You don't have to be a complete C head and do them in your sleep, but if you can't handle the abstract thought needed, then there's little point in wasting any more of each others time. It's one of those "you either get it, or you don't things".
In STL, you still have:
iter++;
iter->DoStuff ();
which is at the least, pointer-esque.
Asking about linked lists was a self contained scenario - and again demonstrates a bit of abstract thinking.
As for singleton stuff? My last job wrote software dealing with real physical machines. I used a few singletons. I used it rarely, but it was essential to have the concept. I wouldn't penalise someone if they knew the idea, but not the magic word.
Thread safety, exceptions, etc would also make it on my list - I hope that reassures you!
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Guys,
I am trying to use OnLButtonDblClk() in TabControl, so I want to do is When someone double clicks in tab Control I Want Tabcontrol resize to my mainframe so it will be overlapped to formview and only tabcontrol will be visible in mainframe. Tabcontrol is inside FrameView. So anyone got an idea how to Solve this Problem?
|
|
|
|
|
Hey guys.
I have one MFC Class with Form with lots of buttons and radiobuttons,Edit Control they are basically Functions for Calculator Now I Used OnDraw() to plot graphs in Formview. There are like 9 Graphs and I want to get each Graph in tabs.Afterwards i realized that TabControl Only support CDialog. So I have to create 9 Diffrent Class for each Tabs and then draw all graphs again there. I found out OnDraw() doesnt get called in DialogBox i wrote OnPaint and pointed that function to OnDraw() but now OnPaint() is not getting called by itself. I Googled everything about OnPaint() and read almost all Forums about it but still couldn't solve it. So basically I am not able to Draw anything in Dialogs(tabs). I cannot call any methods of formview from my dialog box because the values formview contains cannot be access by cdialog class since formview is not initialized when you call CDialog Functions so i get access violation errors.
If any one understand this problems or have any opinion Please Reply.. I will post some error codes and pseudo code for my programs..
Thank you..
|
|
|
|
|
hi..
As per my knowledge OnPaint() is called when ever any dialog is resized,
minimised or maximized.
Only thing which i have understood is that u r trying to make a calculator..
Hoping that Im Right..
All the Best..
|
|
|
|
|
When i call invalidate() it just refresh the mytabcontrol and it blinks but it doesnt actully redraw the graph with new values. this is like scientific calculator with function on top inside formview and graphs on tabview(dialog mode). so each time i switch tab or change values in calculator it has to redraw graph depending upon the new values in calculator. if anyone have got idea how to do this or any hint.
PLEASE...
<<<<post here="">>>
THANKzzzzz
|
|
|
|
|
hi
If u r making a calculator,
u cn tk help of Visual C++ Programming By Mr.Yashwant Kanetkar
Page no.434.there he has given sum hints on this topic..
Hope U solve your Problem soon..
All the Best
tc..
|
|
|
|
|
tanu misra wrote: u cn tk
Is your kbd broken? You seem to be missing some vowels.
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
thank you all for reply. I solved the problem, Calling ON_WM_PAINT() in your TabControl Class will call OnPaint.
But when i switch tabs it suppose to Call OnPaint each time so it redraw the graph. I called INVALIDATE() but doesn't seem like working since TabControl is not mainwindow. INVALIDATE only refresh the main window not the tabcontrol ..
|
|
|
|
|
But the client can connect.
some of the test codes
server
void post_io_request_of_accept(SOCKET so_listen, PerIoData * per_io_data)
{
DWORD bytes_received;
BOOL ok = AcceptEx(so_listen,
per_io_data->so_local,
per_io_data->buf,
0,
sizeof(SOCKADDR_STORAGE)+16,
sizeof(SOCKADDR_STORAGE)+16,
&bytes_received,
per_io_data);
DWORD err = GetLastError();
if (ok)
{
assert(false);
}
else if (err==ERROR_IO_PENDING)
{
}
else
assert(false);
}
DWORD WINAPI ServingThreadProc(LPVOID pParam)
{
DWORD bytes_tranfered;
ULONG_PTR completion_key;
PerIoData * per_io_data;
while (true)
{
BOOL ok = GetQueuedCompletionStatus(HANDLE(pParam),
&bytes_tranfered,
&completion_key,
(OVERLAPPED**)&per_io_data,
INFINITE);
assert(ok);
handle_io_completion(per_io_data);
}
return 0;
}
client
int main()
{
WSADATA wsa;
int res = WSAStartup(MAKEWORD(2,2), &wsa);
assert(res==0);
SOCKADDR_IN addr_in;
addr_in.sin_family = AF_INET;
addr_in.sin_addr.s_addr = inet_addr("127.0.0.1");
addr_in.sin_port = htons(5150);
ZeroMemory(&addr_in.sin_zero, sizeof(addr_in.sin_zero));
SOCKET s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);
assert(s!=INVALID_SOCKET);
int ok = connect(s, (sockaddr*)&addr_in, sizeof(addr_in));
assert(ok==0);
for (int i=0; i<10; ++i)
{
char buf[256];
sprintf_s(buf, sizeof(buf), "message %d", i);
WSABUF wsa_buf;
wsa_buf.buf = buf;
wsa_buf.len = strlen(buf);
DWORD bytes_sent;
int res = WSASend(s, &wsa_buf, 1, &bytes_sent, 0, NULL, NULL);
assert(res==0 && bytes_sent==wsa_buf.len);
printf_s("sent: %s\n", buf);
Sleep(1000);
}
WSACleanup();
return 0;
}
If use PostQueuedCompletionStatus , GetQueuedCompletionStatus will be unblocked.
What is the problem?
Thanks.
modified on Friday, August 6, 2010 11:38 AM
|
|
|
|
|
|
Hello,
I have an MFC dialog based application which does come sequence of tasks one after other.
Each process takes few minutes to complete.
I popup a dialog with cancel button on it with status of current task.
If use selects cancel on the popup dialog. The process has to wait till the current task complete and then stop executing next task.
Can someone tell me how to wait on process till it complete and then execute the mouse event.
Thanks in advance.
|
|
|
|
|
You can do something like this: when the user presses Cancel, set a flag about it, then disable the button and optionally setup a label on you progress dialog that advice "Cancel in progress...", finally at the end of each task check the flag and if it is set stop processing the remaining ones.
|
|
|
|
|
The IProgressDialog[^] interface provides everything you need for such a situation.
It's time for a new signature.
|
|
|
|
|
Thanks for the suggestion..
Any pointers for IProgressDialog example, would be of great help. As i am getting errors during compilation.
Else have to follow the other method.
Thanks a lot for the help..
Regards..
|
|
|
|
|
Member 3834630 wrote: Any pointers for IProgressDialog example,
I gave you the link in my previous message; it's a fairly simple one to implement.
Member 3834630 wrote: i am getting errors during compilation.
Well, unless you tell us what the errors are we cannot help much.
It's time for a new signature.
|
|
|
|
|
Dear all
I am doing a project which my professor ask me to perform perspective reconstruction with 2 USB camera and C++.
May I know is it possible to get signal from the two USB camera by C++ at the same time?
Also, is it possible to perform real-time perspective reconstruction by C++?
Thank you
|
|
|
|
|
Here your answers:
- yes, it is possible: you have to use DirectShow to do it, instantiate two
IGraphBuilder and connect each of them to a different device - you have to add an
ISampleGrabber filter to each of the two IGraphBuilder : this will give you the ability to grab a frame from the two devices in your code and process them. Anyway, it depends on what you mean with real-time: the two devices are not synchronized each other, then the two frames are not referred to the same time (the maximum time unalignment between the two frames depends on the frame-rate of the two devices)
|
|
|
|
|
I have no knowledge about DirectShow, so I may asking some stupid question, sorry.
Reply to your answer.
If I have two USB camera and connecting to my compuer, how can i get the signal and store into IGraphBuilder? What code should I write?
After I looked for some reference, someone is using the following code to get the signal:
IMoniker * pMonCam1 = NULL;
IMoniker * pMonCam2 = NULL;
pMonCam1=getDevices(0);
pMonCam2=getDevices(1);
Is these code can already get the signal?
|
|
|
|
|
Using the DirectShow is a bit more complicated! As a pre-requisite, you need to be able to deal with COM programming.
Look at these links to get an idea about what you should do:
You can also have a look to the OpenCV library[^]: it's a huge library initially developed at Intel and later released to the open-source. It gives a lot of functionalities about image processing (OpenCV stands for Open Computer Vision), then you could find in it useful algorithms both to capture the video stream from various devices and to process the images aquired...
|
|
|
|
|
Hi I have two char array which I need to fill by parsing the string.
char * str = "1,aaa\r\n2,bbb\r\n3,ccc\r\n4,ddd\r\n"
now the the first value(1,2,3,4 in this case ) has to fill in first array and second value(aaa,bbb,ccc,ddd in this case) has to fill in second array.
Can anybody please help me how to do this.
please provide me a sample code if possible.
Thanks
|
|
|
|
|
Tokenize thrice. Once with "\r\n" as the delimiter to count the number of array elements. Allocate two new arrays with that size. Then repeat the previous tokenizing to split one line and then tokenize the got line with "," to get the number and the text. Keep an index counter and fill both the arrays simultaneously.
You must be able to code what I said.
...byte till it megahertz...
|
|
|
|
|
Thanx for ur reply, Can u please gv me some ssample code as I m new in c++.
|
|
|
|
|
NO.
...byte till it megahertz...
|
|
|
|
|
Well, because you have indeed attempted something, I'll help with a very very basic implementation.
void Job()
{
char *data = strdup("1,aaa\r\n2,bbb\r\n3,ccc\r\n4,ddd\r\n");
char *p = data;
int n = 0;
while(*p)
{
if('\r' == *p)
{
n++;
p++;
}
p++;
}
char **text = new char*[n];
int *nums = new int[n];
int i = 0;
char *tok = strtok(data, "\r\n");
while(tok)
{
char *t = tok;
while(*tok)
{
if(',' == *tok)
{
*tok = 0;
nums[i] = atoi(t);
t = tok+1;
}
tok++;
}
text[i] = strdup(t);
i++;
tok = strtok(NULL, "\r\n");
}
for(i = 0; i<n; i++)
free(text[i]);
delete [] text;
delete [] nums;
free(data);
}
It is not recommended to play around with too many pointers. Use std::string and std::vector in place of arrays. And use strtok_s(...) instead of strtok(...) to reduce those loops into simple function calls. I am using VC6 which doesn't have that and hence have written out those loops.
...byte till it megahertz...
|
|
|
|