* *

Coding

User

Welcome, Guest. Please login or register.
May 26, 2013, 03:54:11 AM

Login with username, password and session length

Menu

Stats

Members
  • Total Members: 491
  • Latest: TOPMO3
Stats
  • Total Posts: 12063
  • Total Topics: 1688
  • Online Today: 57
  • Online Ever: 150
  • (September 26, 2012, 02:29:19 PM)
Users Online
Users: 0
Guests: 45
Spiders: 3
Total: 48
Google
Exabot
Baidu

Recent Topics

Author Topic: Using enter within a dialog.  (Read 6103 times)

0 Members and 1 Guest are viewing this topic.

Offline rosslcs

  • Newbie
  • *
  • Posts: 30
  • Bananas: 0
Using enter within a dialog.
« on: May 23, 2012, 08:10:55 AM »
Is it possible to use the enter key within a dialog to get the same result as clicking on a button?

Somthing like ..

If inkey$=(13) then ...


Code: [Select]
SUB dhfind

SELECT @CLASS

CASE @IDCONTROL
Select
@CONTROLID

'Find
case 19
IF @notifycode=0
find$ =
GETCONTROLTEXT(d1,4)
match_case = GETSTATE (d1, 20)

'Found
if
match_case=0 then Position = CONTROLCMD (w1, 1, @RTFINDTEXT, find$, Position,
1)
if match_case=1 then Position = CONTROLCMD (w1, 1, @RTFINDTEXT, find$,
Position, 0)

'Highlight find
CONTROLCMD
w1,1,@RTHIDESEL,0
CONTROLCMD
w1,1,@RTSETSELECTION,Position,Position+len(find$)

'No mach
if
Position=-1 then MessageBox(0,"Search for "+chr$(34)+find$+chr$(34)+" no mach
found.", "Find",1+64)
Position=Position+1

'Display line
no
currentlinenr=controlcmd(w1,1,@rtlinefromchar,-1)
Lcount = CONTROLCMD (
w1,1,@RTGETLINECOUNT)
CONTROLCMD w1,1000,@SWSETPANETEXT,3,"
Line"+str$(currentlinenr+1)+" of"+str$(Lcount)
ENDIF

'Cancel
case
9
IF @notifycode=0
closedialog d1,@IDOK

ENDIF

Endselect
ENDSELECT

RETURN
« Last Edit: May 23, 2012, 08:36:47 AM by Larry McCaughn »

Offline Larry McCaughn

  • Administrator
  • Full Member
  • *****
  • Posts: 193
  • Bananas: 4
  • Gender: Male
Re: Using enter within a dialog.
« Reply #1 on: May 23, 2012, 08:41:22 AM »
Maybe you can do what you want with this:
Code: [Select]
DEF d1:DIALOG

CONST BN_CLICKED = 0

CONST BN_SETFOCUS = 6   
CONST BS_NOTIFY = &H4000

CONST BM_CLICK = &HF5

DEF answer:INT

DEF CurrentButtonCID:INT


DIALOG d1,0,0,213,129,0x80C80080,0,"Enter Selects Button",Handler

CONTROL d1,"B,Hidden Default Button,71,18,70,20,0x40080001,10"

CONTROL d1,"E,Edit Box,40,10,128,34,0x50811004,15"

'BS_NOTIFY = Want the next three buttons to receive (BN_) Button Notification messages.

CONTROL d1,"B,OK,23,55,70,20,0x50010000|BS_NOTIFY,11"

CONTROL d1,"B,Cancel,119,54,70,20,0x50010000|BS_NOTIFY,12"

CONTROL d1,"B,Close,71,90,70,20,0x50010000|BS_NOTIFY,13"


answer = DOMODAL(d1)

end

sub Handler

select @CLASS

   case @IDCONTROL

      select @CONTROLID

         case 10 :'default button (enter key)

            sendmessage (d1,BM_CLICK,0,0,CurrentButtonCID)

            'BM_CLICK

            'An application sends a BM_CLICK message to simulate the user clicking a button.

            'This message causes the button to receive the WM_LBUTTONDOWN and WM_LBUTTONUP messages,

            'and the button's parent window to receive a BN_CLICKED notification message.

            'CurrentButtonCID is the button that has focus.

         case 11

            if @notifycode=BN_SETFOCUS then CurrentButtonCID=@CONTROLID

            'BN_SETFOCUS

            'The BN_SETFOCUS notification code is sent when a button receives the keyboard focus.

            'The button must have the BS_NOTIFY style to send this notification message.

            if @notifycode=BN_CLICKED then messagebox d1,"OK Button","OK"

            'The button was selected using enter or mouse click.  Execute our code.

         case 12

            if @notifycode=BN_SETFOCUS then CurrentButtonCID=@CONTROLID

            if @notifycode=BN_CLICKED then messagebox d1,"Cancel Button","Cancel"

         case 13

            if @notifycode=BN_SETFOCUS then CurrentButtonCID=@CONTROLID

            if @notifycode=BN_CLICKED then closedialog d1,@IDOK

      endselect

   case @IDINITDIALOG

      CENTERWINDOW d1

endselect

return

 
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif