|
You need some thing like spy++. I believe I have seen a simular program here at codeproject. You can also look at sourceforge.
The difference seems to be that you want to listen to all message sent to your program. This is easy if it was written in C, but if you are using MFC (or some other frame work) then you needed to understand where the frame work is rerouting the messages so you can intercept them.
Hey! With a little patience you can single step through, from the beggining, any (Windows) application to determine how to intercept all messages.
INTP
|
|
|
|
|
hi..i need help on a prob pls...
i have a proj where i draw a rect in the OnDraw of my proj's View...
code:
--------------------------------------------------------------------------------
//
//Set the mapping mode to LOENGLISH
//
pDC->SetMapMode(MM_LOENGLISH);
//
//Convert arguments to coordinates to MM_LOENGLISH units.
//
CSize szTemp;
szTemp.cx = pDoc->GetGridX();//get the left of the rect to be drawn
szTemp.cy = pDoc->GetGridY();//get the bottom of the same rect
pDC->DPtoLP(&szTemp);
//
//Draw the size preview
//
CRect rect( 10, -10, szTemp.cx, -szTemp.cy );
pDC->Rectangle(rect);
--------------------------------------------------------------------------------
now after the rect is draw..i want to do the following:
given a point say 20,20.....so every time i get i point i make it into a rect and color it say red...
so if i get a point 20, 20
i amke arect
20,-20,21,-21
works fine now...but io ahve one doubt...
where should i do this this calculation???in the OnUpdate?
in the DOC?make my own fn in a view and put it there?
the point i get from which i am supposed to make the small rect comes from DOC.
so from doc where should i go to do this calulation???
code:
--------------------------------------------------------------------------------
CRect rect(x,-y,x+1,-(y+1));
pDC->Rectangle(rect);
pDC->FillRect(rect, &brush);
UpdateAllViews(NULL,.....);
--------------------------------------------------------------------------------
if i do this in doc..how do i get the DC????
please help...tks a lot...
can i get the dc like this
CClient dc(this);
will this dc be the dc of the view???
can i do the drtawiung using this dc that i make in doc???
tks a lot..really appreciate your time and help..
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
in the OnDraw of View call GetDocument to get the Document Pointer and access the Data that is required to Draw the Stuff
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
cannot do that...the data is not fixed..it keeps changing...something like the scribble applicaiton,,,
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
If ur drawing is based on constant User input
then have no choice but to do the calculations in the Drawing code itself
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
What you seem to want is where to store the rectangle information.
1) If more then 1 view needs the rectangle information, then store it in the document class and tell all views when the information has changed.
2) If only the current view needs the rectangle information, then store it in the view class.
Question: "if i do this in doc..how do i get the DC????"
Answer: The DC only matters when your are drawing the image, and it is given to you (if you are using MFC).
Question: "CClient dc(this);"
Answer: Yes! But you normaly do not need to (when using MFC), since it is given to you in the OnDraw() function.
Question: "will this dc be the dc of the view???"
Answer: If you are getting the DC in the view class, then yes.
Question: "can i do the drtawiung using this dc that i make in doc???"
Answer: Yes! But a document class does not know a DC from a hole in the ground. I wish I could say NO but if you try hard enough then the answer must be yes. (DO NOT DO THIS!)
INTP
|
|
|
|
|
How to know a toolbar button ID under the mouse!??
Best regards,
Eugene Pustovoyt
|
|
|
|
|
A quick look implies the following:
1) Use pToolBar = CToolBar::GetToolBarCtrl(); to get access to control
2) Use pToolBar->GetItemRect(); to find which item the mouse is over.
3) Now use pToolBar->GetItemID(); to get the ID.
Accept for all the typing (loops, ect..), it should be easy.
P.S. It would be easier if each button on an MFC toolbar was an indiviual window, but they are not. If this helps helps, send me your solution; if not write an article on your solution.
INTP
|
|
|
|
|
Good and how can I know a quantities of the toolbar button?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
What do you mean? Do you mean the number of items on the toolbar?
The base class of CToolBar is the CControlBar class and has a GetCount() member. If you have the display coordinates, then just loop through count items until you find an item rectangle (CToolBar::GetItemRect(nIndex, &Rect)) in which the cursor (also in display coordinates) is located. Now you should have the index of the toolbar item, call CToolBar::GetItemID(nIndex) to get ID.
INTP
|
|
|
|
|
Yes, I need to know the number of the items for the enumerate method.
Thank you, your answer was full!!!
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I want to add a preview function while use CFileDialog to open a *.jpg.
Then it has done successfully.
But I found the preview place down not right.
what can i do??
|
|
|
|
|
What are you trying to do?
1) If you just want to see what the image looks like before opening and you are using one of the Windows operating systems that support thumbnails, then
you should already have preview built in.
2) If you wish to support preview on a system that does not support thumnails in the open file dialog, then you will need to subclass the open file dialog. This is covered in the MFC libraray and I believe there may be some articles at codeproject that may cover this subject.
3) If you already have a dialog that you designed, then what problems are you having: (1) is it not drawing, (2) is it not draw in the correct location.
INTP
|
|
|
|
|
for my MDI app, i have a toolbar with a drop down list that is properly initialised and created. i can capture/detect when the user selects a given item from the list.
desired functionality: whenever the user selects an item from the drop-down list, i want to change the contents of the main menubar. i read the online docs for Microsoft Visual C++ .NET regarding the CMDIFrameWnd::MDISetMenu method. at first glance this is what i want but the article suggests that we should not "call this member function if you use the framework to manage your MDI child windows".
any helpful suggestion would be appreciated. thanks.
|
|
|
|
|
I do not use .NET, but one source that might give you a clue is the book "The MFC Answer Book" (look for MFC FAQ on the internet). When using Visual C++ 6.0, you normaly create a resource for based on the view (but you can change the resource used at any time). The most effective way would probaly be to add and remove menue items directly via code (this is much harder to code and maintain).
INTP
|
|
|
|
|
I wanted to know how an mfc application responds to WM_CLOSE. I have one application which is issuing a WM_CLOSE message to another MFC application.But the other doesn't respond to WM_CLOSE instantly. It waits for the current function or method running in primary thread to return and then takes up this message. But if primary thread is not doing anything, only secondary thread is processing, WM_CLOSE is processed instantly. Please confirm that my analysis is correct..
|
|
|
|
|
It is not a matter (I believe) of how MFC responds, but of how Windows responds. You might try putting your thread to sleep momentaraly to give the other application time to process the command.
As for how mfc applications responds: that is up to the person who wrote the application.
INTP
|
|
|
|
|
Thanks, I guess I didn't write my question clearly. What I want to confirm is whether an application running a message loop responds to WM_CLOSE instantly or after finishing the current processing. I tested with my application, what I found that when I issue a WM_CLOSE message to the second application, this second application responds to WM_CLOSE only after it has finished current processing. i.e. if a Dialog class's OnInitDialog method is getting processed when I issue WM_CLOSE, WM_CLOSE is handled only after OnInitDialog returns.
Is this behavior specific to DoModal or any method which is getting called?
|
|
|
|
|
windows programs handle events serially for one window
e.g
if you are already handling an event and another event comes , it will be in the queue and after processing ur current event the next event will be processed from the Queue .
Hope it answers ur query
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Sorry I was buzy elsewere!
Quick Answer: Before any application can close it must first finish what it is doing. That is it will not receive (etc...) any new messages until it is finish with the current message (or sub-task). It is possible to end a task now, but DO NOT DO THAT (CRTL-ALT-DELETE).
Question: "Is this behavior specific to DoModal or any method which is getting called?"
Answer: Yes and No! (1) The quick answer remains the same. The difference is that a modal box is not finished until the user closes the dialog box.
P.S. No application can respond until it has finished current processing.
INTP
|
|
|
|
|
Hi, friends.
I'm make a project that contains a cList Control, when I added item to the list, the new added item always be selected. so when I added , and then click delete button, it always delete the new item.
I use GetFirstSelectedItemPosition () to get the selected item index inside delete function.
How can I de-selected the items after adding or editing?
Thanks
|
|
|
|
|
Look at SetItemState().
INTP
|
|
|
|
|
I've spent the past two days playing with sample code that is supposed to, given a main directory, allow me to select one or more subdirectories and collect stats on them including the number of files, and the total size of each subdirectory. The technique used starts with
hFind = FindFirstFile(strFind, &dataFind);
where strFind is a wildcard search string on the main directory, and dataFind is a WIN32_FIND_DATA structure. Directories are identified by
if(dataFind.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
in a loop that traverses the entire directory. I found that this correctly identified only a few subdirectories, but couldn't figure out why. In a later section, files within a subdirectory are found using the same technique but using
if(dataFind.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
as the search criterion. This, too, failed to find all the files in the subdirectory. After many hours of research and experimenting I deduced that this is a stupid way to do this task, though it was a great way to demonstrate how to use the various controls in a dialog box. The reason, it appears to me, is that the field dwFileAttributes is an OR of one or more of many attributes, and rarely just a single one, so any single value comparison on a multiple-attribute entity will fail.
So my question is, what is a proper method for reliably testing whether a directory entity is a file or a subdirectory?
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
You do it like this
if (dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
and
if (dataFind.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
in other words, and out the bit you're interested in. I wouldn't rely on the archive bit though, it'll miss lots of files. Use FILE_ATTRIBUTE_NORMAL instead.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
Thanks, Rob... That was sorta where my small mind was headed - performing an AND operation to isolate the particular bit of interest, then testing for equality. It's unfortunate that the authors of this book didn't take the opportunity in this example to demonstrate this option. I think it would have been very instructive to a lot of people trying to learn the language. At the very least, it would have alerted students to the fact that the Win32 and MFC APIs are full of such flag fields, and that a programmer must learn appropriate methods for dealing with them. To their credit, though, I must admit that the intent was to demonstrate how to populate the fields of several control objects, which the chapter did quite well. Maybe I'm too much a perfectionist, but I think that sample code in a textbook should be perfect. Unfortunately it is often a far cry from merely good, let alone perfect.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|