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 - gets() uses wrong font or edit field height?

gets() uses wrong font or edit field height?

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby Josh on Sun Aug 18, 2002 6:10 pm

Greetings to all,

I just started fiddling with my Jornada 728 and PocketC (so many questions ...). When I run one of the little demo programs, accompanying the PocketC distro, I noticed that the gets() function displays a nice prompt and a very narrow edit field, i.e. the font used by the edit field control doesn't fit at all (just the upper, say, 75% is visible).

Does anyone know how to correct/fix this little inconvenience?

kind regards,

Josh


Two things are omnipresent in this universe: oxygen and stupidity
-- Frank Zappa
Two things are omnipresent in this universe: oxygen and stupidity
-- Frank Zappa
Josh
 
Posts: 6
Joined: Sun Aug 18, 2002 10:56 am
Location: Netherlands

Postby guy on Mon Aug 19, 2002 7:29 am

The best bet is to write your own function to do this. You can then guarantee that it looks the way you want on all platforms.

There never used to be a problem with gets(), but now its box sizes seem to be all over the place.

Create a static control as a rectangular background for an input box, and place an edit control for the input, and two pushbuttons for OK and Cancel on top of it (create after the background). Create the whole lot at the start of your program with the WS_VISIBLE style off, then show them all when you want to get input. Provide a simple event loop that finishes when one of the buttons is pressed. Hide the controls once the user has pressed OK or Cancel. Read the contents of the edit control if the user pressed OK.


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
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
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby guy on Mon Aug 19, 2002 7:32 am

Once you have your user input box, you can control the font by calling real Windows CE API functions.

Fill a LOGFONT structure with the font details.
Call the CreateFontIndirect() function
Use the returned font handle in a WM_SETFONT message to the control.


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
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
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Josh on Mon Aug 19, 2002 9:27 am

guy,

thanks again for your very elaborate answer. One remark made me wonder however:

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
There never used to be a problem with gets(), but now its box sizes seem to be all over the place.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Does that imply that I can set/alter the dimensions of the gets() box myself somewhere in an include file or config file? Or does your remark imply that those #defined dims are scattered all over the place in the source code of PocketC *itself*? If the former is true, I can fix this little sloppyness myself, if the latter is true, it makes me frown a bit upon this sloppy behaviour ... e.g. I don't want to implement my own home brew, say, printf(), if the one that came with the distibution happens to be broken; I would simply forget about the entire distribution ...

kind regards,

Josh

Two things are omnipresent in this universe: oxygen and stupidity
-- Frank Zappa
Two things are omnipresent in this universe: oxygen and stupidity
-- Frank Zappa
Josh
 
Posts: 6
Joined: Sun Aug 18, 2002 10:56 am
Location: Netherlands

Postby guy on Mon Aug 19, 2002 10:04 am

I suspect that an enhancement in a recent release of the runtime library to better size the box to fit all the various devices out there misfired badly.

It may relate to Kevin trying to size the box based on the default fonts used, without realising that these aren't always stored in the same place in the registry (caught me out too in something I did a while back).

A quick and dirty replacement for gets() is:

<pre id=code><font face=courier size=2 id=code>

// This file is composed of bits from various PCForm source and header
// files.


#define CONTROL_INPUT 230 // Base control ID for input box items
#define CDLG_ITEMH 20 // Height of most items in box


int gi_options ; // User preferences


#define OPT_M_IBSIP 0x1000 // Display popup keyboard when input box used


#define TRUE 1
#define FALSE 0


CreateInputDialogue() {

int iHeight ; // Height of whole input box
int iWidth ; // Width of whole inout box
int iLeft ; // Left margin for box
int iTop ; // Top marginf for box
int iFlags ; // Button creation flags


// Fit the box into the centre of the screen

iHeight = (CDLG_ITEMH * 3) + 37 ;
iWidth = 220 ;
iLeft = (screenx() - iWidth) / 2 ;


switch (deviceplatform()) {
case 2: // PPC
iTop = screeny() - 26 - 80 - iHeight - 10 ;
iFlags = BS_DEFPUSHBUTTON ;
break ;
case 4: // PocketPC
iTop = screeny() - 26 - 26 - 80 - iHeight - 10 ;
iFlags = BS_PUSHBUTTON ;
break ;
default: // HPC, HPCPRO
iTop = (screeny() - iHeight) / 2 ;
iFlags = BS_DEFPUSHBUTTON ;
break ;
}


// Create the components of the box


createctrl("EDIT", "Prompt string", WS_CHILD | ES_READONLY, 0,
iLeft + 10 ,
iTop + 10 ,
iWidth - 20 ,
CDLG_ITEMH ,
CONTROL_INPUT ) ;


createctrl("EDIT", "User input box", WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL | ES_MULTILINE,
WS_EX_CLIENTEDGE,
iLeft + 10 ,
iTop + 15 + CDLG_ITEMH ,
iWidth - 20 ,
CDLG_ITEMH + 2 ,
CONTROL_INPUT + 1) ;


createctrl("BUTTON", "OK", iFlags | WS_CHILD | WS_TABSTOP, 0x0,
iLeft + ((iWidth-(55+55+10))/2),
iTop + (CDLG_ITEMH * 2) + 27,
55,
CDLG_ITEMH,
CONTROL_INPUT + 2) ;


createctrl("BUTTON", "Cancel", BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 0x0,
iLeft + ((iWidth-(55+55+10))/2) + (55+10),
iTop + (CDLG_ITEMH * 2) + 27,
55,
CDLG_ITEMH,
CONTROL_INPUT + 3) ;


createctrl("STATIC", "", WS_CHILD | WS_BORDER, WS_EX_WINDOWEDGE,
iLeft, iTop, iWidth, iHeight, CONTROL_INPUT + 4) ;


}


//+
// InputBox Display a user input box with a prompt and default
//
// Parameters:
//
// string t_caption Prompt to display in window caption
// string t_default Default value to place in input box
//
// Returns:
//
// string Data entered by user
//
//-


InputBox(string t_caption, string t_default) {


int i_event ;
int i_active ;
int i_guiid ;
int i_char ;
int i_entered ;
string t_result ;


editset(CONTROL_INPUT, t_caption) ;
editset(CONTROL_INPUT+1, t_default) ;
sendmsg(CONTROL_INPUT+1, EM_SETSEL, 0, -1) ;
wndshow(CONTROL_INPUT+4, SW_SHOW) ;
wndshow(CONTROL_INPUT+3, SW_SHOW) ;
wndshow(CONTROL_INPUT+2, SW_SHOW) ;
wndshow(CONTROL_INPUT+1, SW_SHOW) ;
wndshow(CONTROL_INPUT, SW_SHOW) ;


if (gi_options & OPT_M_IBSIP) {
devicesip(1) ;
}
guisetfocus(CONTROL_INPUT+1) ;


// Standard event loop. Continue until user terminates with ENTER or ESC or
// the box is closed. Ensure other applications can run whilst waiting.


i_active = TRUE ;
i_entered = FALSE ;
t_result = t_default ;


flushevent() ;


while (i_active) {
sleep(0) ;
i_event = event(1) ;


if (i_event == PM_CHAR) {


i_guiid = guigetfocus() ;


if (i_guiid == CONTROL_INPUT + 1) {


i_char = key() ;
switch (i_char) {
case 13: // Enter
if (i_entered) {
t_result = editget(CONTROL_INPUT + 1) ;
} else {
editset(CONTROL_INPUT + 1, t_default) ;
t_result = t_default ;
}
i_active = FALSE ;
break ;
case 27: // Esc
i_active = FALSE ;
break ;
default:
i_entered = TRUE ;
break ;
}
}
}
}


// Hide the controls and return the user input, or default input


devicesip(0) ;


wndshow(CONTROL_INPUT+3, SW_HIDE) ;
wndshow(CONTROL_INPUT+2, SW_HIDE) ;
wndshow(CONTROL_INPUT+1, SW_HIDE) ;
wndshow(CONTROL_INPUT, SW_HIDE) ;
wndshow(CONTROL_INPUT+4, SW_HIDE) ;


return (t_result) ;
}


</font id=code></pre id=code>




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
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
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby guy on Mon Aug 19, 2002 10:07 am

Call the create function at the start of your program, then call InputBox() whenever you want to get input from the user.

The code is lifted from PCForm, so it may not fit neatly into other programs. The only weird bit is the global options value, which contains user preferences, one bit is used to determine whether the user wants the keyboard turned on during input on the PPC and PocketPC platform.


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
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
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron