|
GetWindowText can only get text from the first pane. As I mentioned earlier, I already tried to send SB_GETTEXT to the CStatusBar control, but it didn't return anything.
|
|
|
|
|
Currently my c++ program sits on a recv() in the primary thread/loop. I want to be able to add one or more secondary threads that receive relatively low frequency data via tcp connections but want to immediately pass this information to the main thread. Is there a way I can signal the recv() in the primary thread to return via some mechanism initiated by any one of the secondary threads? Thought I could use waitformutlipleobjects but not clear how to set it up without moving the recv() functionality already in the main thread to a secondary thread.
Thanks
|
|
|
|
|
If you use WSARecv() with an OVERLAPPED structure instead of using recv() , the function will not block.
You can then wait on events using WaitForMultipleObjects or any of the other wait functions.
The secondary threads can then signal these events using SetEvent .
|
|
|
|
|
Not familiar with overlapped structure. Looked at a msdn example. Seems a bit complicated. Need to do a bit more research on this approach as well as let it settle in. If you can elaborate a bit more that would be appreciated.
Thanks
|
|
|
|
|
I have extracted the relevant code snippets from the MSDN example.
WSAStartup(MAKEWORD(2,2), &wsd);
ConnSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
connect(ConnSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
WSAOVERLAPPED RecvOverlapped = {0};
RecvOverlapped.hEvent = WSACreateEvent();
WSABUF DataBuf;
char buffer[DATA_BUFSIZE];
DataBuf.len = DATA_BUFSIZE;
DataBuf.buf = buffer;
WSARecv(ConnSocket, &DataBuf, 1, &RecvBytes, &Flags, &RecvOverlapped, NULL);
WSAWaitForMultipleEvents(1, &RecvOverlapped.hEvent, TRUE, INFINITE, TRUE);
WSAGetOverlappedResult(ConnSocket, &RecvOverlapped, &RecvBytes, FALSE, &Flags);
The call will block on WSAWaitForMultipleEvents .
Any thread can signal the event on RecvOverlapped.hEven t.
|
|
|
|
|
okay. I'll see if I can get this to work. Thanks!
|
|
|
|
|
Hi guys,
Here I am again... But now with another problem :p
SHCreateDirectoryEx(NULL, "c:\\text", NULL); gives me the following error:
1>d:\app2\app2\Form1.h(302) : error C2664: 'SHCreateDirectoryExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I found that _T("..") should work; giving me the following error:
1>App2.obj : error LNK2028: unresolved token (0A000028) "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>App2.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>D:\App2\Debug\App2.exe : fatal error LNK1120: 2 unresolved externals
Does anyone have experience with this function. I want to make a (n absolute) folder and the OS where this will be written for is Vista (sorry - I might upgrade to W7 tho).
Could someone give me some hints?
Kind regards,
|
|
|
|
|
Try referencing shell32.lib in Additional Dependencies option of the project Linker properties.
If you're doing a C++/CLI application, you should be using Directory::CreateDirectory instead.
|
|
|
|
|
I got an application. So called Windows Forms Application.
I will try Directory::CreateDirectory.
Thanks again.
----------
Edit:
The IDE (Visual C++ Studio 2008 Express) cannot find Directory::CreateDirectory . I might to include some file I guess...
----------
Re-edit:
CreateDirectory("c:\test", NULL); works... Sort of - now I get the following error:
1>d:\app2\app2\Form1.h(304) : error C2664: 'CreateDirectory' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
modified on Friday, November 13, 2009 1:06 PM
|
|
|
|
|
You need to tell me if it is a managed or unmanaged application.
Do you see using namespace xxx or #include xxx on the top of the file?
And what are they?
|
|
|
|
|
Plentyyyyyy lol
#pragma once
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include "Serial/Serial.cpp"
#include "shlobj.h"
namespace App2 {
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
|
|
|
|
|
CreateDirectory(_T("c:\\test"), NULL);
|
|
|
|
|
That works tho!
Thanks dude!
|
|
|
|
|
#include <shlobj.h>
int main(){
SHCreateDirectoryEx(NULL,"c:\\jinx",NULL);
return 0;
}
tested it with ms vc++ 2008. it works like charm
|
|
|
|
|
I am a beginner of c++. I have to do some image processing and computer vision. Can some one tell me if there is a function or library which is similar to imread in Matlab? Can you suggest me any book or useful resource for image processing in c++ ? I appreciate for helps,
Thank you
Mustafa ÖZENDİ
|
|
|
|
|
Image processing (other than loading and saving imaging) is an advanced topic and computer vision a bit more advanced, but can be fun to study because once you're able to do the basic operations, there's a world of fun stuff to do.
I assume imread is a function to load an image, so, you could use the CImage class to do that.
Other than that, I suggest googling a little bit; once you have more precise questions we'd be glad to help you more.
Good luck.
Max.
This signature was proudly tested on animals.
|
|
|
|
|
Check out the OpenCV library. It's currently being supported by Willow Garage.[^] There's a book about it "Learning OpenCV".[^]
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I have an SDI MFC App, the CMainFrame has an in value that is to be displayed on the status bar
I have a OnUpdateWhat method with a CCmdUI * parameter the performs a test text using the value of the int
The value is modified from my CFormView member using the CMainFrame's public function modifyRecCount this function assigns the new value to the status bar value,
I am expecting to get the OnUpdateWhat called when the value of the status bar value field is changed but nothing happens...can anyone help?
|
|
|
|
|
Have you added ON_UPDATE_COMMAND_UI() to the message map? If so, have you set a breakpoint in the handler function to see if it's being called (which is only during idle processing)?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Yes, have added command in MESSAGE_MAP of MainFrame as
ON_UPDATE_COMMAND_UI(ID_INDICATOR_WHAT, OnUpdateWhat)
ID_INDICATOR_WHAT is the indicator for the Last panel on the right in the status bar
a break point in OnUpdateWhat is never hit
|
|
|
|
|
lawrenca37 wrote: a break point in OnUpdateWhat is never hit
Have you added ID_INDICATOR_WHAT to the indicators array?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Yes
statuic UINT indicators[] =
{
ID_SEPARATOR,
ID_INICATOR_FNAME,
ID_INDICATOR_PROC,
ID_INDICATOR_WHAT
};
and in string table
ID_INDICATOR_WHAT 103
|
|
|
|
|
And you added a string resource named ID_INDICATOR_WHAT and gave it some value?
Do you see the pane in the status bar?
I just created a test SDI app and did nothing but the above and added the ID to the indicators array. Running the app showed 999 in the far-right pane. If you are not getting at least this far, all the rest is irrelevant.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Yes created a new project, and did all that was in the previous messages and
the what pane is initialized to 0,
Something interesting, I had code in the CMainFrame OnCreate function to resize the status bar width
for(int i=0;i<(sizeof(indicators)/sizeof(UINT));i++)
m_wndStatusBar.SetPaneInfo(i, ID_SEPARATOR, NULL, 100)
Removeing these line produced the initialize WHAT panel just like the test program...can you explain the order of event or why these lines coveted the panel
|
|
|
|
|
lawrenca37 wrote: ...can you explain the order of event or why these lines coveted the panel
No, but I can ask two questions:
1) Why are you changing the ID of each pane to ID_SEPARATOR ?
2) Why are you setting the pane's style to NULL ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|