FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Passing keystrokes to main window
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Passing keystrokes to main window
Posted: Tue Jul 03, 2007 08: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

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Passing keystrokes to main window
Posted: Tue Jul 03, 2007 12:27 PM
Please review and use this new way to place the dialog controls on a MDI child window:
#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

Continue the discussion