gets() dialog too small in my jornada 720

Discuss PocketC for CE (including Desktop Edition)

Postby raymund on Tue Jun 25, 2002 4:40 pm

Hi all,

I am trying pocketC these days.
I found that the console gets() dialog appears too small to display characters typed in it (although you can still type in).
Any idea on how this small problem can be solved?

Thanks.
raymund
 
Posts: 1
Joined: Tue Jun 25, 2002 4:35 pm

Postby KOU on Wed Jun 26, 2002 2:43 pm

You can create small dialog for input using createctrl function.
Be careful not to use createctrl1.
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby guy on Tue Jul 02, 2002 6:56 am

Try using this code, or a variant of it.

Call CreateInputDialogue() at the start of your program before creating any controls. Then call InputBox() whenever you want to get input from the user. Use InputBox() like gets(), the second parameter is an optional default value. Pass "" if you have no default value.


<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


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 2 guests

cron