I have been trying to get a sketch programme based on Petzold's example in "Programming Windows" to work but everything is lost when the window is restored after being minimized. I tried modifiying it based on methods used in Chris Hobb's tutorial on eliminating screen flicker. The code is attached. Left mouse button to draw, Right mouse button to erase. Could someone point me in the right direction?

Regards, Fumio
Posted on 2003-06-13 20:39:37 by Fumio
There is also a bug. When u try to write something on the top or on a left side of a window.
Posted on 2003-06-14 01:48:46 by AceEmbler
Thanks for your interest AceEmbler. I don't have that experience you have with drawing on top or left of window. I'm using win98. Attached is a screen shot.
Posted on 2003-06-14 08:57:13 by Fumio
:o
Posted on 2003-06-14 10:48:51 by AceEmbler

I have been trying to get a sketch programme based on Petzold's example in "Programming Windows" to work but everything is lost when the window is restored after being minimized. I tried modifiying it based on methods used in Chris Hobb's tutorial on eliminating screen flicker. The code is attached. Left mouse button to draw, Right mouse button to erase. Could someone point me in the right direction?

Regards, Fumio


You have to save the information in an array or buffer and then repaint the client area using the information. However, there should be a simpler method using an extra memory DC or compatible bitmap.

Peek for the message that windows sends to your message loop when your window is restored and then respond by redoing your bitblt from info stored either in an array or compatible bitmap.

The message windoze sends when you restore is WM_MAXIMIZE or something like that.

I had the same problem when making a game but was too lazy to fully investigate it.

Good luck.
Posted on 2003-06-14 15:20:04 by IwasTitan
Just offhand... try replacing the "addr hitpoint" in your MoveToEx functions, with NULL.
When you include something other than NULL as a parameter, MoveToEx returns the
previous x/y positions, and it appears that this *may* be clobbering your POINT structure
with something you don't want (especially the first time it's called). Whether that'd make
a difference or not, in your app... not sure.
(it's late... need sleep...)

Also. You seem to be restoring previous objects in the reverse order they were selected,
since you saved the returned handles on the stack (a local variable would be easier to keep
track of). Speaking of which - I think you can just use the same hPen for both DCs anyway.
(no need for hPenM, in other words.)

You shouldn't need the third case, in your WM_MOUSEMOVE section. In Petzold's WM_xBUTTONUP
handlers, I notice he uses NULL as the parameter, which doesn't appear to be documented
in the SDK. I'd think, rather, ReleaseCapture, but... he never calls it, so... maybe SetCapture, NULL
accomplishes the same thing(?) Duhhhh.....
(getting later... now need even *more* sleep...)

Speaking of your WM_MOUSEMOVE section. Rather than:

.ELSEIF uMsg==WM_MOUSEMOVE

.If fLeftButtonDown==TRUE
do some stuff
.endif

.If fRightButtonDown==TRUE
do some other stuff
.endif

.If fLeftButtonDown==FALSE
do some stuff (that shouldn't be necessary)
.endif

I'd think:

.ELSEIF uMsg==WM_MOUSEMOVE

.If fLeftButtonDown==TRUE
do some stuff

.elseif fRightButtonDown==TRUE
do some other stuff

.elseif fleftButtonDown==FLASE
do some stuff (...)
.endif

That's how my stuff's nested, anyway, and it seems to work.

Ok, one last thing. In your WndProc, you need to add a "Uses ebx esi edi," in there:

WndProc proc Uses ebx esi edi, hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

If you *don't* preserve those regs (all three, just to be sure)... well, it'll work ok in WinXP, but
there's every liklihood that it'll crash Win9x. Mine did, and I had absolutely *no* idea why, 'till
I spotted Hutch's note on that matter (over in the Masm32 forum). I think it's totally ansurd
that Windows would call a completely unknown routine without preserving its own regs, buuuut...
(and, apparently, someone else thought so too, 'cause it *will* work in XP).

Good luck! Sorry I didn't investigate more fully, but... looks like you'll get 'er straightened out.
(btw, are you using a debugger? Olly? *Highly* reccommended.)

Jeff
Posted on 2003-06-15 15:28:45 by jayte
-
Posted on 2003-06-15 19:45:27 by roaknog
Thanks roaknog:
Regards Fumio
Posted on 2003-06-15 20:44:08 by Fumio