Passing keystrokes to main window

Passing keystrokes to main window

Postby hua » Tue Jul 03, 2007 8:12 am

I've defined a menu at the main window which uses accelerators in a MDI environment. Initial test was ok and I was quite happy. Later I tried using dialog box in the child window so I can use the resource editor to place my controls. This however caused the accelerators to stop working which I suspect because all the keystrokes are sent only to the dialog box. How do I get the keystrokes to be sent to the main window as well?

TIA
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby Antonio Linares » Tue Jul 03, 2007 12:27 pm

Please review and use this new way to place the dialog controls on a MDI child window:
Code: Select all  Expand view
#include "FiveWin.ch"

#define COLOR_BTNFACE   15

function Main()

   local oWnd

   USE Customer

   DEFINE WINDOW oWnd TITLE "Test" MDI

   ACTIVATE WINDOW oWnd ;
      ON INIT BuildChild()

return nil

function BuildChild()

   local oChild
   
   DEFINE WINDOW oChild TITLE "A Child Window" MDICHILD ;
      COLOR 0, GetSysColor( COLOR_BTNFACE )
   
   ACTIVATE WINDOW oChild ;
      ON INIT BuildDialog( oChild )
   
return nil   

function BuildDialog( oChild )

   local oDlg, oBrw, oSay, cText := "Hello World!"
 
   DEFINE DIALOG oDlg RESOURCE "DE_HEADER_BROWSE" OF oChild
   
   oBrw = TXBrowse():New( oDlg )
   oBrw:CreateFromResource( 10 )
   oBrw:SetRDD()
   
   REDEFINE BUTTON ID 20 OF oDlg
   REDEFINE BUTTON ID 30 OF oDlg
   REDEFINE BUTTON ID 40 OF oDlg
   REDEFINE BUTTON ID 50 OF oDlg
   REDEFINE BUTTON ID 60 OF oDlg
   REDEFINE BUTTON ID 70 OF oDlg
   REDEFINE BUTTON ID 80 OF oDlg
   REDEFINE BUTTON ID 100 OF oDlg
   REDEFINE BUTTON ID   1 OF oDlg

   REDEFINE SAY oSay VAR cText ID 90 OF oDlg

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT ChangeParent( oDlg, oChild )
     
   oDlg:End()   
   oChild:bResized = { || oBrw:SetSize( oChild:nWidth - 117, oChild:nHeight - 60 ),;
                                     oSay:nTop := oChild:nHeight - 55, oSay:nLeft := ( oChild:nWidth / 2 ) - oSay:nWidth / 2 }
   oChild:SetSize( 800, 400 )
   
return nil   

#define GW_CHILD      5
#define GW_HWNDNEXT   2

function ChangeParent( oDlg, oWnd )

   local hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )
   local n, aChilds := {}

   while hCtrl != 0
      AAdd( aChilds, hCtrl )
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
   end

   AEval( aChilds, { | hCtrl | SetParent( hCtrl, oWnd:hWnd ) } )

   for n = 1 to Len( oDlg:aControls )
      AAdd( oWnd:aControls, oDlg:aControls[ n ] )
   next

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests