|
No, that was added in VC7 (or maybe 7.1, I forget). There's no simple way to do it in 6.
|
|
|
|
|
please check my thread on the c# forum, any idea ?
(thread: "Bizzare question")
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=1697316&df=100#xx1697316xx
thanks,
Liron
|
|
|
|
|
Liron Hirsch wrote: please check my thread on the c# forum, any idea ?
Why, are you wanting a VC++ answer?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
it might help me too, a guy in the C# forum replied and said I might find the answer in c++
|
|
|
|
|
If you have a question C++ you can ask on this forum not shift to another forum
|
|
|
|
|
Your response would be valid had he asked here first and then asked in a separate forum. In reality, he first asked in the C# forum and was then redirected here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Liron Hirsch wrote: please check my thread on the c# forum, any idea ?
(thread: "Bizzare question")
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=1697316&df=100#xx1697316xx
really it's impossible mission for VC++ guys...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
hi
how to validate a given directory path ( in a remote machine whether the path is valid or not) in vc++?
and also how to execute a dos command in MFC?
|
|
|
|
|
Gokul_md wrote: how to validate a given directory path ( is valid or not) in vc++?
How about PathIsDirectory() ?
Gokul_md wrote: how to execute a dos command in MFC?
Like you would anything else, use CreateProcess() or ShellExecute() . However, some DOS commands have an equivalent API (e.g., dir, copy).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
This is only working for local directories. Not for remote shared path validation. how to check the remote machine shared directory path is valid or not?
|
|
|
|
|
Is PathIsUNC() any better?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Gokul_md wrote: This is only working for local directories. Not for remote shared path validation. how to check the remote machine shared directory path is valid or not?
PathFileExist
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
Hi there everyone!
I've been coding a multithreaded application for a while and due to some big changes in the application I've decided to recode it all from the start.
Together with the new changes, thread safety has really become an issue and it's made me realise how hard it really is to design a multithreaded application. So after thinking for weeks and reading all I've come over I think it's time to ask around for some advice :]
My application runs two main threads:
* One for the GUI (Win32 Console)
* One for a TCP socket listening for incoming HTTP requests (yes, it works as a basic webserver)
The application also runs 10 worker threads for handling http requests. These threads are in a pool that keeps handling each and every http requests that is queued.
The reason I use a thread pool is that handling a request can take some time, for instance if a complicated script is executed or a large file is requested and I don't want one request to block another.
The Webserver supports a very simple script langauge (similar to ASP). Using this, the client can both access and modify a lot of objects on the server, such as Users, Statistics, Settings.
This is where the problem lies: These objects needs to be thread safe. Say for example that one http request modifies a username while three another http requests at the same time wants to output the username.. adding to this, maybe the GUI also wants to display this username at the exact same time... this is where it can all go very wrong if it's not thread safe.
As a note I can say that I'm currently using the boost library 'shared_ptr' for accessing these objects through manager classes, for example: UserManager, LogManager, StatisticsManager.. etc Maybe one possibility would be to write a wrapper around the shared_ptr for thread safety??..
But to be honest I really haven't come up with the perfect way to solve this. It's a lot of objects that can be accessed by both the GUI, the Webserver and the Worker Threads, so honestly, wrapping every get/set accessor up in Mutexes isn't a very pretty solution.
So well, I thought it might be a good idea to see if anyone here have any ideas on how I can design this, or just do some brainstorming :]
thanks!
//na
|
|
|
|
|
Presumably the manager classes are created before the worker threads are active, so putting synchronization at that level seems appropriate. It is necessary then to prevent one thread from writing changes to these objects while others are also trying to read or write to them.
This article presents one technique for accomplishing such synchronization:
http://www.codeproject.com/threads/ReaderWriterLock.asp [^]
|
|
|
|
|
>>But to be honest I really haven't come up with the perfect way to solve this. It's a lot of
>>objects that can be accessed by both the GUI, the Webserver and the Worker Threads, so
>>honestly, wrapping every get/set accessor up in Mutexes isn't a very pretty solution.
It's not always pretty
I use a little helper class to make it a bit prettier:
<br />
class CMyCriticalSection<br />
{<br />
private:<br />
CRITICAL_SECTION CritSec;<br />
public:<br />
CMyCriticalSection() {::InitializeCriticalSection(&CritSec);}<br />
virtual ~CMyCriticalSection() {::DeleteCriticalSection(&CritSec);}<br />
<br />
void Enter() {::EnterCriticalSection(&CritSec);}<br />
void Leave() {::LeaveCriticalSection(&CritSec);}<br />
};<br />
So, for member variables that need thread access protection I add a CMyCriticalSection object:
<br />
class CMyClass<br />
{<br />
protected:<br />
CString Str;<br />
CMyCriticalSection StrCritSec;<br />
public:<br />
void ThreadSafeSetStr(const CString &);<br />
};<br />
<br />
void CMyClass::ThreadSafeSetStr(const CString &newstr)<br />
{<br />
StrCritSec.Enter();<br />
Str = newstr;<br />
StrCritSec.Leave();<br />
}<br />
Mark
|
|
|
|
|
You do not necessarily need to use a multi threaded approach with your server.
If locking and inter-thread-communication becomes a burden try a software architecture where socket connections are handled in one single thread context. When all sockets are running in the same thread context there is no need for locking shared data structures anymore. There are a couple of Unix web servers which follow this architecture (e.g. thttpd, mathopd), for Windows try the MFC class CAsyncSocket.
Hope this helps, feel free to brainstorm more...
|
|
|
|
|
first TrackPopupMenu,then how to response right button click on the menu?
thank you here
|
|
|
|
|
make one more menu IDR_MENU2
add handler
oncontext menu write code
void CChildView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CClientDC dc(this);
CRect rect;
GetClientRect(&rect);
int h,w;
h=rect.Height();
w=rect.Width ();
CMenu conmenu;
conmenu.LoadMenu(IDR_MENU2);
CMenu *p=conmenu.GetSubMenu(0);
p->TrackPopupMenu(TPM_CENTERALIGN|TPM_RIGHTBUTTON,point.x ,point.y ,AfxGetMainWnd() );
CWnd::OnContextMenu(pWnd,point);
}
and on RButtonDOWn u write ur code
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Thank you.
but I mean this:
I used trackpopupmenu showed a popup menu,then I want to do something when I right click on the menu,pay attention, I mean right click on the menu not right click to show the menu.
so,the point is how to handle right click on a popup menu message.
|
|
|
|
|
there r msg handlers for right click event also like WM_RBUTTONDOWM and so on
....u may use that event .....that code was for pop up menu
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
3141592653 wrote: so,the point is how to handle right click on a popup menu message.
you have to map the Menu ID with the It's respective Handller!
|
|
|
|
|
use english to ask your question, otherwise, people here won't understand what you're trying to achieve...
|
|
|
|
|
Hi All
How to implement printing without using Print Dialog ?
How to set default values (Paper size, Orientation etc) to Print Dialog ?
KK
|
|
|
|
|
|