|
You cross posted and you are not giving your questions titles with any meaning. Please read the forum guidelines.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
I'm using CRectTracker alongside another class that uses SetWindowLongPtr to subclass my CScrollView class.
Problem is when I perform a CRectTracker::Track() or CRectTracker::TrackRubberBand() the CRectTracker hogs all the messages and my subclass WndProc gets none until the Track method returns.
Is there a way to make CRectTracker behave and pass messages on down the chain while tracking?
|
|
|
|
|
During tracking, CRectTracker is in its own modal message loop, as you've seen.
I'm not sure what messages you need during tracking, but if you just need to
do something when the rect changes, you can override CRectTracker::OnChangedRect().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I basically need coordinate feedback while tracking. Nothing fancy.
I realized I could use CRectTracker::OnChangedRect() or even CRectTracker::DrawTrackerRect() but that requires a close binding to the entity instantiating my class derived from CRectTracker. I guess that's gonna be the solution though as I dug through the source and no other idea has jumped out at me.
On a side note, it always amazes me how the OOP purists claim classes should be small, do one thing well, and not require knowledge of their surroundings.
I've found that extremely hard to accomplish in practice.
Anyway, thanks for the feedback as it always helps to hear suggestions that are consistent with ones own gut reactions. I lack the confidence to realize that sometimes I might actually be on the right track.
|
|
|
|
|
bob16972 wrote: it always amazes me how the OOP purists claim classes
should be small, do one thing well, and not require knowledge
of their surroundings.
I've found that extremely hard to accomplish in practice.
I especially find that problem in UI programming with MFC. In a complex
UI, eventually windows need to communicate with each other. Most
say the window shouldn't have knowledge of other window classes so
all communication is done through messages up and down the Z-order.
That makes it more OOP pure (I guess) at the C++ level but often the
messages need to be so specific that the class is really not "generic" anyway.
Back on topic... to me, since CRectTracker isn't a window, if I have to
derive a class from it anyhow, I have no problem making a custom
tracker class specific to one window.
All it really needs to know is an owner CWnd to send messages to if it needs
to be more generic/reusable, just like it needs a CWnd to do its rubberbanding.
Have fun!
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi!
I'm looking for a way to monitor drive access using WinAPI. I want a notification when the drive is read or written.
Is this possible without getting down to NTFS/FAT etc.
You see, I am slightly confused at the moment.
Regards
Alex
|
|
|
|
|
ReadDirectoryChangesW()?
you can monitor all the writing to the drives using this function. But reading...
Other was is to implement a driver like the filemon does. The source code of that utility is also availabe in the net( I forgot the link to that site )
|
|
|
|
|
You'll need to create a driver for this level of control.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Mh, sounds quite difficult.
Do you have any hints for me where I can start from?
|
|
|
|
|
No, I've not done any driver-related projects. Try here. Dr. Newcomer knows his stuff.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
If the dll were loaded into memory for each app that required it, it would be a waste. Think of your own code, if you wanted to do the same calculation a few hundred times, would you code it a few hundred times or simply create a function and call that all those times? That's all a dll is, it's a set of functions that are used very often during the life cycle of you're OS's session.
|
|
|
|
|
Thanks Walder. But, my doubt is on how shared library is implemented.
We have A.exe and B.exe, using C.dll. When A.exe starts execution, C.dll (code + data) is loaded to memory. Where is this loaded into memory ? Within the process space of A.exe or outside ?
If B.exe also starts execution, and since the DLL is shared, won't it cause the problems of race condition ?
|
|
|
|
|
Dll's do not normally store data, if they do that data is not shared amongst processes. For the most part, the OS will handle the loading dll's, it will track the open handles, when there are none it will unload it.
Also, you do not need to worry about race conditions, this is related to multi threaded apps, not multi instance. A CPU, regardless of how powerful, can only execute one code at a time. The way your OS works, it divides this power between each app. Normally, ( think of a message loop now ) a program executes, then waits.
Add:
while ( true )
{
}
to your code and watch your system freeze, the app refuses to release the CPU to others.
What I'm trying to say is, the same piece of code will never be executed at the same time by two different processes.
|
|
|
|
|
WalderMort wrote: What I'm trying to say is, the same piece of code will never be executed at the same time by two different processes.
Untrue (although admittedly it depends on what you mean by the "same code"). Systems with multiple CPUs or CPUs with multiple cores are commonplace.
Steve
|
|
|
|
|
xavierakx wrote: Within the process space of A.exe...
Yes.
See here[^] for more.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, Thank you all! I followed link by links...
I could get a very good article on shared libraries, that cleared my doubts. Thought of sharing -
http://www.iecc.com/linker/linker09.html
|
|
|
|
|
Hi,
Im working with this article:
http://www.codeproject.com/internet/client_server_socket.asp[^]
Can any1 help me how to re-connect Client?
Like after typing in QUIT, later type CONNECT and again connect to server w/o restarting Client app?
I tried to use shutdown(sock,2) and back to where I initialized connection:
myTcpSocket::initialize()
....
But i get WSAEISCONN and client closes itself :/
When i try closing socket with closesocket(sock) and when re-connecting back to myTcpSocket::initialize()
...
client stays alive but doesnt connect as i get WSANOTSOCKET.
I need help, i rebuild this example to be non-blocking, everything works great but i want it to disconenct and when i want to connect to server w/o the need to close client.
Huge thx in advance. It's a matter of life and death
|
|
|
|
|
hello,
The sample you are looking needs quiet a bit of modifications to work like your expectations.
The server is written for only one client connection, if you need to use it for multiple client connections you need to bring the acceptClient() also inside the while loop.
while()
{
acceptClient()
client->recieveMessage
if(BYE)
{
/* Close client Socket, you can delete the client socket by deleting the client pointer the destructor ~mySocket() will close the socket */
delete client;
continue;
}
client->sendMessage
etc.
}
/* Close Server Socket */
Refer these two samples for more understanding
http://www.codeproject.com/internet/winsockintro01.asp
http://www.codeproject.com/internet/winsockintro02.asp
Arun Krishnan
|
|
|
|
|
Thx for replay.
I found the problem, something was corrupting my socket. Can't remember now what, I cleaned the code, create new socket after closing older one, assign it to socket class and it all works w00t
|
|
|
|
|
am locking for get the function names through .Net tools like dumpbin.exe
from the dlls like use32.dll and shell32.dll it provide the name of function included int that dll but does not show the number of argument and datatype of the arguments.
Plz help me out and give me some helpful hints.
|
|
|
|
|
Just read the header file for the dll. They are all there in you "include" directory. Refer to MSDN for which header go's with which dll, but the names are pretty simple.
|
|
|
|
|
Only functions exported as C++ functions have their names decorated to include the return type and parameter list. Windows APIs are exported with C linkage so all you get is the function name.
|
|
|
|
|
Hey Friends
I wish to play a sound whenever an item is added to a listbox in another application (for which i do not have the code)
Now it appears that i should create a dll & set some type of hook
but which type?
has anybody tried this or have any relative info?
Regards
|
|
|
|
|
Check SetWindowsHookEx with idHook = WH_GETMESSAGE.
Don't try it, just do it!
|
|
|
|