|
Thanks G_S. I did try starting my program away from the IDE and it certainly was easier to isolate my application and also its sub-controls and lok at only the messages I was interested in.
Alas, I still have not figured out what keeps repainting my custom control...
Cheers,
Mark
|
|
|
|
|
Hi Mark,
By far the best way to debug (although this depends on preference and opinion) is to just the visual studio debugger, and step through code that you need to test line by line.
Get familiar with breakpoints and 'step in/step out' for functions. The debugger is powerful enough for you to walk through code as it is executing, line by line, make changes on the fly and compile them back into the running program. If you notice a line of code didn't work the correct way, you can change the line, compile the changes, tell the debugger to step back to that line and execute it again. You can keep on doing this until you've got the code correct.
This line by line debugging will also greatly ease your use of spy- because when you step over a line of code you'll probably only end up sending one windows message (or none at all), and you won't get the floods of mouse messages.
Try using Winspector Spy (a free tool on the net), it corrects some of the most common quibbles with spy++. In terms of using spy itself, the most useful feature is under 'Search>Find Window'. You can drag the Finder tool over the window you want to spy on and it selects it for you automatically; very useful if you need to find a window such as a statusbar which may not have a caption.
When watching windows, go to the 'logging options' and make sure you're not logging mouse messages, paint or nc (non-client) paint messages, otherwise you tend to get a continuous flood of nonsense.
So whilst watching a window you are debugging step-by-step, you can generally see what's going on. The only limitation of the step-by-step debugging is that it doesn't do windows messages well, because they go through a message pump etc which makes stepping in and out of those functions very complicated. For checking dodgy code though, the debugger should be your first check, get comfortable with it, it's an extremely powerful tool.
Hope this helps Mark
Dave Kerr
codechamber@hotmail.com
http://www.codechamber.com
|
|
|
|
|
Hi Dave:
Thanks for your response. I guess I should have been a little more specific about the kind of problem that I am having. I've been using Visual Studio for years and, yes, the line-by-line debugger, stepping in, stepping over, breakpoints and the various watch windows is always my first recourse when debugging and testing.
My problem is that I suspect that there are windows messages being issued that I am unaware of and might be working against me. Sounds like conspiracy theory, I know, but the Reader's Digest version of my problem is that I am trying to customize a control. It is user drawn. In "DrawItem", I am painting the control's background a certain colour, when I step through and view this procedure, I can see that the "DrawItem" procedure is indeed painting the background. But as soon as I allow the program to continue, some other entity is un-painting my background. I assume that this is a Windows message that I had not anticipated. This is why I would like to see what messages are being issued.
Am I correct in assuming that it is the WM_PAINT message that is eventually calling the "DrawItem" procedure? Or have I misunderstood?
Anyway, that is my story. I do not know if Spy++ would help me here or not but I have been spinning my wheels here since late last night and I am willing to try anything at this point.
Thanks,
Mark
|
|
|
|
|
Hi Mark,
OK- I thought it was a much more general question, I didn't mean to sound patronising to someone who's been using studio for years!
First things first- make sure you are handling the WM_ERASEBKGRND message and returning FALSE- otherwise during the drawing sequence the system will try and erase the control's background. This sounds like the most likely problem.
If it's more complicated custom drawing you're doing, such as list items in list controls, then look in the documentation for how to set the background. For example as far as I can remmeber with things like tree controls, to customise the tree items background, you handle the custom draw notification, but don't erase the background, you set the background colour in the passed device context to what you want, and then the system erases it for you.
So if the background is being unpainted, check for the WM_ERASEBKGRND message and make sure you handle it, and for tree/list/more complicated controls, make sure that to change the background you're setting the correct variable in the device context.
If none of this works and spy doesn't pick up any cheeky little messages being boosted around without your knowledge, then it might be worth posting the explicit problem somewhere and seeing if it's been encountered before...
Good luck,
dave
Dave Kerr
codechamber@hotmail.com
http://www.codechamber.com
|
|
|
|
|
Thanks Dave. That sounds like a likely suspect. I am not currently handling WM_ERASEBKGRND.
Cheers,
Mark
|
|
|
|
|
Hi,
I'm trying to use the "Reference Counting" technic and the "Copy on write" technic, so a "MyString class" can be able to have it's own simulated Garbage Collector.
My problem is when I try to overload this operator "[]", for example:
MyString s1(L"HELLO WORLD");
wchar_t * pwc = &s1[1];
wchar_t ch= s1[2];
I need a way to find out if the operator [] is being "called" to make a refence of the object s1:
&s1[1];
or if the operator is being called just to return a copy of the wchar_t value contained in the object s1:
wchar_t ch= s1[2];
Developer
|
|
|
|
|
Check out how CString overrides this operator. It actually has 2 overrides for it (one that is const, and ones that allows for the item to be changed).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
I was advised that these files are part of the Borland c++ comiler. I have downloaded the comiler, but these files are not there and I need them. How can I get them??
Thanks a lot!
|
|
|
|
|
what is your compiler now, and what do you need exactly ?
there is certainly an alternative to what was inside those header...
|
|
|
|
|
I am using Microsoft Visual c++. I need those headers to programatically create a Microsoft Word file with a coulpe of lines of text in it.
|
|
|
|
|
can't you use a Word automation ?
|
|
|
|
|
This is totally useless as you will need to link to a specific library and that won't work probably. Instead, take a look at word automation (that is the way to go). There is some usefull articles here[^]
|
|
|
|
|
Thank you both for your answers. I am not an experienced programmer and the reason I wanted to use the other files is, beacause I cannot find a good, simple example on how to do what I need with Word automation.
|
|
|
|
|
Hi all,
When I print a document, I use the CPrinterDialog class. This works fine when I want to show the user the dialog and then het the printer's device context using "GetPrinterDC ()". But when the user clicks the print icon on the toolbar, I want to print without asking for the relevant printer, i.e. using the default printer.
However, when I call "CPrintDialog::CreatePrinterDC ()", I do not get a DC. Microsoft's doc says that you then still need to initialise the dialog by DoModal, but I do not want that, since I do not want to show the user this dialog.
Any bright ideas on how to get the default printer directly?
Thanks in advance
William
|
|
|
|
|
Found the solution meanwhile (in case anybody is interested)
call the printDialog's "GetDefaults ()" function will do the job. If there is no default printer, the function will return FALSE, in which case a print dialog should be shown anyway.
Regards,
WIlliam
|
|
|
|
|
Is GetDefaultPrinter good?
|
|
|
|
|
I want to Know the height from the bottom of the tool bar to the top of main window
Can any body help me out
|
|
|
|
|
There are two ways:
1:
RECT ToolRect;
RECT WndRect;
CToolBar::GetWindowRect (&ToolRect);
GetWindowRect (&WndRect);
ToolRect.left -= WndRect.left;
ToolRect.right -= WndRect.left;
ToolRect.top -= WndRect.top
ToolRect.bottom -= WndRect.top;
This will give you the positions relative to the upper-left corner of the main window. Usually however, you will need the co-ordinates relative to the upperleft corner of the window's client area. This is done by
2:
RECT ToolRect;
RECT WndRect;
CToolBar::GetWindowRect (&ToolRect);
GetClientRect (&WndRect);
ClientToScreen (&WndRect);
ToolRect.left -= WndRect.left;
ToolRect.right -= WndRect.left;
ToolRect.top -= WndRect.top
ToolRect.bottom -= WndRect.top;
Success,
WIlliam
|
|
|
|
|
Hi all,
I've written an ActiveX control that automates MS Word When I call the Method PrintPreview I get the print preview window up but instead of the document being shown I get the web page it resides in, minus the document contents.
I've gone right through the type library header and haven't found another route (it is huge though).
|
|
|
|
|
Automation is a hassle in any case. However, I have found it usefull to generate a word macro doing the things you want done, and then edit that macro to see what exactly happens. Usually you will have to call the same procedures from your automation with the same variables to get the job done.
Success.
William
|
|
|
|
|
Nice idea.
Thanks
Tom
|
|
|
|
|
Hi william,
I used your technique and unfortunately it agreed with what I was already trying. Which is comforting to know, as it means I wasn't on the wrong track. Moreover, it's made me think now that the PrintPreview call is going to IE's PrintPreview engine. Basically, it depicts everything on the page except the Word document, something the Word Print Preview engine would be very unlikely to do.
Looks like I may have to get my hands dirty.;)
Tom
|
|
|
|
|
How can i receive data on my pc from microcontroller using acessspoint.
My microcontroller has TCP/IP stack.
do i have to use TCP protocol as well for receiving the data.
thanks
|
|
|
|
|
yes
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
I want color to the controls and and also to the window.
How can i color to it?
|
|
|
|