Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Problems with Popup Menu API example
Page 1 of 1

PostPosted: Thu Jan 02, 2003 4:11 pm
by chrisleeuk
After downloading the pocket C API I notice the nice POPUP.PC example of how to create popup menus.

However after adding a couple of edit controls to the example and an event handler I noticed that when an item from the popup menus 'sub menu' is selected all events are then lost from the application.

The edit controls will not accept any text from the SIP and no events are getting into the program.

If I call the popup menu again and this time I just choose an item from the inital menu then all events start working again.

All testing indicates that this only occurs on a sub menu of the inital popup menu. Any ideas how I might resolve this?

I have tried things like 'SetActiveWindow' and 'SetFocus' API calls but with no effect.

PostPosted: Thu Jan 02, 2003 4:40 pm
by guy
It's not something simple like duplicating the menu IDs in your control Ids is it?

I use TrackPopupmenu with submenus a lot in the current internal PCForm development version and I have no problems with odd things happening to other controls.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Fri Jan 03, 2003 6:49 am
by Mickle
You can use SetActiveWindow() and SetFocus() only with windows associated with the thread calling this functions.
PocketC is actually running 2 threads: main thread (UI) and virtual machine. Any window created createctrl() are associated with UI thread. Do not use SetActiveWindow() and SetFocus() for it window. Any window created CreateWindow() are associated with virtual machine thread. You can use SetActiveWindow() and SetFocus() for it window.
You can use SetFocus() with window associated with another thread if it window is the child of the window on the thread calling this function.
You can use SetForegroundWindow() for window associated with any thread.
Mickle.

PostPosted: Fri Jan 03, 2003 8:09 am
by chrisleeuk
Below is the slightly modified version of Popup.pc. I have my headers on my storage file so the include will need changing.

I am running this code on a Pocket PC 2000 device.
In this example I only have one control to avoid other issues.
If I run the code and select any of the first menu items I can enter things into the edit box.

If I run again and select a sub menu item then I can set focus to the edit box by clicking in it but I cannot enter anything via the SIP.

I have used this routine as part of a larger one which is a bit big to show here. In my other example the popup menu is called several times. I also have a full event management routine. Whenever I call the popup and select a sub item the event routine stops working correctly. I still get some events but all SIP related and hardware button events fail to work.

In addition I can select any edit box but no information will appear from the SIP.

If I call the popup again without stopping the program and I select an item from the first menu all of the event stuff and SIP entry starts working again.

I tried again but without destroying the menus but it made no difference.

Any ideas?
Its all very strange.
Thanks for you help so far.

<font size="1">#include "/storage card/pocketc/winuser.h"

main() {

HMENU hMenu ;
HMENU hSubMenu ;
HWND hWnd ;
int iResult ;
int iTickState = MF_CHECKED ;
createctrl("EDIT","File",WS_BORDER |WS_VISIBLE | WS_CHILD,0,0,150,130,20,999);

hWnd = gethwnd(1) ;

hMenu = CreatePopupMenu() ;
hSubMenu = CreatePopupMenu() ;

AppendMenu(hSubMenu, MF_STRING | MF_ENABLED, 100, "Sub 1") ;
AppendMenu(hSubMenu, MF_STRING | MF_ENABLED, 110, "Sub 2") ;
AppendMenu(hSubMenu, MF_STRING | MF_ENABLED, 120, "Sub 3") ;

AppendMenu(hMenu, MF_STRING | MF_ENABLED, 10, "First") ;
AppendMenu(hMenu, MF_STRING | MF_ENABLED | MF_CHECKED, 20, "Second") ;
AppendMenu(hMenu, MF_STRING | MF_GRAYED, 30, "Third") ;
AppendMenu(hMenu, MF_SEPARATOR, 0, "") ;
AppendMenu(hMenu, MF_STRING | MF_ENABLED, 40, "Fourth") ;
AppendMenu(hMenu, MF_STRING | MF_ENABLED | MF_POPUP, hSubMenu, "Submenu") ;
AppendMenu(hMenu, MF_STRING | MF_ENABLED , 50, "Exit") ;

//do {
iResult = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, 1, 25, 0, hWnd, NULL) ;
confirm("Result was " + iResult) ;
switch (iResult) {
case 20:
if (iTickState == 0) {
iTickState = MF_CHECKED ;
} else {
iTickState = 0 ;
}
CheckMenuItem(hMenu, 20, iTickState) ;
break ;
case 30:
EnableMenuItem(hMenu, 30, MF_GRAYED) ;
break ;
case 40:
EnableMenuItem(hMenu, 30, MF_ENABLED) ;
break ;
}
//} while (iResult != 50) ;
DestroyMenu(hSubMenu) ;
DestroyMenu(hMenu) ;
while (1) {
sleep(0);
}




quit() ;
}</font id="size1">

PostPosted: Fri Jan 03, 2003 4:50 pm
by guy
I've just ordered a PocketPC. I'll test the code out for you when it arrives.

Have you tried disabling the SIP before calling TrackPopupMenu() and then reenabling it afterwards?



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Sat Jan 04, 2003 6:53 am
by Mickle
I am running this code on HPC PRO. SAME result.

PostPosted: Sat Jan 04, 2003 11:53 am
by guy
Maybe there is a problem with the fact that the owning window is created by pcshell (thread problem or pcshell message processing problem).

Try adding the TPM_NONOTIFY flag to the flags. This might help. The documentation states that this stops the function from sending a message to the owning window. It also states that TPM_NONOTIFY isn't supported. Hmm.

The other thing that you could try is creating your own window to receive the notification message. Use CreateWindow(), not createctrl().

I'll do some tests to see whether I can find a work-around.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Fri Jan 24, 2003 4:18 pm
by guy
The fix to this is simple.

Instead of:

hWnd = gethwnd(1) ;

Use:

hWnd = CreateWindow("STATIC", "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, gethinstance(), NULL) ;

ie Use your own window to catch the final message from the popup menu rather than sending it to pcshell which doesn't expect to catch it and gets confused.

At the end of the program just get rid of the window:

DestroyWindow(hWnd) ;


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Mon Jan 27, 2003 9:36 am
by guy
It's probably a good idea to empty messages off the queue for the catching window every so often.

Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum