PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Possible errors 0.6c

Kornalius,

Im using the onboard editor, running on an IPAQ 1940.

1. When I compile from the menu, it seems to compile the last saved version of the file rather than the contents of the editing window. Maybe it should prompt you to save again so that you are always compiling your newest work regardless of whether you have saved it or not.

2. If I compile and then run, the program does not run. I get a blank window and which I have to close to return to the editor. If I choose run again, it does run. This happens also if I start with run instead of compile, I have to run it twice to get it to run.

3. I have some code that draws pixels on an image object. (Thanks for the tips on that btw :D ) Before the routine runs I use showmessage to say hello. You click OK to close the message window and then the pixels are drawn. When the loop finishes, a blank rectangle appears where the showmessage was. Maybe it's my lack of understanding of the windows event system, but I thought that after Ok was pressed on the message, it no longer existed. So how come it still has an effect on the pixel area? It's like something is out of synch... Is it the image object redrawing the part of itself that had the message over it? If so, why didn't this occur immediatley before the pixels were drawn?

Code below...

Code:

#include "windows.ppl"
proc paint
local(x$,y$,dc$,a$);
global(c$);

showmessage("paint");
dc$=GetDC(BITMAP101$);
x$=50;
y$=50;

Repeat
Repeat
a$=SetPixel(dc$, x$, y$, c$);
x$++;
c$++;
Until(x$==200);
x$=0;
y$++;
Until(y$==200);

end;

#code {Main.frm#FORM100}
func FORM100Proc (hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case(Msg$)
WM_COMMAND:
wmId$ = LOWORD(wParam$);
wmEvent$ = HIWORD(wParam$);
case(wmId$)
1001: // Exit
PostMessage(hWnd$, WM_CLOSE, 0, 0);
return(false);
102:
paint;

end;
end;
return (ok$);
end;


#code {Main.frm}
func WinMain
Global(FORM100$, BITMAP101$, BUTTON102$, BUTTON103$, m1000$);


FORM100$ = NewForm("FORM100", "PPLForm", &FORM100Proc;);

BITMAP101$ = NewControl(101, "STATIC", NULL, "BITMAP101", WS_VISIBLE|SS_BITMAP, FORM100$, 8, 8, 224, 216);

BUTTON102$ = NewControl(102, "BUTTON", NULL, "Generate", WS_TABSTOP|WS_VISIBLE, FORM100$, 8, 232, 64, 24);

BUTTON103$ = NewControl(103, "BUTTON", NULL, "Save...", WS_TABSTOP|WS_VISIBLE, FORM100$, 168, 232, 64, 24);

m1000$ = NewMenu(FORM100$, "File", 1000);
NewMenuItem(m1000$, -1, "Exit", 1001);

ShowWindow(FORM100$, SW_SHOW);

#code {Main.frm#WinMain}

return (true);
end;
Hi Andy,

Whenever something changes in the screen area The Windows OS sends a "WM_PAINT" message to each window (form/control) in the effected area. It is up to the form/control to "paint" (or repaint) the area for which it is responsible.

You need to include a WM_PAINT case in your windows procedure.

The code snippet below shows an example from one of my programs that displays bmp files to the screen - I don't expect you to laboriously follow the code, but offer it as an example of how/where to handle the "WM_PAINT" messages.


Code:

func MainFormProc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case (Msg$)

WM_TIMER:
DoTimerProc;

WM_COMMAND:
wmId$ = LOWORD(wParam$);
wmEvent$ = HIWORD(wParam$);
case (wmId$)
401: // Open
OpenBMP;
402: // Close
CloseBMP;
409: // Exit
PostMessage(hWnd$, WM_CLOSE, 0, 0);
return (false);
501: // Show GPS Form
ShowWindow(gpsForm$, SW_SHOW);
end;

WM_LBUTTONDOWN:
ox$ = LOWORD(lParam$);
oy$ = HIWORD(lParam$);

WM_MOUSEMOVE:
x$ = li$ + (ox$-LOWORD(lParam$));
if (x$ > (bw$-iw$)) x$ = (bw$ - iw$); end;
if (x$<0) x$ = 0; end;

y$ = ti$ + (oy$-HIWORD(lParam$));
if (y$ > (bh$-ih$)) y$ = (bh$ - ih$); end;
if (y$<0) y$ = 0; end;

if (bm$ <> NULL)
if ((x$<>li$) OR (y$<>ti$))
ox$ = LOWORD(lParam$);
oy$ = HIWORD(lParam$);
li$ = x$;
ti$ = y$;
PostMessage(hWnd$, WM_PAINT, 0, 0);
end;
end;

WM_PAINT:
struct (ps$, PAINTSTRUCT);
struct (rt$, RECT);

hdc$ = GetDC(hWnd$);
BeginPaint(hWnd$, &ps$);
GetClientRect(hWnd$, &rt$);
if (bm$ <> NULL)
hdcMem$ = CreateCompatibleDC(hdc$);
hOldSel$ = SelectObject(hdcMem$, bm$);
BitBlt(hdc$, rt.left$, rt.top$, rt.right$ - rt.left$, rt.bottom$ - rt.top$, hdcMem$, li$, ti$, SRCCOPY);
DeleteDC(hdcMem$);
if (hOldSel$ <> NULL) DeleteObject(hOldSel$); end;
else
FillRect(hdc$, &rt$, GetStockObject(WHITE_BRUSH));
end;
EndPaint(hWnd$, &ps$);
ReleaseDC(hWnd$, hdc$);

WM_DESTROY:
killtimer(hWnd$,evt$);
CloseHandle(sck_inet$);
if (not(com$ == INVALID_HANDLE_VALUE)) CloseGPSPort; end;
if (bm$ <> NULL) DeleteObject(bm$); end;
free (ColorTable$);
free (buff$);
end;

return (ok$);
end;


Hope I haven't made this too confusing ....

cheers
Hi Mervjoyce,

Thanks for your explanation and code snippet. I think I know what you mean, and I guess my item 3 is off topic for this thread: It's not an issue with PPL.

I guess what you're saying is that to correctly handle the windowing process, my image needs to redraw itself on the WM_PAINT event, and then it should always be up to date. That's fine I understand that.

I noticed with my program that the message box is still on the screen even AFTER I have pressed it's OK button. Is this because the message box does not explicitly remove itself from the screen by it's own process? Does it disappear rather because the objects underneath it redraw themselves? Since I don't provide a WM_PAINT routine, is there a default behaviour ie: fill with background color, or something? That would explain why the blank rectangle appears; something is obviously generating the blank rectangle...

I'm not sure if I'm on the right track with this. I think Im nearly there, but maybe I'd better do a bit of reading up. :?

Thanks for the help!
Hi guys,

Item 2 on my list was described incorrectly.

The program DOES run the first time I run it. (I just couldn't see the objects on the form as they were obscured by the input panel.) The input panel then disappears when you close the program, which means when you run the program again, you see all of the form.

Is this a bug? I Don't know, but it does seem a little inconsistant.