| lostprophetpunk (33) | |||||||||||
|
Heya there, For some reason the variables don't seem to want to change when I click the menu item. Not sure how to get it working. At the start of my code I declared this...
My resource.h file...
Resource.rc file...
Here is the WM_COMMAND I have...
Here is the WM_PAINT...
| |||||||||||
|
|
|||||||||||
| andywestken (1950) | |
|
You need to invalidate your window after changing color, so it's redrawn with the new color. i.e. InvalidateRect() If you click on a new color and resize your window, to trigger a redraw, you'll see your internals are all working. Andy | |
|
Last edited on
|
|
| lostprophetpunk (33) | |
| How would I go about doing that? Sorry, I'm quite new to Win32. | |
|
|
|
| andywestken (1950) | |||
Based on your current code
| |||
|
Last edited on
|
|||
| lostprophetpunk (33) | |
|
That doesn't seem to be working. gives no errors/warnings and a successful compile. | |
|
|
|
| andywestken (1950) | |||
|
Hmmm... Well, along with your resource.h and .rc file, the following .cpp works for me (it's your code fragments plus bits nicked from wizard generated boilerplate for window registration and creation and the message loop) * * * plus a call to delete the brush created in the WM_PAINT handler * * *
| |||
|
Last edited on
|
|||
| lostprophetpunk (33) | |
|
Right so I got it to work, simply by replacing the WM_DESTROY command with WM_QUIT. However when the colours are selected through the menu, it only seems to redraw part of the rectangle as a colour, the rest of it stays black. As I see that the second value of InvalidateRect() should be set to NULL for the whole area, would be it be better to specify the region with RECT()? | |
|
|
|
| lostprophetpunk (33) | ||||
|
Fixed it. All that needed to be done was remove the bool inval= = false; and also the
The
| ||||
|
|
||||
| lostprophetpunk (33) | |
| Okay, new problem but in the same area. When I add an edit box and the focus is on that...the colour of the rectangle turns from black to green. Have no idea why it is doing this. | |
|
|
|
| lostprophetpunk (33) | |
| Anyone that can help me? | |
|
|
|
| andywestken (1950) | |
|
#1 PostQuitMessage() should be called in the WM_DESTROY handler and causes a WM_QUIT to be generated which teminates the message loop. #2 It would be better to specify the area for InvalidateRect, but it should work OK as-is? #3 The bool was to stop InvalidateRect from being fired with commands other than those from your color menu items. And... #4 Set a breakpoint on one of the lines in the switch condition that sets the color to green and check the call stack to see what's sending the message. And what command it is. Andy (I also corrected the code I posted from PostQuitMessage(WM_QUIT);to PostQuitMessage(0);A previous mis-correction...) | |
|
Last edited on
|
|