PocketMatrix forums

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

A little help please :)

I've got a very odd problem.

I have a button on a pocketPC form which I want to press and have it do the old Hello World.

Code:

func BUTTON102Proc (hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case (Msg$)
WM_COMMAND:
wmId$ = LOWORD(wParam$);
wmEvent$ = HIWORD(wParam$);
case (wmEvents$)
BN_CLICKED:
ShowMessage("Testing");
end;
// Put your code here
end;
return (ok$);
end;


That's the code and it all compiles fine. However, when I run the program and click the button nothing happens.

I'm running latest version, and created this on the Desktop IDE.

Can anyone help me out here. This really is weird.

CJ

p.s. I've attached the entire project just in case it's needed.
Attachments:
Hello World.zip (2 KB)
Siege1975,

I looked up BM_CLICK in the API reference and I found this:

This message is sent by an application to simulate the user clicking a button. This message causes the button to receive a WM_LBUTTONDOWN and a WM_LBUTTONUP message, and the button's parent window to receive a BN_CLICKED notification message.


What I think you want to do is to catch the notification of the button event on the main form winProc. The main form proc would look something like this...

Code:
func FORM1Proc (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);
101: // Button
s$=GetText(EDIT1$);
s$=s$+" OK";
SetText(EDIT1$,s$);
end;
end;
return (ok$);
end;


Let me know if you need more information or some working examples. Hope this helps.

bmanske
Okay I've got the button to do a show message now. But to do so I had to open the .frm in notepad and edit it by hand. This seems a little clunky to me. Especially since the .frm file has all the code on one line per event, which is v. confusing.

Perhaps the ability to edit the frm's code via the ide would be useful. I know you can get to each controls event's. But from the form editor you cannot get to the main message pump.

Just a thought. Because I've noticed that the .frm is used in preference to the ppl file. I've tried to change that alone and had no luck.

Or am I missing something :)

I have to say that so far I'm very impressed with the possabilities that this language opens up. Most pocketPC programming is an expensive or just plain esoteric art form. This language could stop that and open up the world of mobile programming to just about any indie developer.
Siege1975,

Using the form editor in the PIDE, click on a blank spot on the form. You should see resizing handles for the form that you can drag if you want to change the size of the window created. Right click on the blank spot and on the Controls menu choose Code and the main message pump will open in the editor.

There are also 2 other special sections, right click on the form and choose Edit > Code then you can get to the Initialization section and the creation code section.

The initialization section is placed at the top of the file and is good for procedures, includes, defines... The creation code section is placed just after the form and the controls are created.

Try it. Add some code to these sections, then save it and look at Edit > Code > View Form Source and you can see the code that gets generated and where your code gets placed.

bmanske
Thanks, that's a great help. I was a little confused there for a moment :)

No doubt I'll end up getting confused again :), and it's good to know that there are people on the board willing to help.

It's amazing how boards often don't.
I'll accept that as a complement from all of us on the board. Thanks!

Come on back if you feel any more confusion coming on.

bmanske
bmanske wrote:I'll accept that as a complement from all of us on the board. Thanks!

Come on back if you feel any more confusion coming on.

bmanske


Of that you can be sure ;)
thrashmetal15 · 11 Nov 2005, 20:31 UTC
I had the same problem. It was a little confusing there for a little.
I think most of the problems comes from the tutorials that were written for the web site. They are nice and very instructive but I think they need some updating. I'll see what I can do about it, I'll try contacting the authors.